# How to Query to get the jvm heap usage for each node(from \_node/stats)

**URL:** <https://discuss.elastic.co/t/how-to-query-to-get-the-jvm-heap-usage-for-each-node-from--node-stats/76150>\
**Category:** Elasticsearch\
**Created:** [February 23, 2017, 5:42am UTC](https://discuss.elastic.co/t/how-to-query-to-get-the-jvm-heap-usage-for-each-node-from--node-stats/76150 "2017-02-23T05:42:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nethis](https://avatars.discourse-cdn.com/v4/letter/n/d2c977/32.png) [@nethis](https://discuss.elastic.co/u/nethis)\
**Post date:** [February 23, 2017, 5:42am UTC](https://discuss.elastic.co/t/how-to-query-to-get-the-jvm-heap-usage-for-each-node-from--node-stats/76150/1 "2017-02-23T05:42:00Z")

</div>

Hi There,

Is there a way to query the node and their jvm heap usage only from \_node/stats . So, I am looking for one of the formats below

```
node heap_used_in_bytes heap_used_percent heap_committed_in_bytes

node1 185680048 5 3632857088 

```

or

```
node1:
{"heap_used_in_bytes": 185680048,
          "heap_used_percent": 5,
          "heap_committed_in_bytes": 3632857088,
          "heap_max_in_bytes": 3632857088,
          "non_heap_used_in_bytes": 62888168,
          "non_heap_committed_in_bytes": 64159744},
node2:
{"heap_used_in_bytes": 185680048,
          "heap_used_percent": 5,
          "heap_committed_in_bytes": 3632857088,
          "heap_max_in_bytes": 3632857088,
          "non_heap_used_in_bytes": 62888168,
          "non_heap_committed_in_bytes": 64159744}
```

---

<div class="post-metadata">

**Author:** ![jkuang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jkuang/32/72637_2.png) [@jkuang](https://discuss.elastic.co/u/jkuang)\
**Post date:** [February 24, 2017, 11:06pm UTC](https://discuss.elastic.co/t/how-to-query-to-get-the-jvm-heap-usage-for-each-node-from--node-stats/76150/2 "2017-02-24T23:06:58Z")

</div>

You can use the workaround below:

curl -XGET '[http://localhost:9200/\_nodes/jvm?pretty](http://localhost:9200/_nodes/jvm?pretty)' | grep -i 'node|heap'

---

<div class="post-metadata">

**Author:** ![nethis](https://avatars.discourse-cdn.com/v4/letter/n/d2c977/32.png) [@nethis](https://discuss.elastic.co/u/nethis)\
**Post date:** [March 1, 2017, 11:15am UTC](https://discuss.elastic.co/t/how-to-query-to-get-the-jvm-heap-usage-for-each-node-from--node-stats/76150/3 "2017-03-01T11:15:53Z")

</div>

@jkuang I am getting the output as below. Its getting additional details as well. I just need the required format mentioned above . am I missing anything here? I used

`_nodes/jvm?pretty | grep -i 'node\|heap'`

```
{
  "cluster_name": "ittesprod",
  "nodes": {
    "G-vSfTFnSDWJD4yGIDJo4g": {
      "name": "ITTESPROD-MSTR2",
      "transport_address": "10.158.36.202:9300",
      "host": "10.158.36.202",
      "ip": "10.158.36.202",
      "version": "2.4.0",
      "build": "ce9f0c7",
      "http_address": "10.158.36.202:9200",
      "attributes": {
        "data": "false",
        "master": "true"
      },
      "jvm": {
        "pid": 10768,
        "version": "1.8.0_102",
        "vm_name": "Java HotSpot(TM) 64-Bit Server VM",
        "vm_version": "25.102-b14",
        "vm_vendor": "Oracle Corporation",
        "start_time_in_millis": 1487309091680,
        "mem": {
          "heap_init_in_bytes": 3758096384,
          "heap_max_in_bytes": 3632857088,
          "non_heap_init_in_bytes": 2555904,
          "non_heap_max_in_bytes": 0,
          "direct_max_in_bytes": 3632857088
        },
        "gc_collectors": [
          "ParNew",
          "MarkSweepCompact"
        ],
        "memory_pools": [
          "Code Cache",
          "Metaspace",
          "Compressed Class Space",
          "Par Eden Space",
          "Par Survivor Space",
          "Tenured Gen"
        ],
        "using_compressed_ordinary_object_pointers": "true"
      }
    },
    "3XJ7xxTIRR2VxJ9NAwb-ng": {
      "name": "ITTESPROD-DATA3",
      "transport_address": "10.158.36.204:9300",
      "host": "10.158.36.204",
      "ip": "10.158.36.204",
      "version": "2.4.0",
      "build": "ce9f0c7",
      "attributes": {
        "master": "false"
      },
      "jvm": {
        "pid": 5428,
        "version": "1.8.0_102",
        "vm_name": "Java HotSpot(TM) 64-Bit Server VM",
        "vm_version": "25.102-b14",
        "vm_vendor": "Oracle Corporation",
        "start_time_in_millis": 1487346872518,
        "mem": {
          "heap_init_in_bytes": 30064771072,
          "heap_max_in_bytes": 29062660096,
          "non_heap_init_in_bytes": 2555904,
          "non_heap_max_in_bytes": 0,
          "direct_max_in_bytes": 29062660096
        },
        "gc_collectors": [
          "ParNew",
          "MarkSweepCompact"
        ],
        "memory_pools": [
          "Code Cache",
          "Metaspace",
          "Compressed Class Space",
          "Par Eden Space",
          "Par Survivor Space",
          "Tenured Gen"
        ],
        "using_compressed_ordinary_object_pointers": "true"
      }
```

---

<div class="post-metadata">

**Author:** ![jkuang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jkuang/32/72637_2.png) [@jkuang](https://discuss.elastic.co/u/jkuang)\
**Post date:** [March 1, 2017, 9:10pm UTC](https://discuss.elastic.co/t/how-to-query-to-get-the-jvm-heap-usage-for-each-node-from--node-stats/76150/4 "2017-03-01T21:10:33Z")

</div>

I"m not sure why you're getting so many variables when using "grep". The grep should only output variables label as node and heap like mine below:

```auto
curl -XGET 'http://localhost:9200/_nodes/jvm?pretty' | grep -i 'node\|heap'
  % Total % Received % Xferd Average Speed Time Time Time Current
                                 Dload Upload Total Spent Left Speed
100 1307 100 1307 0 0 186k 0 --:--:-- --:--:-- --:--:-- 212k
  "_nodes" : {
  "nodes" : {
          "heap_init_in_bytes" : 2147483648,
          "heap_max_in_bytes" : 2077753344,
          "non_heap_init_in_bytes" : 2555904,
          "non_heap_max_in_bytes" : 0,

```

What OS are you using?

---

<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:** [March 29, 2017, 9:10pm UTC](https://discuss.elastic.co/t/how-to-query-to-get-the-jvm-heap-usage-for-each-node-from--node-stats/76150/5 "2017-03-29T21:10:54Z")

</div>

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