Wazuh keep a maximum of 60 days of information

1,387 views
Skip to first unread message

Daniel Hinojo

unread,
Jan 28, 2021, 11:37:17 AM1/28/21
to Wazuh mailing list
Good morning Dear, a query how can I configure my wazuh so that when I have information of 60 days it begins to eliminate this in order to free up space. please your support. Thank you  

elw...@wazuh.com

unread,
Jan 29, 2021, 1:46:36 AM1/29/21
to Wazuh mailing list
Hello Daniel,

You can define a cronjob on your Wazuh manager server to remove data older than 60 days as follows:

  • Edit cron job file : crontab -e

  • Add the command : 45 0 * * * find /var/ossec/logs/ -name "*.gz" -type f -mtime +60 -exec rm -f {} \;  It will delete all compressed files under /var/ossec/logs that have not been modified in the last 60 days, every day at 00:45.
Hope it helps,

Regards,
Wali

Davide Bozzelli

unread,
Jan 29, 2021, 2:40:46 AM1/29/21
to elw...@wazuh.com, Wazuh mailing list
Hi

I think he means elk data too, which is the n.1 disk space consumer. 



--
You received this message because you are subscribed to the Google Groups "Wazuh mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wazuh+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wazuh/eadb1ec2-1c83-4fe3-82ea-add325d156d8n%40googlegroups.com.

elw...@wazuh.com

unread,
Feb 1, 2021, 5:08:53 AM2/1/21
to Wazuh mailing list

Hello Davide,

If he is referring to the data in Elasticsearch, Index Lifecycle Management can be implemented as described thoroughly here https://wazuh.com/blog/wazuh-index-management/.  He would need to specify only the delete phase to keep 60 days.


Hope it helps,

Regards,
Wali


Daniel Hinojo

unread,
Feb 3, 2021, 10:28:07 PM2/3/21
to Wazuh mailing list
Thanks for your answer to all, with this link I can free up space on my disk of all the history of both elastic and ossec log?  

elw...@wazuh.com

unread,
Feb 4, 2021, 1:57:27 AM2/4/21
to Wazuh mailing list
Hello Daniel,

The guide from the link is for Elastic and the first answer with cronjob is for Wazuh/ossec alerts/logs.

Regards,
El Wali

Daniel Hinojo

unread,
Feb 22, 2021, 12:44:28 PM2/22/21
to Wazuh mailing list
Good morning Dear, I'm trying to do what they tell me according to the blog https://wazuh.com/blog/wazuh-index-management/, but I can't find the Index Lifecycle Policies path, I'm currently using Wazuh 4.0, please if you could help me

 and Another query when deleting log from / records Wazuh / ossec is also necessary to delete in the Elastic index?  

elw...@wazuh.com

unread,
Feb 23, 2021, 7:34:49 AM2/23/21
to Wazuh mailing list
Hello Daniel,

I am not sure what you are referring to by the Lifecycle Policies path. As Lifecycle policies are accessible and defined using the UI, and it will be different between Opendistro and Elastic Basic :


Opendistro :

ISM-1-create-policy.png



Elastic basic :

ILM-1-create-policy.png




The data/alerts are stored by default in Wazuh under the path `/var/ossec/logs/alerts/`  (the reason I have provided the cronjob in my first response) and in Elasticsearch in the indices; for that deleting them should be performed in each component. 

Wazuh and Elastic stack data flow :

deployment.png

You can read more about the data flow here: https://documentation.wazuh.com/current/getting-started/architecture.html#communications-and-data-flow

Hope this helps.

Regards,
Wali

Daniel Hinojo

unread,
Feb 23, 2021, 5:25:59 PM2/23/21
to Wazuh mailing list
Thank you very much it worked for me. But I have a doubt I see that there are .log files in the location / var / ossec / logs / alerts / 2021 / Jan / They weigh a lot and have not changed for more than 30 days, that .log extension should also be removed or only the .gz?  

Gene Comer

unread,
Feb 23, 2021, 5:49:08 PM2/23/21
to Wazuh mailing list

elw...@wazuh.com

unread,
Feb 24, 2021, 5:40:48 AM2/24/21
to Wazuh mailing list
Hello Daniel,

You are welcome, always glad to help.

For your question, You need to tweak the cronjob command to apply a search for `.log` files as well. It would result : 45 0 * * * find /var/ossec/logs/ -name "*.gz" -o -name "*.log"  -type f -mtime +60 -exec rm -f {} \;



Hope this helps.

Regards,
Wali

Daniel Hinojo

unread,
Feb 28, 2021, 6:05:27 PM2/28/21
to Wazuh mailing list
Thanks a lot, I could already configure it and it works very well.  
Reply all
Reply to author
Forward
0 new messages