Friday, 20 October 2023

Elastic search list all the nodes in a cluster

There are two ways to list all the nodes in an Elasticsearch cluster:

  1. Using the _cat/nodes API:

This API is intended for human consumption using the command line or Kibana console. To use it, you can run the following command:

curl -XGET 'http://localhost:9200/_cat/nodes'

This will return a list of all the nodes in the cluster, along with information such as their IP address, role, and status.

  1. Using the nodes info API:

This API is intended for application consumption. To use it, you can run the following command:

curl -XGET 'http://localhost:9200/_nodes/info'

This will return a more detailed list of all the nodes in the cluster, including information such as their configuration, JVM information, and operating system information.

You can also use the nodes info API to list specific nodes in the cluster by passing their IDs to the API. For example, to list the nodes with the IDs node-1 and node-2, you can run the following command:

curl -XGET 'http://localhost:9200/_nodes/info/node-1,node-2'

Whichever method you choose, you can use the output of the API to get a better understanding of the nodes in your Elasticsearch cluster. This information can be useful for troubleshooting problems, monitoring performance, and scaling your cluster.

No comments:

Post a Comment