Hi Nadita,
By default, the Wazuh server retains logs and does not delete them automatically. However, you can choose when to manually or automatically delete these logs according to your legal and regulatory requirements.
These files were stored on the path /var/ossec/logs/archives/ and they rotate and compress in the same way that I explained before.
You can add a command to the crontab in order to schedule the deletion according to your criteria.
i.e.
Cronjob to remove older alerts
0 0 * * * find /var/ossec/logs/alerts/ -type f -mtime +365 -exec rm -f {} \;
0 0 * * * find /var/ossec/logs/archives/ -type f -mtime +365 -exec rm -f {} \;
Cronjob to move older alerts to another location
0 0 * * * find /var/ossec/logs/alerts/ -type d -mtime +90 -regex '\/var/ossec/logs/alerts\/[0-9]+' -exec cp -rp {} </path/to/NAS/> \; -exec rm -rf {} \;
0 0 * * * find /var/ossec/logs/arvhives/ -type d -mtime +90 -regex '\/var/ossec/logs/alerts\/[0-9]+' -exec cp -rp {} </path/to/NAS/> \; -exec rm -rf {} \;
Cronjob to compress uncompressed JSON alerts
0 8,20 * * * find /var/ossec/logs/archives/ -type f -regex '\S+ossec-archive-\S+-\S+.json' -exec gzip {} \;
0 8,20 * * * find /var/ossec/logs/alerts/ -type f -regex '\S+ossec-alerts-\S+-\S+.json' -exec gzip {} \;
You can take this as a reference and prepare a cronjob based on your required use case. You can also review
Crontab – Quick Reference to have a brief idea about how crontab works.
Note: If you have archives enabled, the rotated archives logs will be stored in the /var/ossec/logs/archives/ directory similarly. Therefore, you can follow the same process to move the archives log as well.
Please review this to understand how Wazuh log data collection works:
https://documentation.wazuh.com/current/user-manual/capabilities/log-data-collection/how-it-works.htmlHope this helps,
Regards,