We have beats running and watching a single log file that is updated a few times per second constantly. The log file is generated by the Python3.6 logging.handlers.WatchedFileHandler and is rotated by logrotate once it reaches 1G. For the purposes of this issue I have disabled logrotate completely to rule it out as a factor.
Operating System:
$ cat /etc/os-release
NAME="Ubuntu"
VERSION="14.04.5 LTS, Trusty Tahr"
Beats Version:
5.2.2
Config:
filebeat:
prospectors:
-
paths:
- /logs/my-app/my-app*.jsonlog
fields_under_root: true
input_type: log
document_type: customlogtype
tail_files: false
type: log
fields:
a: bunch
of: fields
with: extra
info: banana
output:
logstash:
hosts: ["192.51.100.1:5000"]
logging.level: debug
logging.to_files: true
logging.to_syslog: false
logging.files:
path: /var/log/filebeat
name: mybeat.log
keepfiles: 7
Logs:
2017-03-02T01:14:02Z DBG Run prospector
2017-03-02T01:14:02Z DBG Start next scan
2017-03-02T01:14:02Z DBG Check file for harvesting: /logs/my-app/my-app-PID54.jsonlog
2017-03-02T01:14:02Z DBG Update existing file for harvesting: /logs/my-app/my-app-PID54.jsonlog, offset: 17268771
2017-03-02T01:14:02Z DBG Harvester for file is still running: /logs/my-app/my-app-PID54.jsonlog
2017-03-02T01:14:02Z DBG Prospector states cleaned up. Before: 1, After: 1
2017-03-02T01:14:12Z DBG Run prospector
2017-03-02T01:14:12Z DBG Start next scan
2017-03-02T01:14:12Z DBG Check file for harvesting: /logs/my-app/my-app-PID54.jsonlog
2017-03-02T01:14:12Z DBG Update existing file for harvesting: /logs/my-app/my-app-PID54.jsonlog, offset: 17268771
2017-03-02T01:14:12Z DBG Harvester for file is still running: /logs/my-app/my-app-PID54.jsonlog
2017-03-02T01:14:12Z DBG Prospector states cleaned up. Before: 1, After: 1
2017-03-02T01:14:16Z DBG 41 events out of 1822 events sent to logstash. Continue sending
2017-03-02T01:14:16Z DBG Try to publish 1781 events to logstash with window size 41
2017-03-02T01:14:22Z INFO Non-zero metrics in the last 30s: libbeat.logstash.publish.write_bytes=9534 libbeat.logstash.publish.read_bytes=12
2017-03-02T01:14:22Z DBG Run prospector
2017-03-02T01:14:22Z DBG Start next scan
2017-03-02T01:14:22Z DBG Check file for harvesting: /logs/my-app/my-app-PID54.jsonlog
2017-03-02T01:14:22Z DBG Update existing file for harvesting: /logs/my-app/my-app-PID54.jsonlog, offset: 17268771
2017-03-02T01:14:22Z DBG Harvester for file is still running: /logs/my-app/my-app-PID54.jsonlog
2017-03-02T01:14:22Z DBG Prospector states cleaned up. Before: 1, After: 1
2017-03-02T01:14:32Z DBG Run prospector
2017-03-02T01:14:32Z DBG Start next scan
2017-03-02T01:14:32Z DBG Check file for harvesting: /logs/my-app/my-app-PID54.jsonlog
2017-03-02T01:14:32Z DBG Update existing file for harvesting: /logs/my-app/my-app-PID54.jsonlog, offset: 17268771
2017-03-02T01:14:32Z DBG Harvester for file is still running: /logs/my-app/my-app-PID54.jsonlog
2017-03-02T01:14:32Z DBG Prospector states cleaned up. Before: 1, After: 1
2017-03-02T01:14:33Z DBG 41 events out of 1781 events sent to logstash. Continue sending
2017-03-02T01:14:33Z DBG Try to publish 1740 events to logstash with window size 41
2017-03-02T01:14:42Z DBG Run prospector
2017-03-02T01:14:42Z DBG Start next scan
2017-03-02T01:14:42Z DBG Check file for harvesting: /logs/my-app/my-app-PID54.jsonlog
2017-03-02T01:14:42Z DBG Update existing file for harvesting: /logs/my-app/my-app-PID54.jsonlog, offset: 17268771
2017-03-02T01:14:42Z DBG Harvester for file is still running: /logs/my-app/my-app-PID54.jsonlog
2017-03-02T01:14:42Z DBG Prospector states cleaned up. Before: 1, After: 1
2017-03-02T01:14:50Z DBG 41 events out of 1740 events sent to logstash. Continue sending
2017-03-02T01:14:50Z DBG Try to publish 1699 events to logstash with window size 41
2017-03-02T01:14:52Z INFO Non-zero metrics in the last 30s: libbeat.logstash.publish.read_bytes=12 libbeat.logstash.publish.write_bytes=9192
2017-03-02T01:14:52Z DBG Run prospector
2017-03-02T01:14:52Z DBG Start next scan
2017-03-02T01:14:52Z DBG Check file for harvesting: /logs/my-app/my-app-PID54.jsonlog
2017-03-02T01:14:52Z DBG Update existing file for harvesting: /logs/my-app/my-app-PID54.jsonlog, offset: 17268771
2017-03-02T01:14:52Z DBG Harvester for file is still running: /logs/my-app/my-app-PID54.jsonlog
2017-03-02T01:14:52Z DBG Prospector states cleaned up. Before: 1, After: 1
As you can see in the logs the Harvester reads the file and records the offset but the offset never increments and the Harvester never stops running. Before it gets stuck in this loop all of the logs up until the offset byte are sent correctly to elasticsearch.