elasticsearch : use logrotate for garbage collector logs
gitea/ansible-roles/pipeline/head This commit looks good Details

This commit is contained in:
William Hirigoyen 2023-01-02 17:27:25 +01:00
parent 8401401716
commit 48e3ced983
5 changed files with 35 additions and 2 deletions

View File

@ -23,6 +23,7 @@ The **patch** part changes is incremented if multiple releases happen the same m
* Proper jinja spacing
* evolinux-base: ensure dbus is started and enabled (not by default in the case of an offline netinst)
* elasticsearch : use logrotate for garbage collector logs instead of breaking compression cron
### Removed

View File

@ -118,6 +118,18 @@
tags:
- config
- name: Garbage collector logs rotation by the JVM is disabled
lineinfile:
dest: /etc/elasticsearch/jvm.options.d/evolinux.options
regexp: "^-Xlog:gc"
line: "-Xlog:gc*,gc+age=trace,safepoint:file=/var/log/elasticsearch/gc.log:utctime,pid,tags:filecount=0"
create: yes
owner: root
group: elasticsearch
mode: "0640"
tags:
- config
- name: Configure cluster members
lineinfile:
dest: /etc/elasticsearch/elasticsearch.yml

View File

@ -17,3 +17,12 @@
group: root
mode: "0750"
when: is_cron_installed.rc == 0
- name: "Setup logrotate for JVM garbage collector"
template:
src: logrotate.j2
dest: /etc/logrotate/elasticsearch
owner: root
group: root
mode: "0750"
when: is_cron_installed.rc == 0

View File

@ -0,0 +1,12 @@
/var/log/elasticsearch/gc.log {
su elasticsearch elasticsearch
daily
rotate {{ elasticsearch_log_rotate_days }}
compress
nodelaycompress
missingok
copytruncate
dateext
dateformat .%Y-%m-%d
}

View File

@ -8,7 +8,6 @@ MAX_AGE={{ elasticsearch_log_rotate_days | mandatory }}
# Compress logs
find ${LOG_DIR} -type f -user ${USER} -name "*.log.????-??-??" -exec gzip --best {} \;
find ${LOG_DIR} -type f -user ${USER} -name "*-????-??-??.log" -exec gzip --best {} \;
find ${LOG_DIR} -type f -user ${USER} -name "*.log.??" -not -name "*.gz" -exec gzip --best {} \;
# Delete old logs
find ${LOG_DIR} -type f -user ${USER} -name "*gz" -ctime +${MAX_AGE} -delete
find ${LOG_DIR} -type f -user ${USER} -name "*gz" -ctime +${MAX_AGE} -delete