Value being displayed inside the Legend as a Label

Hello,

I do have quite a Problem and im new to Grafana and still learning.

i use prometheus/snmp_exporter as a data source.
When i query the oid for extremePortUtilization30secs then i get the value i want to display as a “label” inside the legend.

Is there any way to display this as a value?
I want extremeCpuMonitorSystemUtilization30secs as a Value. but its displaying 1 as value.

Hi, is this your metric, or someone provides you with such a metric? By default, value of the metric should not be passed into a label - it can create lots of series and boom your prometheus (on top of your problems with querying the data). Check out this stack overflow thread maybe you’ll find something satisfactionatory there.

AFAIK pure prometheus doesn’t have something like “get value from label”. VictoriaMetrics has such a function, but it would require chaning the datasource and infrastructure, so I don’t think it’s worth it.

snmp_exporter gets the data from a switch and forwards the data to prometheus and prometheus to grafana…
So its not possible?
I will search the Thread for further help thank you.

Depends on what you want. As you’ll see in the thread, people are showing the value as label in stat panel.

yes i managed to reproduce that. it would work but then i noticed i need 2 labels shown as “value”. with other words it works like that but i need another label shown. right now it says “0.8” and i need the switch processname shown above that '“0.8”

I don’t think it’s possible to display the value like that (from Prometheus). Best you could do is to create a legend {{extremeCPUMonitorSystemUtilization30Sec}} - {{ < the second label > }} and hereby having the description next to each other but I doubt that’s what you want.

I also found this thread, where they say you could theoretically rewrite the label into value using prometheus relabel config but I don’t know if that’s possible to do.

Now that I think about it you could also try to play around with some transformations to get around that. I think Convert field type to convert the extremeCpuMonitor... label to a number and then (theoretically) you could display it as a value :thinking:

Edit:
By PromQL alone I still don’t think that’s possible. But if you want a Gauge visualization, you can do the following:

  1. Leave your query as it is for now
  2. Go into Transform tab (right next to the query one) and there you’ll have to create three transformations (see the screenshot attached):
    2.1 Reduce that will create a single number out of your time series. Make sure the option Labels to fields is toggled.
    2.2 Convert field type that will change the type of your label extremeCpuMonitorSystemUtilization30secs to Number.
    2.3 Organize fields where you “delete” the original value of the metric (1) from the view.
  3. In your Gauge visualization options change Value Options => Show to All values.

image

Will something like that work?