-
What Grafana version and what operating system are you using?
13
-
What are you trying to achieve?
Instead of having two queries, wondering if it’s possible to put these two metric names into a custom variable to have Grafana create the two queries. Doesn’t seem to work.
irate({"$IO", site=~"$Site", job="snmp_mx", ifDescr=~"$Interface"}[5m]) * 8
or
irate({name=~"$IO", site=~"$Site", job="snmp_mx", ifDescr=~"$Interface"}[5m]) * 8
Related to the metric names, once a metric name (ifHCInOctets) calculate with the rate() function, that metric name is gone, and label __name__ doesn’t bring it up when trying to use in as a legend label and having to manually type it out.
-
How are you trying to achieve it?
legendFormat:“{{_name_}}”
Trying that gives back the same literal value of {{_name_}} and not ifHCInOctets, for example
I am able to get the end result, but there’s a lot of typing and perhaps there’s a better way. Thanks for reading if you got here 
If you’re using a Prometheus-compatible datasource, you can do this with the __name__ label.
Create a Custom variable named IO with values:
ifHCInOctets,ifHCOutOctets
Enable Multi-value, then use:
irate({__name__=~"$IO", site=~"$Site", job="snmp_mx", ifDescr=~"$Interface"}[5m]) * 8
That allows a single query to match whichever metric(s) are selected in $IO, instead of maintaining two separate queries.
Regarding the legend question, rate()/irate() intentionally remove the __name__ label, so {{__name__}} won’t work after those functions.
Thanks SA for taking your time to suggest.
So yes, I can certainly follow you directions easily, but the effect is a either/or, but not both at the same time, which was hoping would simplify down to one query for TX/RX. Oh well.
On capturing the metric name (ifHCInOctets) after being used in the rate() function, I agree with you about how that’s how it works. Although since it’s no longer available, then are we to manually creating legend labels? I wonder…
I do see the docs on Manage library panels and perhaps that might be the way forwards.