Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In promQL, how to max clamp the values of an instant vector with another instant vector

Tags:

clamp

promql

Is there a way to achieve that max clamping by passing an instant vector containing corresponding max values for each series?

In promQL, using the function clamp_max, it is possible to clamp the values of an instant vector with a scalar value, but if an instant vector is passed instead of the scalar, you get an error

Using function scalar() on that instant vector only works if the instant vector only contains one single value

like image 583
Dixan M Avatar asked Oct 15 '25 23:10

Dixan M


1 Answers

The simplest solution for clamping v time series with max_v series is the following:

(v < max_v) or max_v

This query works in the following way:

  1. The v < max_v leaves only values smaller than max_v.
  2. The (...) or max_v fills gaps from the step 1 with max_v values.
like image 64
valyala Avatar answered Oct 19 '25 17:10

valyala



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!