Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prometheus reports a different value for node_memory_Active_bytes and free -b

I'm quite new to Prometheus, so this is possibly a silly question - but here goes.

When I request node_memory_Active_bytes and node_memory_MemTotal_bytes I get:

node_memory_Active_bytes{instance="10.1.4.9:9100",job="node-exporter"}  3257815040

(..and..)

node_memory_MemTotal_bytes{instance="10.1.4.9:9100",job="node-exporter"}    16509550592

However, on the box, if I run free -b, I get the following:

$ free -b
              total        used        free      shared  buff/cache   available
Mem:    16509550592  2264915968  6787731456    59121664  7456903168 14140530688
Swap:             0           0           0

I'm struggling to maps prometheus's view of memory with the actual machine's view. I'm sure I must be doing something wrong, but I have no idea what. The total's match, but the free

like image 856
Matthew Haworth Avatar asked Mar 19 '26 04:03

Matthew Haworth


2 Answers

Equivalent queries for free -b command:

  • total: node_memory_MemTotal_bytes
  • used: node_memory_MemTotal_bytes - node_memory_MemFree_bytes - node_memory_Buffers_bytes - node_memory_Cached_bytes - node_memory_SReclaimable_bytes
  • shared: node_memory_Shmem_bytes
  • free: node_memory_MemFree_bytes
  • buff/cache: node_memory_Buffers_bytes + node_memory_Cached_bytes + node_memory_SReclaimable_bytes
  • available: node_memory_MemAvailable_bytes
like image 137
Naser Mirzaei Avatar answered Mar 24 '26 08:03

Naser Mirzaei


I think you're confusing "active" memory with "used" memory, aren't you? They're different things.

See more info about this here.

To get "used" memory with Prometheus Node Exporter calculate:

node_memory_MemTotal_bytes - node_memory_MemAvailable_bytes
like image 30
Marcelo Ávila de Oliveira Avatar answered Mar 24 '26 07:03

Marcelo Ávila de Oliveira



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!