Martin Del Vecchio
Martin Del Vecchio

Reputation: 3838

What PromQL query gives the minimum current value for an arbitrary list of metrics?

I have three metrics in Prometheus; let's call them metric1, metric2, and metric3.

I want to determine the minimum of the current values of those three metrics, and I can't figure out the PromQL.

MIN(metric1) works; it returns the current value of metric1

I tried MIN(metric1, metric2, metric3), MIN([metric1, metric2, metric3]), etc., but I can't make it work.

Upvotes: 1

Views: 2187

Answers (2)

Martin Del Vecchio
Martin Del Vecchio

Reputation: 3838

I finally saw this in the documentation; if I give the metrics consistent names, I can create an instant vector to match the names by regular expression:

min{__name__=~"metric.*"}

Upvotes: 2

Stefan R
Stefan R

Reputation: 755

You can use the aggregate function on a union of your 3 metrics:

 MIN(metric1 or metric2 or metric3)

That should work. Whether it's a good thing to do depends on what you are really trying to achieve and what your exact use-case is.

PromQL Operators \ Working example

Upvotes: 1

Related Questions