Adtt logrotate meta configuration for Elasticsearch
- parametrize interval and rotate
Related: PROD-29848
Change-Id: I44557fe76f53b48802e4f5b3ac08273142ec33af
diff --git a/elasticsearch/meta/logrotate.yml b/elasticsearch/meta/logrotate.yml
new file mode 100644
index 0000000..c57e792
--- /dev/null
+++ b/elasticsearch/meta/logrotate.yml
@@ -0,0 +1,26 @@
+## Default: Daily rotation with 28 rotations kept
+{%- from "elasticsearch/map.jinja" import server, client with context %}
+
+{%- if server.get('enabled', False) %}
+ {%- set log_interval = server.get('logrotate', {}).get('interval', 'daily') %}
+ {%- set log_rotation = server.get('logrotate', {}).get('rotate', 28) %}
+{%- elif client.get('enabled', False) %}
+ {%- set log_interval = client.get('logrotate', {}).get('interval', 'daily') %}
+ {%- set log_rotation = client.get('logrotate', {}).get('rotate', 28) %}
+{%- endif %}
+
+{%- if server.get('enabled', False) or client.get('enabled', False) %}
+job:
+ elasticsearch:
+ - files:
+ - /var/log/elasticsearch/*.log
+ options:
+ - {{ log_interval }}
+ - rotate: {{ log_rotation }}
+ - copytruncate
+ - compress
+ - delaycompress
+ - missingok
+ - notifempty
+ - create 664 elasticsearch elasticsearch
+{%- endif %}