Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
684 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 Reply

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...