'Extract specific label value in Prometheus and set this as query result value
I have a query which return resultant value in Prometheus output query and in value it return 1. I tried to google a bit but unfortunately didn't succeed in getting the required answer.
My use case is as below.
I executed following query => hrMemorySize{job="snmp-moxa"} in prometheus query browser
it give me following result ->
Element
hrMemorySize{hrMemorySize="125072",instance="1.1.1.1",job="snmp-moxa"}
value 1
my requirement is to get this hrMemorySize in value or is there any way I can parse this and set output into this hrMemorySize as value.
I know in grafana we can use label_values but I am not using grafana for visualization instead we have custom build application which is using these queries.
Solution 1:[1]
Currently prometheus metrics types include counter, gauge, histogram, and summary. They are all numeric types.
But Prometheus labels are always Strings, so I think should be no functions to transform metric labels to metric values.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Leo Lao |
