Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PromQL query to get the maximum of two metrics

In a Prometheus timeseries database, there are two sets of data (for M1 and M2) collected with following schema

  • <timestamp>, <M1> <Labels L1, L2, L3>
  • <timestamp>, <M2> <Labels L1, L2, L3, L4>

Write a PromQL query that creates a new time-series N, that tracks the max(M1, M2) for each time period the query is run.

For example: table

I tried using max(), but it takes only 1 argument.

like image 466
Amy_Josh Avatar asked Oct 26 '25 05:10

Amy_Josh


1 Answers

metric1 > metric2 or metric2 > metric1

I think this does the max and works also when both metrics have the same set of labels.

like image 79
user2393642 Avatar answered Oct 29 '25 07:10

user2393642