How to get the rate of duration bucket in promethues after using subtraction

Viewed 165

I'm trying to get the rate of request duration after subtracting 2 buckets. However, the below query returns error. How can I get the rate after using subraction? If its not possible then how can I represent this?

sum(rate(duration_bucker{le="5.0"}  - ignoring(le) duration_bucker{le="1.0"} [1m])) by (data)

Error:"1:96: parse error: binary expression must contain only scalar and instant vector types"

1 Answers

Just apply the rate() function individually to the left and to the right operand of the - operation:

sum(
  rate(duration_bucker{le="5.0"}[1m]) - ignoring(le)
  rate(duration_bucker{le="1.0"}[1m])
) by (data)
Related