38 cards
Posted about 1 year ago. Visible to the public.

Elasticsearch unassigned replica shards on single node instances

get the unassigned shards

curl -s -XGET 'localhost:9200/_cat/shards?pretty' | grep UNASSIGNED

If it's a replica (r in the column befor the UNASSIGNED) and you are on a single node elasticsearch you need to disable replicas

get templates with patterns and search which template will be used for the unassigned shard

curl -XGET 'localhost:9200/_template?pretty' | jq 'to_entries[] | { key, index_pattern: .value.index_patterns}'

how to change template configuration

Overwritte the template settings:

curl -XPUT 'localhost:9200/_template/footemplate?pretty' -H 'Content-Type: application/json' -d'{ "index_patterns": [ "foobar.*(" ], "settings": { "index": { "number_of_shards": 1, "number_of_replicas": 0 } } }'


Now you have fixed the issue for future indices matching the index_pattern of the edited template. But you need to remove the unassigend replica shards already there. Use the index names returned by the first HTTP request and disable replicas for the indices:

curl -XPUT 'localhost:9200/$INDEXNAME/_settings?pretty' -H 'Content-Type: application/json' -d'{ "index": { "number_of_replicas": 0 } }'

xpack monitoring index template

If the troubeling template is the xpack monitoring template .monitoring-es or any other monitoring template automaticall created (for e.g. .monitoring-kibana) you can't change the settings because xpack will overwrite them. You need to create a separate template which will be applied after the first one: Configuring Indices for Monitoring

Owner of this card:

Claus-Theodor Riegg
Last edit:
8 months ago
by Claus-Theodor Riegg
This website uses cookies to improve usability and analyze traffic.
Accept or learn more