Elasticsearch: daily job for log rotation

haproxy_munin
Jérémy Lecour 6 years ago committed by Jérémy Lecour
parent bcbfcf9080
commit 4746354c54

@ -8,6 +8,7 @@ elasticsearch_custom_tmpdir: Null
elasticsearch_default_tmpdir: /var/lib/elasticsearch/tmp
elasticsearch_jvm_xms: 2g
elasticsearch_jvm_xmx: 2g
elasticsearch_log_rotate_days: 365
elasticsearch_curator: False

@ -0,0 +1,9 @@
---
- name: "log rotation script"
template:
src: rotate_elasticsearch_logs.j2
dest: /etc/cron.daily/rotate_elasticsearch_logs
owner: root
group: root
mode: "0750"

@ -10,6 +10,8 @@
- include: tmpdir.yml
- include: logs.yml
- include: plugin_head.yml
when: elasticsearch_plugin_head

@ -0,0 +1,9 @@
#!/bin/sh
# {{ ansible_managed }}
LOG_DIR=/var/log/elasticsearch
USER=elasticsearch
MAX_AGE={{ elasticsearch_log_rotate_days | mandatory }}
find ${LOG_DIR} -type f -user ${USER} -name "*.log.????-??-??" -exec gzip --best {} \;
find ${LOG_DIR} -type f -user ${USER} -name "*.log.????-??-??.gz" -mtime +${MAX_AGE} -delete
Loading…
Cancel
Save