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 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

  • take the pod label values as row values for the first column,
  • take the platform label values as the column names for the next columns and,
  • take the metric values as the intersection between pod and platform as depicted above.

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 :pray:

I just had to select the Time Series format on the Grafana query editor and then the Value field name is properly populated in the Transform tab – so 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.

1 Like