prometheusgrafanapromql

Table-like visualization with label values as row values and column names


I have some metrics from a Prometheus data-source like this (the real data contains many more label combinations):

status{pod = "A", platform = "X",} 1
status{pod = "C", platform = "X",} 3
status{pod = "A", platform = "Y",} 5
status{pod = "A", platform = "P",} 8
status{pod = "C", platform = "Y",} 7
status{pod = "B", platform = "Y",} 4
status{pod = "B", platform = "P",} 1

For which I need to display the info with a Grafana visualization like this:

X Y P
A 1 5 8
C 3 7
B 4 1

The labels pod and platform cannot be hard-coded into the visualization configuration but it needs to be taken from the values from the metrics.

So basically, I need to:

I tried using the Table Panel using the Labels to fields transformation but couldn’t get it working.

So, how could I achieve the described scenario? I’m open to any suggestion that could give me a similar result.

I’d be really thankful for any insights you could provide me with.

Posted originally on Grafana Community. Posted here to reach wider audience


Solution

  • I just had to select the Time Series format on the Grafana query editor and then the Value field name drop-down is properly populated in the Transform tab.

    Now I’m able to choose pod for that drop-down and the platform values are rendered as column names as expected with their respective values for each pod.