Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
622 views
in Technique[技术] by (71.8m points)

prometheus - 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...