Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logparser should error and exit on permissions errors #1418

Closed
ahivert opened this issue Jun 24, 2016 · 5 comments
Closed

logparser should error and exit on permissions errors #1418

ahivert opened this issue Jun 24, 2016 · 5 comments
Labels
bug unexpected problem or unintended behavior

Comments

@ahivert
Copy link

ahivert commented Jun 24, 2016

I'm testing the awesome new logparser plugin but I have trouble to made it work.

Actually with this version

Telegraf - version 1.0.0-beta2

Running it on Ubuntu 14.04

This is my conf with logparser

[[inputs.logparser]]
    files = [ "/var/log/nginx/access.log" ]
  [inputs.logparser.grok]
    patterns = [ "%{COMMONAPACHELOG} %{QS:referrer} %{QS:agent}" ]

This settings works when I type telegraf in my console but not work when I launch telegraf with service telegraf start

When I launch telegraf in my console I can see the lines

Loaded inputs: cpu disk diskio net nginx logparser mem system
Seeked /var/log/nginx/access.log - &{Offset:0 Whence:2}

But when I launch it from service telegraf start this is the lines in logfile

Loaded inputs: diskio net nginx logparser mem system cpu disk

The line with Seeked is not presents

If I set only the logparser plugin, there is 0 metric gathered.

Maybe this is normal due to the beta release ?

@abarban
Copy link

abarban commented Jun 24, 2016

Similar issue on RedHat EL5! Also with tail plugin!

@sparrc
Copy link
Contributor

sparrc commented Jun 25, 2016

It's probably a permissions issue, try running sudo -u telegraf telegraf -config ..., the telegraf user must have permission to access that file.

@sparrc sparrc added the bug unexpected problem or unintended behavior label Jun 25, 2016
@sparrc
Copy link
Contributor

sparrc commented Jun 25, 2016

that being said, if it is a permissions issue, there should be an error message about that.

@ahivert
Copy link
Author

ahivert commented Jun 27, 2016

I just made the test and you're right @sparrc this is about permission on log file.

Thank you !

Add an error message to the log will help the user. :)

@mpchadwick
Copy link

I installed Telegraf this morning and configured logparser. Nothing's been written all day, and I suspect its permissions. Telegraf gives no indicator of that in /var/log/telegraf/telegraf.log, though

@sparrc sparrc changed the title logparser don't send metric when telegraf run as service logparser should error and exit on permissions errors Jul 18, 2016
sparrc added a commit that referenced this issue Jul 18, 2016
closes #1436

This also fixes the bad behavior of waiting until runtime to return log
parsing pattern compile errors when a pattern was simply unfound.

closes #1418

Also protect against user error when the telegraf user does not have
permission to open the provided file. We will now error and exit in this
case, rather than silently waiting to get permission to open it.
@sparrc sparrc closed this as completed in dabb6f5 Jul 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

4 participants