Skip to content

Instantly share code, notes, and snippets.

@apr-1985
Created November 1, 2021 08:57
Show Gist options
  • Select an option

  • Save apr-1985/5e6aed7727ec9f212eca62d3f80fa437 to your computer and use it in GitHub Desktop.

Select an option

Save apr-1985/5e6aed7727ec9f212eca62d3f80fa437 to your computer and use it in GitHub Desktop.
Adding an ISM to Elasticsearch

Adding an ISM to Elasticsearch

Add an ISM to All Elasticsearch index matching selected index patterns (* to match all patterns). ISM sets number of replicas to 0 after 7 days and then deletes the index after 14.

curl -XPUT 'https://<YOUR_URL>/_template/14_day_delete' -H 'Content-Type: application/json' -d '{"index_patterns": ["artifactory-*", "github-*", "lambda-*"], "settings": {"opendistro.index_state_management.policy_id": "delete_after_14d"}}'
{
"policy": {
"policy_id": "delete_after_14d",
"description": "Changes replica count and deletes.",
"last_updated_time": 1614070452118,
"schema_version": 1,
"error_notification": null,
"default_state": "current",
"states": [
{
"name": "current",
"actions": [],
"transitions": [
{
"state_name": "old",
"conditions": {
"min_index_age": "7d"
}
}
]
},
{
"name": "old",
"actions": [
{
"replica_count": {
"number_of_replicas": 0
}
}
],
"transitions": [
{
"state_name": "delete",
"conditions": {
"min_index_age": "14d"
}
}
]
},
{
"name": "delete",
"actions": [
{
"delete": {}
}
],
"transitions": []
}
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment