# Node roles in Elasticsearch 2.x

**URL:** https://discuss.elastic.co/t/node-roles-in-elasticsearch-2-x/82861
**Category:** Elasticsearch
**Created:** [April 19, 2017, 10:15am UTC](https://discuss.elastic.co/t/node-roles-in-elasticsearch-2-x/82861 "2017-04-19T10:15:37Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![joschi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joschi/32/44946_2.png) [@joschi](https://discuss.elastic.co/u/joschi)
#### Post date: [April 19, 2017, 10:15am UTC](https://discuss.elastic.co/t/node-roles-in-elasticsearch-2-x/82861/1 "2017-04-19T10:15:37Z")

</div>

What's a reliable way to retrieve the roles of an Elasticsearch node (master, data, client) with Elasticsearch 2.x?

It seems that the `attributes` field in the [Nodes Info API](https://www.elastic.co/guide/en/elasticsearch/reference/2.4/cluster-nodes-info.html) isn't available all the time:

```auto
$ curl http://127.0.0.1:9200/?pretty
{
  "name" : "King Bedlam",
  "cluster_name" : "elasticsearch",
  "version" : {
    "number" : "2.4.0",
    "build_hash" : "ce9f0c7394dee074091dd1bc4e9469251181fc55",
    "build_timestamp" : "2016-08-29T09:14:17Z",
    "build_snapshot" : false,
    "lucene_version" : "5.5.2"
  },
  "tagline" : "You Know, for Search"
}

```

```auto
$ curl -s http://127.0.0.1:9200/_nodes?pretty | jq '.nodes | .[] | [.attributes]'
[
  {
    "client": "true",
    "data": "false",
    "master": "false"
  }
]
[
  null
]

```

The full output of the Nodes Info API is as follows (slightly shortened to fit the character limits):

```auto
$ curl -s http://127.0.0.1:9200/_nodes?pretty
{
  "cluster_name" : "elasticsearch",
  "nodes" : {
    "DeehriT-TxqB_DeZBnuNMA" : {
      "name" : "custom-client-node",
      "transport_address" : "127.0.0.1:9350",
      "host" : "127.0.0.1",
      "ip" : "127.0.0.1",
      "version" : "2.4.4",
      "build" : "fcbb46d",
      "http_address" : "127.0.0.1:9201",
      "attributes" : {
        "client" : "true",
        "data" : "false",
        "master" : "false"
      },
      "settings" : {
        "cluster" : {
          "name" : "elasticsearch"
        },
        "node" : {
          "name" : "custom-client-node",
          "client" : "true",
          "data" : "false",
          "master" : "false"
        },
        "path" : {
          "data" : "data/elasticsearch",
          "logs" : "data/elasticsearch/logs",
          "home" : "data/elasticsearch"
        },
        "discovery" : {
          "zen" : {
            "ping" : {
              "unicast" : {
                "hosts" : ["127.0.0.1:9300"]
              }
            }
          },
          "initial_state_timeout" : "3s"
        },
        "name" : "custom-client-node",
        "action" : {
          "auto_create_index" : "false"
        },
        "client" : {
          "type" : "node"
        },
        "http" : {
          "enabled" : "true"
        },
        "transport" : {
          "tcp" : {
            "port" : "9350"
          }
        }
      },
      "os" : {
        "refresh_interval_in_millis" : 1000,
        "name" : "Mac OS X",
        "arch" : "x86_64",
        "version" : "10.12.4",
        "available_processors" : 8,
        "allocated_processors" : 8
      },
      "process" : {
        "refresh_interval_in_millis" : 1000,
        "id" : 20772,
        "mlockall" : false
      },
      "jvm" : {
        "pid" : 20772,
        "version" : "1.8.0_121",
        "vm_name" : "Java HotSpot(TM) 64-Bit Server VM",
        "vm_version" : "25.121-b13",
        "vm_vendor" : "Oracle Corporation",
        "start_time_in_millis" : 1492595873725,
        "mem" : {
          "heap_init_in_bytes" : 268435456,
          "heap_max_in_bytes" : 3817865216,
          "non_heap_init_in_bytes" : 2555904,
          "non_heap_max_in_bytes" : 0,
          "direct_max_in_bytes" : 3817865216
        },
        "gc_collectors" : ["PS Scavenge", "PS MarkSweep"],
        "memory_pools" : ["Code Cache", "Metaspace", "Compressed Class Space", "PS Eden Space", "PS Survivor Space", "PS Old Gen"],
        "using_compressed_ordinary_object_pointers" : "true"
      },
      "thread_pool" : { … },
      "transport" : {
        "bound_address" : ["127.0.0.1:9350"],
        "publish_address" : "127.0.0.1:9350",
        "profiles" : { }
      },
      "http" : {
        "bound_address" : ["127.0.0.1:9201"],
        "publish_address" : "127.0.0.1:9201",
        "max_content_length_in_bytes" : 104857600
      },
      "plugins" : [],
      "modules" : []
    },
    "0P3xXxKKSF6rKryL6pdM6Q" : {
      "name" : "King Bedlam",
      "transport_address" : "127.0.0.1:9300",
      "host" : "127.0.0.1",
      "ip" : "127.0.0.1",
      "version" : "2.4.0",
      "build" : "ce9f0c7",
      "http_address" : "127.0.0.1:9200",
      "settings" : {
        "name" : "King Bedlam",
        "client" : {
          "type" : "node"
        },
        "cluster" : {
          "name" : "elasticsearch"
        },
        "path" : {
          "logs" : "elasticsearch-2.4.0/logs",
          "home" : "elasticsearch-2.4.0"
        },
        "config" : {
          "ignore_system_properties" : "true"
        },
        "network" : {
          "host" : "127.0.0.1"
        }
      },
      "os" : {
        "refresh_interval_in_millis" : 1000,
        "name" : "Mac OS X",
        "arch" : "x86_64",
        "version" : "10.12.4",
        "available_processors" : 8,
        "allocated_processors" : 8
      },
      "process" : {
        "refresh_interval_in_millis" : 1000,
        "id" : 20651,
        "mlockall" : false
      },
      "jvm" : {
        "pid" : 20651,
        "version" : "1.8.0_121",
        "vm_name" : "Java HotSpot(TM) 64-Bit Server VM",
        "vm_version" : "25.121-b13",
        "vm_vendor" : "Oracle Corporation",
        "start_time_in_millis" : 1492594873945,
        "mem" : {
          "heap_init_in_bytes" : 268435456,
          "heap_max_in_bytes" : 1037959168,
          "non_heap_init_in_bytes" : 2555904,
          "non_heap_max_in_bytes" : 0,
          "direct_max_in_bytes" : 1037959168
        },
        "gc_collectors" : ["ParNew", "ConcurrentMarkSweep"],
        "memory_pools" : ["Code Cache", "Metaspace", "Compressed Class Space", "Par Eden Space", "Par Survivor Space", "CMS Old Gen"],
        "using_compressed_ordinary_object_pointers" : "true"
      },
      "thread_pool" : { … }
      "transport" : {
        "bound_address" : ["127.0.0.1:9300"],
        "publish_address" : "127.0.0.1:9300",
        "profiles" : { }
      },
      "http" : {
        "bound_address" : ["127.0.0.1:9200"],
        "publish_address" : "127.0.0.1:9200",
        "max_content_length_in_bytes" : 104857600
      },
      "plugins" : [],
      "modules" : []
    }
  }
}

```

---

<div class="post-metadata">

### Author: ![joschi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joschi/32/44946_2.png) [@joschi](https://discuss.elastic.co/u/joschi)
#### Post date: [April 19, 2017, 10:33am UTC](https://discuss.elastic.co/t/node-roles-in-elasticsearch-2-x/82861/2 "2017-04-19T10:33:20Z")

</div>

@warkolm kindly pointed me at the [cat nodes API](https://www.elastic.co/guide/en/elasticsearch/reference/2.4/cat-nodes.html) which contains the required information:

```auto
$ curl -s 'http://127.0.0.1:9200/_cat/nodes?h=n,r'
custom-client-node c
King Bedlam d

```

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [May 17, 2017, 10:41am UTC](https://discuss.elastic.co/t/node-roles-in-elasticsearch-2-x/82861/3 "2017-05-17T10:41:32Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
