Getting cluster node information via the API

The earlier recipes allow us to return information to a cluster level; ElasticSearch provides calls to gather information at a node level.

Getting ready

You need a working ElasticSearch cluster.

How to do it...

To get information on nodes, we will perform the following steps:

  1. To retrieve node information, the HTTP method is GET and the curl command is:
    curl -XGET 'http://localhost:9200/_nodes?all=true'
    curl -XGET 'http://localhost:9200/_nodes/<nodeId1>,<nodeId2>?all=true'
    
  2. The result will be as follows:
    { "cluster_name" : "es-cookbook", "nodes" : { "R3Gwu0a6Q9GTHPQ6cg95ZA" : { "name" : "Man-Ape", "transport_address" : "inet[/192.168.1.13:9300]", "host" : "Albertos-MacBook-Pro-2.local", "ip" : "192.168.1.13", ...

Get ElasticSearch Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.