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:
sysUpTime{job=~"snmp_cisco_mib",instance=~"192.168.100.10|192.168.100.12"}
That promql query will come back with something like:
sysUpTime{hostname="switch01", instance="192.168.100.10", job="snmp_cisco_mib"}
2789106640
sysUpTime{hostname="switch02", instance="192.168.100.12", job="snmp_cisco_mib"}
200688039
The table headers I get back are the calculated bootup time and the query:
{hostname="switch02", instance="192.168.100.12", job="snmp_cisco_mib"}
2022-06-27 16:47:25
{hostname="switch01", instance="192.168.100.10", 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