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

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}

You can use the workaround below:

curl -XGET 'http://localhost:9200/_nodes/jvm?pretty' | grep -i 'node|heap'

1 Like

@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"
      }

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:

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?

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