You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow native histogram to be divided by a float (non zero). Also would make sense to allow the other operations to take place by going through the histogram and applying the operation on all components of the histogram.
Rationale:
When calculating rate/increase of native histograms, the result is component wise (sum, count, ...) operation. To be able to scale the output, we need the division.
Concrete problem
In Grafana Mimir we have query splitting by time. Which means running some queries in parts by splitting on time and then merging the result.
One particular case is:
sum(rate(native_histogram_series{}[3m]))
Here rate = increase / time, so you can rewrite the above to say (roughly for brevity):
sum( (increase over first minute + increase over second minute + increase over third minute) / 180 )
So you get partial increase and then divide by the total time (180s).
The only problem is that currently dividing the native histogram by number results in 0s. But if division worked as expected, we would get the correct results.
The text was updated successfully, but these errors were encountered:
"Scaling" histograms (via multiplication/division by a scalar) sounds like a reasonable thing to do. However, I vaguely remember that I hit some roadblocks when I wanted to implement it a while ago. But I cannot remember the details. Perhaps that was before we fully embraced the FloatHistogram… But since we now use FloatHistogram exclusively inside PromQL, it might be easy to do. Maybe the concern had to do with "negative" histograms, e.g. what happens if you do -1 * some_histogram. Again, with FloatHistogram not a problem, but it throws off counter reset detection. I guess usually you would only scale gauge histograms (e.g. a rated histogram, in fact, rate is already internally scaling the histogram), and we could issue a warning when creating "negative" counter histograms (cf. #12152). Once we are fine with negative histograms, we could also allow subtraction between histograms (because histogram_a - histogram_b is anyway equivalent to histogram_a + -1 * histogram_b).
Proposal
Allow native histogram to be divided by a float (non zero). Also would make sense to allow the other operations to take place by going through the histogram and applying the operation on all components of the histogram.
Rationale:
When calculating rate/increase of native histograms, the result is component wise (sum, count, ...) operation. To be able to scale the output, we need the division.
Concrete problem
In Grafana Mimir we have query splitting by time. Which means running some queries in parts by splitting on time and then merging the result.
One particular case is:
sum(rate(native_histogram_series{}[3m]))
Here rate = increase / time, so you can rewrite the above to say (roughly for brevity):
sum( (increase over first minute + increase over second minute + increase over third minute) / 180 )
So you get partial increase and then divide by the total time (180s).
The only problem is that currently dividing the native histogram by number results in 0s. But if division worked as expected, we would get the correct results.
The text was updated successfully, but these errors were encountered: