How can I extract a value from a label=value returned in a query response?

I’m attempting to build a table (or something similar) showing the switch hostname and the system boot time. Trying to (ab)use a stat panel for this.

My query used for a stat panel response:

time()*1000 - sysUpTime{job=~"snmp_cisco_mib",instance=~"${instance:pipe}"}*10

Which expands into an promql query of:


That promql query will come back with something like:

sysUpTime{hostname="switch01", instance="", job="snmp_cisco_mib"}
sysUpTime{hostname="switch02", instance="", job="snmp_cisco_mib"}

The table headers I get back are the calculated bootup time and the query:

{hostname="switch02", instance="", job="snmp_cisco_mib"}
2022-06-27 16:47:25
{hostname="switch01", instance="", job="snmp_cisco_mib"}
2023-04-23 06:50:31

It’s showing the boot time correctly, but I’d like to only show the hostname. In the query inspector I can drill down to a “labels” object that has the key/value pairs shown in the bracketed response. I’m just not sure how to muck around with those to only show what I want. Or, maybe I just need to ask only the hostname in the query with some sort of filter.

Not sure where to go from here. Please help!

Running 9.2.1

That’s simple PromQL task - group by hostname label, e.g.

avg by (hostname) (time()*1000 - sysUpTime{job=~"snmp_cisco_mib",instance=~"${instance:pipe}"}*10)

Of course on the Grafana side use query Format: Table and Table panel type.