Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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.


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

1 Answer

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...