Thank you Ben for the detailed explanation! This makes sense.
On Sunday, May 17, 2020 at 2:12:10 AM UTC-7, Ben Kochie wrote:
>
> It's about aggregation and doing math on the data.
>
> sum(node_cpu_seconds_total) makes sense, because all of the various modes
> can be added together.
>
> Say you had labels for memory:
>
> node_memory_bytes{mem_type="MemAvailable"} 1.00470784e+08
> node_memory_bytes{mem_type="MemFree"} 5.3211136e+07
> node_memory_bytes{mem_type="MemTotal"} 2.68435456e+08
>
> sum(node_memory_bytes) is nonsensical because "MemTotal" + "MemFree" +
> "MemAvailable" doesn't add up to anything useful.
>
> But, having them as separate metrics makes queries like
> "node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes" work out
>
> Think of metric names and labels as column vs rows in a spreadsheet.
> Aggregation operators like sum() avg() min() max() work vertically.
> Mathematical operators like + - / * work horizontally.
>
> On Sun, May 17, 2020 at 4:08 AM Daniel Lo Nigro <[email protected] <javascript:>>
> wrote:
>
>> I've noticed that for some metrics, Prometheus node_exporter will use one
>> metric name and separate labels. For example, CPU usage has a "mode" label:
>>
>> node_cpu_seconds_total{cpu="0",mode="idle"} 320045.23
>> node_cpu_seconds_total{cpu="0",mode="steal"} 0
>> node_cpu_seconds_total{cpu="0",mode="system"} 3703.1
>> node_cpu_seconds_total{cpu="0",mode="user"} 4713.87
>>
>> Whereas for other metrics, it uses separate metric names. For example,
>> memory usage:
>>
>> node_memory_MemAvailable_bytes 1.00470784e+08
>> node_memory_MemFree_bytes 5.3211136e+07
>> node_memory_MemTotal_bytes 2.68435456e+08
>>
>> Both are bounded (there's a fixed number of CPU modes, and a fixed number
>> of memory fields) so I'm not sure why the implementation differs between
>> the two.
>>
>> Is this intentional? If so, is there a guideline or best practice as to
>> when to do the former vs when to do the latter?
>>
>> Thanks!
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Prometheus Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/prometheus-users/8722a500-e5c9-443e-8183-6bdb76699509%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/prometheus-users/8722a500-e5c9-443e-8183-6bdb76699509%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
--
You received this message because you are subscribed to the Google Groups
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/prometheus-users/93d425ed-a8a4-446e-ab61-7b7845cfe729%40googlegroups.com.