2 values in custom text string in Stat Panel?

I’m using Grafana 9.5.2 on Ubuntu 22.04 (in Docker), and I’m using Prometheus as a data source.

I have 2 Prometheus queries that I would like to combine into a custom text string in a Stat Panel (or another panel that supports this if possible).

The queries are:

A) count(count(node_cpu_seconds_total{instance=~"$node",job="$job"}) by (cpu)). This gives the number of CPU cores. In this example, let’s set the value to 4.

B) avg(node_cpu_scaling_frequency_hertz{instance=~"$node",job="$job"} / 1000000000): This gives the current average CPU frequency across cores in GHz. In this example, let’s set the value to 1.50

I would like to combine these values into a custom text string with the following format:

<number of cores> @ <average frequency> GHz

So in this example the resulting text inside the panel would be:

4 @ 1.50 GHz

A simple Stat Panel would be very fine for this, but I can’t see any Transform action in Grafana that allows me to create a custom string like this.

I’m not sure where to start, as I’m not very well versed in advanced Grafana setup or advanved PromQL queries.

Can anyone help to provide guidance, or maybe even a working example? It may also be possible that a third-party plugin panel is required for this type of display - if that’s the case please let me know.

Thanks.

@ameinild I can’t find any transformations which allowed me to do that as well.

Take a look at the Dynamic Text panel:

Hmm, yeah that could be an option - will look further into this.

1 Like

I went for the simple solution so far, and made 2 different panels besides each other.

Grafana_CPU_cores

1 Like