'How to query specific value of a particular metrics using PROMQL
I have one query while performing operation on an instant vector.
For ex: node_value metrics with 10minutes of data
node_value{ID="1",instance="xx.xxx.xx.xx:x",job="prometheus",node="node1"}
32 @1608811039.845
33 @1608811099.845
34 @1608811159.845
35 @1608811219.845
36 @1608811279.845
37 @1608811339.845
38 @1608811399.845
39 @1608811459.845
40 @1608811519.845
41 @1608811579.845
Now, I want to do a sum/any operation of 1st and last value of the above metrics.
How can we do that?, as I could see nothing specified in DOC. or more any specific way we can fetch values(single value) like 1st, 2nd or 3rd value from above metrics.
Solution 1:[1]
Use the offset modifier. For example, if you want to multiply the first and the last values do the following:
node_value{ID="1",instance="xx.xxx.xx.xx:x",job="prometheus",node="node1"} * node_value{ID="1",instance="xx.xxx.xx.xx:x",job="prometheus",node="node1"} offset 10m
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 | Marcelo Ãvila de Oliveira |