# \_cat/nodeattrs - empty echo

**URL:** https://discuss.elastic.co/t/cat-nodeattrs-empty-echo/177225
**Category:** Elasticsearch
**Created:** [April 17, 2019, 8:09am UTC](https://discuss.elastic.co/t/cat-nodeattrs-empty-echo/177225 "2019-04-17T08:09:02Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![erde](https://avatars.discourse-cdn.com/v4/letter/e/73ab20/32.png) [@erde](https://discuss.elastic.co/u/erde)
#### Post date: [April 17, 2019, 8:09am UTC](https://discuss.elastic.co/t/cat-nodeattrs-empty-echo/177225/1 "2019-04-17T08:09:02Z")

</div>

Hello,  
ES: elasticsearch-5.5.2-1.noarch

I need to assign node id to bash variable and I expected to get it this way:

```
# curl -s -XGET 'http://ip:9200/_cat/nodeattrs'
# curl -s -XGET 'http://ip:9200/_cat/nodeattrs?v&h=name,pid,attr,value'
name pid attr value
#

```

Why does it return empty echo?  
I can get it this way:

```
# curl -s -XGET 'http://ip:9200/_cat/nodes?v&full_id=true&h=id'
id
BWNZ3xyOSYKo7CVDRGogvA
7pXQ9qfFRpWkc8GBmtHwdg
F_qcivzzSzG_GCaemMOnUA
tZi7lnw7R2S3NBq56G-ZBw
Et90JFMjRaCvjxkaX8Cnmg
69EhNIkFQoSreSbxgIC4oQ

```

but I need just one, current host node id.

---

<div class="post-metadata">

### Author: ![HenningAndersen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/henningandersen/32/48188_2.png) [@HenningAndersen](https://discuss.elastic.co/u/HenningAndersen)
#### Post date: [April 17, 2019, 3:14pm UTC](https://discuss.elastic.co/t/cat-nodeattrs-empty-echo/177225/2 "2019-04-17T15:14:23Z")

</div>

Hi @erde,

you can probably parse it out of the response for:

```auto
curl 'localhost:9200/_nodes/_local'

```

though you will need to parse the JSON output.

---

<div class="post-metadata">

### Author: ![erde](https://avatars.discourse-cdn.com/v4/letter/e/73ab20/32.png) [@erde](https://discuss.elastic.co/u/erde)
#### Post date: [April 17, 2019, 5:01pm UTC](https://discuss.elastic.co/t/cat-nodeattrs-empty-echo/177225/3 "2019-04-17T17:01:49Z")

</div>

Thank you for your answer.  
I know but I couldn't do it so I looked for another way and hoped '\_cat/nodeattrs' do it for me.  
It is not so easy to get id because it is not in 'variable: value;' format so I can not use:

`curl -s -XGET 'http://localhost:9200/_nodes/_local' | python -c "import sys, json; print json.load(sys.stdin)['nodes'][SOMETHING SHOULD BE HERE]"`

I haven't got an idea how to manage it.

---

<div class="post-metadata">

### Author: ![erde](https://avatars.discourse-cdn.com/v4/letter/e/73ab20/32.png) [@erde](https://discuss.elastic.co/u/erde)
#### Post date: [April 18, 2019, 8:00am UTC](https://discuss.elastic.co/t/cat-nodeattrs-empty-echo/177225/4 "2019-04-18T08:00:24Z")

</div>

I have managed to get node id:

```auto
curl -s -XGET "http://localhost:9200/_nodes/$(hostname -s)/stats/" | python -c "import sys, json; print json.load(sys.stdin)['nodes'].keys()"| cut -d"'" -f2

```

and the complete result of my work, host independent one-liner to get metrics:

```auto
export nodeID=`curl -s -XGET "http://localhost:9200/_nodes/$(hostname -s)/stats/" | python -c "import sys, json; print json.load(sys.stdin)['nodes'].keys()"| cut -d"'" -f2`;curl -s -XGET "http://localhost:9200/_nodes/$(hostname -s)/stats/os" | python -c "import os, sys, json; print json.load(sys.stdin)['nodes'][os.environ['nodeID']]['os']['mem']['total_in_bytes']"

```

simple! 🙂

---

<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 16, 2019, 8:00am UTC](https://discuss.elastic.co/t/cat-nodeattrs-empty-echo/177225/5 "2019-05-16T08:00:29Z")

</div>

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