Identifying the elected master node helps validate cluster coordination during incidents, rolling restarts, and unexpected shard allocation behavior. Since cluster state updates are published by the elected master, frequent master changes often indicate an underlying stability problem that needs attention.
The Elasticsearch cluster coordination subsystem elects a master from the set of master-eligible nodes. The current elected master can be queried using the _cat/master API for a quick, human-readable view, then verified against node roles using the _cat/nodes API.
Master election can change during node restarts, network partitions, or when the cluster is under load, so results should be rechecked if the cluster appears to be flapping. Clusters with security enabled require authentication and may use HTTPS, so curl requests may need --user and --cacert adjustments.
Steps to identify the elected master node in Elasticsearch:
- Query the current elected master node.
$ curl -sS "http://localhost:9200/_cat/master?v" id host ip node -562e87MR5-DrMSv7C07Dw 192.0.2.40 192.0.2.40 node-01
Add ?format=json for machine-readable output, and add authentication when security is enabled (for example, --user user:pass).
If the request returns 503 or no rows, the cluster may not have an elected master.
- Verify the master marker and master eligibility across nodes.
$ curl -sS "http://localhost:9200/_cat/nodes?v&h=id,name,ip,node.role,master" id name ip node.role master -562 node-01 192.0.2.40 cdfhilmrstw *
The master column shows * on the elected master, and the node.role column includes m on master-eligible nodes.
- Cross-check the master node ID from cluster state.
$ curl -sS "http://localhost:9200/_cluster/state/master_node?pretty" { "cluster_name" : "search-cluster", "cluster_uuid" : "tpq9USqHRViOeqiA2eXWxQ", "master_node" : "-562e87MR5-DrMSv7C07Dw" }The master_node value should match the id shown by _cat/master.
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.
