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

Make Logparser Plugin Check For New Files #2141

Merged
merged 3 commits into from
Feb 1, 2017

Conversation

njwhite
Copy link
Contributor

@njwhite njwhite commented Dec 8, 2016

Required for all PRs:

  • CHANGELOG.md updated (we recommend not updating this until the PR has been approved by a maintainer)
  • Sign CLA (if not already signed)
  • README.md updated (if adding a new plugin)

Check in the Gather metric to see if any new files matching the glob
have appeared. If so, start tailing them from the beginning.

@sparrc sparrc added this to the 1.3.0 milestone Jan 25, 2017
Copy link
Contributor

@sparrc sparrc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put a note in the sample config that new files will always be tailed from the beginning.

Check in the Gather metric to see if any new files matching the glob
have appeared. If so, start tailing them from the beginning.
@njwhite
Copy link
Contributor Author

njwhite commented Jan 30, 2017

@sparrc thanks - I've updated the PR with your review feedback

@sparrc
Copy link
Contributor

sparrc commented Jan 30, 2017

looks good, please update the changelog!

@sparrc
Copy link
Contributor

sparrc commented Jan 30, 2017

I believe this closes #1829

@njwhite njwhite force-pushed the feature/newfiles branch 2 times, most recently from 2cab413 to 7db7591 Compare January 31, 2017 22:52
@njwhite
Copy link
Contributor Author

njwhite commented Jan 31, 2017

@sparrc thanks - I've updated the changelog.

@sparrc sparrc merged commit 2932db8 into influxdata:master Feb 1, 2017
mlindes pushed a commit to Comcast/telegraf that referenced this pull request Feb 6, 2017
* Make Logparser Plugin Check For New Files

Check in the Gather metric to see if any new files matching the glob
have appeared. If so, start tailing them from the beginning.

* changelog update for influxdata#2141
eldadzack pushed a commit to eldadzack/telegraf that referenced this pull request Mar 27, 2017
* Make Logparser Plugin Check For New Files

Check in the Gather metric to see if any new files matching the glob
have appeared. If so, start tailing them from the beginning.

* changelog update for influxdata#2141
@kiplandiles
Copy link

kiplandiles commented Apr 19, 2017

Telegraf v1.2.1 (git: release-1.2 3b6ffb3)
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04.5 LTS"

Was this fixed? I just fired up a logParser input for a haproxy.log and noticed that Grafana quit displaying the metrics from the haproxy.log. When I checked telegraf.log I see the information below. At 16:13:31 I started telegraf. At 16:17:01 it looks like telegraf is attempting to handle the log rotation and at 16.17.02 it looks to have reopened the new haproxy.log file. That's when I lost my metrics in Grafana. I "reloaded" telegraf (service reload telegraf) at 16:34 and started collecting metrics again. Maybe telegraf need to HUP itself as part of this process.

2017/04/19 16:13:31 Seeked /var/log/haproxy.log - &{Offset:0 Whence:2}
2017/04/19 16:17:01 Re-opening moved/deleted file /var/log/haproxy.log ...
2017/04/19 16:17:01 Successfully reopened /var/log/haproxy.log
2017/04/19 16:17:02 Re-opening moved/deleted file /var/log/haproxy.log ...
2017/04/19 16:17:02 Successfully reopened /var/log/haproxy.log
2017/04/19 16:34:09 Seeked /var/log/haproxy.log - &{Offset:0 Whence:2}

Relevant portion of my telegraf configuration

[global_tags]
  role = "haproxy"
[[inputs.logparser]]
  ## file(s) to tail:
  files = ["/var/log/haproxy.log"]
  from_beginning = false
  name_override = "haproxy_log"
  ## For parsing logstash-style "grok" patterns:
  [inputs.logparser.grok]
    patterns = ["%{HAPROXYHTTP}"]
    custom_patterns = '''
        HAPROXYTIME %{HOUR}:%{MINUTE}:%{SECOND}
        HAPROXYDATE %{MONTH:haproxy_month} %{MONTHDAY:haproxy_day} %{HAPROXYTIME:haproxy_time}
        HAPROXYHTTP %{HAPROXYDATE} %{IPORHOST:syslog_server} %{SYSLOGPROG}: %{IP:client_ip} %{WORD:method} %{URIPATHPARAM:http_request} HTTP/%{NUMBER} %{NUMBER:status:int} %{NUMBER:request_bytes:int} %{INT}
    '''

@danielnelson
Copy link
Contributor

@kiplandiles See #1829

@kiplandiles
Copy link

@danielnelson - Thanks. I actually started at #1829 and it referred me here. I'm a bit of a GitHub newbie so sorry if I should have posted there instead. So do I understand that this won't be fixed until 1.3? @sparrc commented that this closed 1829.

@danielnelson
Copy link
Contributor

I reopened that issue because there are still problems. I believe it is caused by a bug in the upstream project. Perhaps this issue: hpcloud/tail#97

I'm not sure when it will get fixed, but I don't consider it a blocker because it isn't a regression. Perhaps there is already a solution floating around that we could merge into our fork https://github.com/influxdata/tail.

The next release of Telegraf will be 1.3, not planning any bug fix releases before then.

@kiplandiles
Copy link

Thanks again. Guess I will handle this issue myself with logrotate.

postrotate
	reload telegraf >/dev/null 2>&1 || true
endscript

We shall see how that works out. Already have to add telegraf to the adm group just to access the haproxy log file so logParser seems to require a bit of tweaking.
usermod -aG adm telegraf

@d0o0
Copy link

d0o0 commented Apr 3, 2018

how to closed the fd of the deleted files? since tail only execute closefile when telegraf exits

maxunt pushed a commit that referenced this pull request Jun 26, 2018
* Make Logparser Plugin Check For New Files

Check in the Gather metric to see if any new files matching the glob
have appeared. If so, start tailing them from the beginning.

* changelog update for #2141
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants