GithubHelp home page GithubHelp logo

grok - log rotation issue about grok_exporter HOT 14 CLOSED

fstab avatar fstab commented on August 15, 2024
grok - log rotation issue

from grok_exporter.

Comments (14)

senattcsgit avatar senattcsgit commented on August 15, 2024 1

I upgraded the grok and so far I didnt see the error I used to see with previous release. Heading in right direction, but I would like to monitor for few more days to close this issue.

from grok_exporter.

fstab avatar fstab commented on August 15, 2024

This error occurs if the grok_exporter process does not have the permission to open the log file. Could you double-check if the user running grok_exporter can read the file?

from grok_exporter.

senattcsgit avatar senattcsgit commented on August 15, 2024

file permissions are okay because grok exporter comes up successfully and parses log files but when log file gets rotated-thats when its get killed. if permissions were problem, i would have seen issue when Im bringing up grok initially.

Log files have 755 permissions and grok has rwx for these files.

from grok_exporter.

fstab avatar fstab commented on August 15, 2024

How is your logrotate configured and which file system are you using?

from grok_exporter.

senattcsgit avatar senattcsgit commented on August 15, 2024

We are using rsyslog.d and here is the configuration 👍
[xxxx@ppppppp002c:/etc/rsyslog.d]> cat haproxy.conf

Saving application haproxy logs haproxy.log

$ModLoad imudp
$UDPServerRun 514
$UDPServerAddress 127.0.0.1
local0.* /var/prod/logs/yyyy/haproxy/tugs_hap.log
local1.* /var/prod/logs/yyyy/haproxy/http_hap.log
local2.* /var/prod/logs/yyyy/haproxy/securehttp_hap.log
local4.* /var/prod/logs/yyyy/haproxy/rest_hap.log
local5.* /var/prod/logs/yyyy/haproxy/ssl_hap.log
local6.* /var/prod/logs/yyyy/haproxy/caas_hap.log
[xxxx@ppppppp002c:/etc/rsyslog.d]>

from grok_exporter.

senattcsgit avatar senattcsgit commented on August 15, 2024

and the filesystem type is xfs

/dev/mapper/vg01-lvvarprodlogsxxxx /var/prod/logs/xxxx xfs defaults 1 2

from grok_exporter.

fstab avatar fstab commented on August 15, 2024

Maybe the error is related to how the rotated files like http_hap.log-20190529.gz are created, and how the logfile http_hap.log is re-created after rotation. Is rsyslog doing this in your case, or is logrotate running in addition to rsyslog to rotate the log files?

I am asking because rsyslog seems to support custom log rotation scripts (like here), and logrotate has a lot of configuration options how log files are rotated and re-created.

from grok_exporter.

senattcsgit avatar senattcsgit commented on August 15, 2024

Any best practices you can advice on the log rotation like moving the old file or copying? How is community handling these scenarios, I'm sure no one is maintaining one log file, which might fill up the disk space...Thoughts? In the meantime, I will get answers on rsyslog as it is handled by UNIX SA's in my company.

from grok_exporter.

senattcsgit avatar senattcsgit commented on August 15, 2024

Looks like it's both rsyslog and logrotate

and here is the logrotate configuration:

[xxxx@ppppppp002c:/etc/logrotate.d]> cat haproxy
/var/prod/logs/xxxx/haproxy/tugs_hap.log
/var/prod/logs/xxxx/haproxy/http_hap.log
/var/prod/logs/xxxx/haproxy/securehttp_hap.log
/var/prod/logs/xxxx/haproxy/rest_hap.log
/var/prod/logs/xxxx/haproxy/ssl_hap.log
/var/prod/logs/xxxx/haproxy/caas_hap.log
{
missingok
notifempty
sharedscripts
size 500M
rotate 4
daily
compress
postrotate
service rsyslog restart >/dev/null 2>&1 || true
endscript
create 0755 xxxx yyyy
}
[xxxx@ppppppp002c:/etc/logrotate.d]>

from grok_exporter.

fstab avatar fstab commented on August 15, 2024

This should work. Could you update to grok_exporter v0.2.7 and report if the error persists, and which error message you get with the current release?

from grok_exporter.

senattcsgit avatar senattcsgit commented on August 15, 2024

current error message : error reading log lines: failed to watch /var/prod/logs/xxxx/haproxy/http_hap.log: open /var/prod/logs/xxxx/haproxy/http_hap.log: permission denied

I will work on upgrade and report tomorrow . Thanks for your help.

from grok_exporter.

senattcsgit avatar senattcsgit commented on August 15, 2024

Even with new grok version- I'm still seeing the issue.
grok version: grok_exporter version: 0.2.7 (build date: 2019-04-08, branch: master, revision: e2ba841, go version: go1.12.2, platform: linux-amd64)

error reading log lines: /var/prod/logs/xxxx/haproxy/http_hap.log: failed to open file: open /var/prod/logs/xxxx/haproxy/http_hap.log: permission denied

Is this happening when log rotation is in progress and grok is trying to open file? anyway to ignore

from grok_exporter.

fstab avatar fstab commented on August 15, 2024

I checked where the error message is created in the grok_exporter source code: I assume logrotate ran shortly before the error and moved the original http_hap.log away. Then a new http_hap.log was created. grok_exporter detects the new file, tries to open it, and gets a permission denied error from the operating system. That causes the error.

As you say grok_exporter can successfully read the file when you restart it, the permission denied error seems to be a temporary problem that occurs only shortly after the new file is created.

Could you check if you have ACLs configured for your file system? Maybe ACLs are causing a short delay until correct permissions are applied.

from grok_exporter.

senattcsgit avatar senattcsgit commented on August 15, 2024

Closing the issue as we found a work around by introducing a cronjob and more recently by moving to kubernetes.

from grok_exporter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.