add ilm policies to handle the life of the es indices

two policies are added to handle short and long term indices.

life of the indices can be configured using the 'elasticsearch.life'
field at browbeat-config.yml file
shortterm will have: 125 days
longterm will have 2 years

the policy and the policy based templates can be created using the
'es-template' install playbook.

Change-Id: I0f4a4a9acc03092fd582ae4ff50f688850def953
This commit is contained in:
Masco 2023-08-22 18:23:55 +05:30
parent 99512c928e
commit 00ad57c7ac
9 changed files with 8826 additions and 4394 deletions

View File

@ -23,6 +23,17 @@
ignore_errors: true
when: elastic5
- name: Upload ilm policy
uri:
url: http://{{ es_ip }}:{{es_local_port }}/_ilm/policy/{{ item | basename | regex_replace('\.json','') }}
method: PUT
body: "{{ lookup('file', item) }}"
body_format: json
with_fileglob:
- "{{ browbeat_path }}/elastic/v7ilm_policy/browbeat*"
ignore_errors: true
when: elastic7
- name: Upload templates
uri:
url: http://{{ es_ip }}:{{ es_local_port }}/_template/{{ item | basename | regex_replace('\.json','') }}

View File

@ -37,6 +37,8 @@ elasticsearch:
enabled: false
host: 1.1.1.1
port: 9200
#allowed values: shortterm, longterm
life: shortterm
regather: false
metadata_files:
- name: hardware-metadata

View File

@ -46,9 +46,10 @@ class Elastic(object):
'port': self.config['elasticsearch']['port']}],
send_get_body_as='POST'
)
life = self.config['elasticsearch']['life']
self.workload = workload
today = datetime.datetime.today()
self.index = "{}-{}-{}".format(tool, workload,
self.index = "{}-{}-{}-{}".format(tool, workload, life,
today.strftime('%Y.%m'))
def __del__(self):

View File

@ -75,6 +75,9 @@ mapping:
port:
type: int
required: True
life:
type: str
required: True
regather:
type: bool
required: True

View File

@ -0,0 +1,12 @@
{
"policy": {
"phases": {
"delete": {
"min_age": "2y",
"actions": {
"delete": {}
}
}
}
}
}

View File

@ -0,0 +1,12 @@
{
"policy": {
"phases": {
"delete": {
"min_age": "125d",
"actions": {
"delete": {}
}
}
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff