Get free resources for nomad cluster or nodes

Is it possible to get free memory/CPU for the cluster or at least for all nodes through API? I can see this information in nomad node status <node-name-or-id> but I can’t in /nodes endpoint.

I can see storage data:

                'unique.storage.bytesfree': '120788234240',
                'unique.storage.bytestotal': '128837464064',

but for memory only total:

                'memory.totalbytes': '32667799552',

and reserved resources has zero values:

 'ReservedResources': {'Cpu': {'CpuShares': 0, 'ReservedCpuCores': None},
                       'Disk': {'DiskMB': 0},
                       'Memory': {'MemoryMB': 0},
                       'Networks': {'ReservedHostPorts': ''}},

You could try the v1/metrics endpoint of the API. I think could get total amount of memory, current usage, allocated memory and much more.

Let us know if this solves your use case.

1 Like

I’m already using the metrics approach, but is there really no other way? It seems that the /node endpoint has an allocated field, but it’s returning no data - all the fields have zero value"… Also, we have clusters with ~20 nodes and we need to visit EACH endpoint for EACH node.