Hello,
I have a use case where I ingest files created by the Wazuh agent, these files are created in paths with the following format:
/var/ossec/logs/archives/YYYY/MM/ossec-archive-dd.json
For example:
/var/ossec/logs/archives/2022/05/ossec-archive-05.json
Those files are hard-linked to the file /var/ossec/logs/archives/archives.json
, so it is pointing to the same inode and filebeat is configured to read the /var/ossec/logs/archives/archives.json
file.
Sometimes the source file needs to be rotated because its size, so I will have something like this:
/var/ossec/logs/archives/2022/05/ossec-archive-05.json
/var/ossec/logs/archives/2022/05/ossec-archive-05-001.json
/var/ossec/logs/archives/2022/05/ossec-archive-05-XXX.json
The new rotated file is then hard-linked to the /var/ossec/logs/archives/archives.json
and filebeat can read it without any problems.
The issue is:
After the original file is rotated and has not been updated for a while, filebeat is not releasing the file handler, I have a background process to compress the ossec-archive-XX.json
files because of disk space issues, but since I check if the file is being used with lsof
and filebeat is not releasing it, the files don't get compressed.
This issue did not happen when using the log input, they started happening when we updated to use the filestream input.
The documentation says that the default value for close.on_state_change.inactive
is 5 minutes, so I would expect that filebeat closed the file handler for inactive files after 5 minutes without any update, this is not happening, I also tried to explicitly set this in the filebeat.yml
, but it also didn't work, I can only release the file handlers if I restart filebeat.
Is there any other config that I could tweak to solve this, to make filebeat release the file handler after some time?
This is my current filebeat.yml
filebeat.config.inputs:
enabled: true
path: "/etc/filebeat/inputs/*.yml"
setup.ilm.enabled: false
ilm.enabled: false
setup.template.enabled: false
queue.mem:
events: 8000
flush.min_events: 1000
flush.timeout: 1s
output.elasticsearch:
hosts: '${ES_HOT_NODES}'
loadbalance: true
worker: 2
bulk_max_size: 500
compression_level: 5
username: '${ES_USERNAME}'
password: '${ES_PASSWORD}'
ssl.certificate_authorities: ["/etc/filebeat/config/certs/ca.crt"]
http.enabled: true
http.port: 5067
monitoring.enabled: false
monitoring.cluster_uuid: '${ES_MONITORING_UUID}'
And this is the input wazuh.yml
- type: filestream
paths:
- /var/ossec/logs/archives/archives.json
fields:
index_prefix: index-name
pipeline: ingest-pipeline-name
I'm running 7.16.3, an update is planned but will not happen now.