Browse Source

logstash: daily job for log rotation

haproxy_munin
Jérémy Lecour 4 years ago
committed by Jérémy Lecour
parent
commit
888336e6fe
  1. 1
      logstash/defaults/main.yml
  2. 9
      logstash/tasks/logs.yml
  3. 2
      logstash/tasks/main.yml
  4. 9
      logstash/templates/rotate_logstash_logs.j2

1
logstash/defaults/main.yml

@ -1,3 +1,4 @@
---
logstash_jvm_xms: 256m
logstash_jvm_xmx: 1g
logstash_log_rotate_days: 365

9
logstash/tasks/logs.yml

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

2
logstash/tasks/main.yml

@ -70,3 +70,5 @@
- debug:
var: logstash_template
verbosity: 1
- include: logs.yml

9
logstash/templates/rotate_logstash_logs.j2

@ -0,0 +1,9 @@
#!/bin/sh
# {{ ansible_managed }}
LOG_DIR=/var/log/logstash
MAX_AGE={{ logstash_log_rotate_days | mandatory }}
find ${LOG_DIR} -type f -user logstash -name "logstash.log.*.gz" -mtime +${MAX_AGE} -delete
find ${LOG_DIR} -type f -user root -name "logstash.err.*.gz" -mtime +${MAX_AGE} -delete
find ${LOG_DIR} -type f -user root -name "logstash.stdout.*.gz" -mtime +${MAX_AGE} -delete
Loading…
Cancel
Save