Extract labels values from prometheus metrics

Hi @torkel,
any update on display label values inside metrics?

Maybe I am doing something wrong but I am not able to display the value of label coming from Prometheus.

For example Grafana/Singlestat panel which will display the version as text “v.9.4.0” .

nodejs_version_info{group=“axsportal”,instance=“localhost:6600”,job=“prometheus”,major=“9”,minor=“4”,patch=“0”,version=“v9.4.0”} 1

Similar labels are coming from this popular package -> prom-client


Update
After struggling for a couple of hours reading how to do it , it finally worked.
It was already explained at least a couple of times.
In my case to get it display v9.4.0 into Singlestat Panel from
nodejs_version_info{group=“axsportal”,instance=“localhost:6600”,job=“prometheus”,major=“9”,minor=“4”,patch=“0”,version=“v9.4.0”} 1

I had to go to

  1. Data sources make sure I have Scrape interval set to : 60s
  2. In my dashboard Add row -> SingleStat -> Metrics tab -> Query is : nodejs_version_info , now value displayed is 1
  3. SingleStat -> Options -> Value Stat (name)
  4. Go back to SingleStat Metrics -> Legend format {{version}} You can pick any label of the nodejs_version_info query.

Hopefully this will help someone else.

12 Likes