Elasticsearch index with yellow health

Viewed 6259

I'm working on a large CPython codebase that uses Elasticsearch.

Normally, this codebase creates n indexes and n aliases, and there's a one-to-one correspondence between these indexes and aliases.

But once in a while, I instead get n indexes and n-1 aliases, and one of the indexes has a name that should've been used by an alias.

For some reason when this happens, the bogus index-that-has-what-should-be-an-alias-name has yellow status, while the other indexes are all green.

What might cause an index to be the only one that is yellow? I'm hoping understanding this might help me narrow down which part of the code I need to scrutinize to fix the bug


Edit: My elasticsearch.yml has just:

cluster.name: "docker-cluster"
network.host: 0.0.0.0
discovery.zen.ping.unicast.hosts: ["127.0.0.1", "[::1]"]

In production we may have more ES nodes, but this is just a test system - so just one ES node.

2 Answers

The status yellow indicates that replica shards of that certain index could not get allocated to other nodes.

This can happen for various reasons. For example if you have specified more replicas than you have nodes. You would need to share some more information about your cluster setup and whether you configured shard allocation by your own or not.

Elasticsearch will never assign a replica to the same node as the primary shard, so if you only have one node it is perfectly normal and expected for your cluster to indicate yellow. If you feel better about it being green, then change the number of replicas on each index to be 0.

PUT /my-index/_settings
{
    "index" : {
        "number_of_replicas" : 0
    }
}

Please read this blog https://opster.com/guides/elasticsearch/operations/elasticsearch-yellow-status/

It explains very well how to fix yellow indexes.

Related