Index policy or Index template for Elasticsearh

I have elasticsearch cluster for storing logs, and i have indices like this

logs.2021.01.03 ...etc

so indices creates at daily basis, and i have index template for this indices

PUT _index_template/template_1
  "index_patterns": ["logs*"],
  "template": {
    "settings": {
      "number_of_shards": 6,
      "number_of_replicas": 1

but I want to make sure that indexes that are older than 1 day have 0 replicas to save disk space, and indexes that are younger than 1 day remain with 1 replica (so that in case of server loss, I have data for today)

how can i do this using elasticsearch way? i think about bash script that executes by cron , which get all of the indices which older than 1 day and make 0 replica, but i don't want to use external scripts to do that Thank you for you help

You can use ILM to do this. The allocate action should be able to alter the number of replicas.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.