Hi,
i'm using filebeat 1.2.3 and i do not understand a behavior on rotated files that lead my monitoring system to be unreliable from two point of view: events are not sent properly and rotated files are not closed properly. I've the following test case:
my config file
filebeat:
registry_file: /var/run/filebeat
publish_async: false
idle_timeout: 10s
spool_size: 2048
prospectors:
-
input_type: log
force_close_files: true
multiline:
negate: true
pattern: "^{"
match: after
paths:
- /var/log/test.log
close_older: 5m
output:
logstash:
max_retries: 1000000
worker: 5
timeout: 10
bulk_max_size: 8192
loadbalance: true
hosts: ["localhost:5044"]
logging:
level: info
# enable file rotation with default configuration
to_files: true
# do not log to syslog
to_syslog: false
files:
path: /var/log/filebeat
name: filebeat.log
keepfiles: 10
rotateeverybytes: 104857600
Logging after log rotation
bash$> cat /var/log/filebeat/filebeat.log | grep test.log
2016-06-15T08:06:04+02:00 INFO Harvester started for file: /var/log/test.log
2016-06-15T14:42:55+02:00 INFO Not resuming rotated file: /var/log/test.log
2016-06-15T14:42:55+02:00 INFO Harvester started for file: /var/log/test.log
2016-06-15T14:43:05+02:00 INFO Not resuming rotated file: /var/log/test.log
2016-06-15T14:43:15+02:00 INFO Not resuming rotated file: /var/log/test.log
2016-06-15T14:43:35+02:00 INFO Not resuming rotated file: /var/log/test.log
2016-06-15T14:43:45+02:00 INFO Not resuming rotated file: /var/log/test.log
2016-06-15T14:43:55+02:00 INFO Not resuming rotated file: /var/log/test.log
2016-06-15T14:44:05+02:00 INFO Not resuming rotated file: /var/log/test.log
2016-06-15T14:44:15+02:00 INFO Not resuming rotated file: /var/log/test.log
2016-06-15T14:44:25+02:00 INFO Not resuming rotated file: /var/log/test.log
....
List of open file at 2016-06-15T18:44:25+02:00
bash$> lsof -p 43117
filebeat 43117 root 21r REG 8,17 6237614492 2883693 /var/log/test.log.1 (deleted)
filebeat 43117 root 41r REG 8,17 4395389695 2884028 /var/log/test.log
Some analysis on the state file
At this point i've analyzed changes on state file and i've fount a strange behaviour. With the following command i'm monitoring changes on reference of the inode and offset and we can see that the inode reference flaps betweend the deleted rotated file and the current one.
bash$> while true; do (cat /var/run/filebeat | jq . | grep -B 6 -P "source.*test.log" && sleep 2); done
"/var/log/test.log": {
"FileStateOS": {
"device": 2065,
"inode": 2883693
},
"offset": 1867412648,
"source": "/var/log/test.log"
"/var/log/test.log": {
"FileStateOS": {
"device": 2065,
"inode": 2883693
},
"offset": 1867412648,
"source": "/var/log/test.log"
"/var/log/test.log": {
"FileStateOS": {
"device": 2065,
"inode": 2884028
},
"offset": 410248229,
"source": "/var/log/test.log"
"/var/log/test.log": {
"FileStateOS": {
"device": 2065,
"inode": 2884028
},
"offset": 410294689,
"source": "/var/log/test.log"
"/var/log/test.log": {
"FileStateOS": {
"device": 2065,
"inode": 2884028
},
"offset": 410294689,
"source": "/var/log/test.log"
One little detail that can be useful: the process writing on /var/log/test.log after log rotation write correcty to the new file. Is there an issue in my configuration?