I'm looking for something similar to SQL's LEAST() function.
Since there are binary operators (and a well-defined matching behavior) one would expect there would be min/max as well, but couldn't find such functions.
I'm aware that this is achievable using regex (i.e., min(__name__=~"a|b")
) but would like to avoid such hacks if possible.
PromQL supports the ability to join two metrics together: You can append a label set from one metric and append it to another at query time. This can be useful in Prometheus rule evaluations, since it lets you generate a new metric for a series by appending labels from another info metric.
To filter out unwanted metrics from a target, use the ignore_metrics configuration option. To filter out targets instead of the metrics, use the scrape_enabled_label configuration option.
Prometheus rate function is the process of calculating the average per second rate of value increases. You would use this when you want to view how your server CPU usage has increased over a time range or how many requests come in over a time range and how that number increases.
I'm pretty sure that's the most efficient way of doing it. If you want to avoid regexes, you could write it instead as:
a < b or b
But it may be more expensive to compute this way. (Unless, of course, you used recording rules instead of min(a)
and min(b)
directly. And maybe even then. You'll just have to benchmark it yourself.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With