Hello, all.
I was wondering if anyone has ever stumbled across this and if there are any workarounds (I've been bashing my head against it for entirely too long now...).
I have multiple servers using filebeat to ship logs to a central Elasticsearch instance.
All filebeat installations are elastic.co sourced debian packages and not docker containers.
Logs are successfully sent/received with all expected metadata from /var/log/.log via a filestream input and /var/lib/docker/containers//*.log via container input (and add_docker_metadata processor).
All systems and docker containers are configured for US/Central time and not UTC.
The problem is that the index name filebeat writes to (log-%{+yyyy.MM.dd}) is based on local time for the system files and UTC for the docker container files.
This results in logs for the same time being written to two different indexes for the hours that local and UTC dates differ. For example:
{
"_index": "log-2022.12.26",
"_type": "_doc",
"_id": "1UKU3dFvXGM",
"_score": 6.228486318473047,
"@timestamp": "2022-12-27T05:59:54.296Z",
--SNIP--
"input": {
"type": "filestream"
},
"log": {
"file": {
"path": "/var/log/syslog"
},
"offset": 94772
},
--SNIP--
}
}
{
"_index": "log-2022.12.27",
"_type": "_doc",
"_id": "1UKTYk0pzlC",
"_score": 6.611061873463312,
"@timestamp": "2022-12-27T05:58:44.123000064Z",
--SNIP--
"input": {
"type": "container"
},
"log": {
"file": {
"path": "/var/lib/docker/containers/3f86dbb851588a7129890a92f885d3de0e7637252887f936a62359a46bc73b09/3f86dbb851588a7129890a92f885d3de0e7637252887f936a62359a46bc73b09-json.log"
},
"offset": 44300259
},
--SNIP--
}
}
I'm running filebeat 8.5.3 across the board and see the results in the latest version of Elasticsearch and Zincsearch.
Here's my filebeat.yml:
filebeat.inputs:
- type: filestream
id: syslogs
enabled: true
paths:
- /var/log/*.log
- /var/log/syslog
- type: container
paths:
- /var/lib/docker/containers/*/*.log
filebeat.config.modules:
path: ${path.config}/modules.d/*.yml
reload.enabled: false
output.elasticsearch:
hosts: ["REDACTED"]
path: "/es/"
index: "log-%{+yyyy.MM.dd}"
username: "REDACTED"
password: "REDACTED"
processors:
- add_host_metadata:
when.not.contains.tags: forwarded
- add_docker_metadata:
host: "unix:///var/run/docker.sock"
setup.ilm.enabled: false
setup.template.name: "log"
setup.template.pattern: "log-*"
logging.level: error
logging.to_syslog: false
logging.to_files: false
Any thoughts, suggestions or insights would be greatly appreciated.
Thanks,
Matthew