Prometheus output reports disk usage differently than Netdata

Hi all,

I’m using netdata 1.29.3 on a CentOS 7.3 host.

I’ve noticed that the prometheus output for my disk usage is vastly different from what is reported via the Netdata UI (additionally the prometheus metrics are incorrect).

For example, prometheus output for the / file system shows:
netdata_disk_space{chart=“disk_space.“,family=”/",dimension=“avail”} 657024 1617655142914
netdata_disk_space{chart="disk_space.
”,family=“/”,dimension=“used”} 2245180 1617655142914

But netdata UI shows (attached image):
Screen Shot 2021-04-05 at 14.52.09

My prometheus export config is:
[prometheus:exporter]
data source = as collected
send names instead of ids = yes
send configured labels = yes
send automatic labels = no
send charts matching = *
send hosts matching = localhost *
prefix = netdata

I’m not sure what could be causing the difference. This is the case for every node I’ve double checked on so far.

Hi @mjtice :wave:

This is tricky, indeed!

Let’s see. This is Disk Space Usage chart source code

m->rd_space_avail    = rrddim_add(m->st_space, "avail", NULL, (collected_number)bsize, 1024 * 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
m->rd_space_used     = rrddim_add(m->st_space, "used", NULL, (collected_number)bsize, 1024 * 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
m->rd_space_reserved = rrddim_add(m->st_space, "reserved_for_root", "reserved for root", (collected_number)bsize, 1024 * 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
  • (collected_number)bsize is multiplier (an integer value to multiply the collected value)
  • 1024 * 1024 * 1024 is divisor (an integer value to divide the collected value)

data source = as collected means return the values as is, so you get the raw values - number of blocks.

To convert it to Gigabytes you need: value * multiplier / divisor

# avail
>>> 657024.0 * 4096 / 1024 / 1024 / 1024
2.50634765625

# used
>>> 2245180.0 * 4096 / 1024 / 1024 / 1024
8.564682006835938

Related issue Diskspace Usage full while it is not · Issue #1255 · netdata/netdata · GitHub

1 Like

Ah, very interesting. Thanks @ilyam8 !