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
There is an issue with the Flux histogramQuantile() function that causes it to display incorrect results. Specifically, when trying to calculate the quantile for a histogram with no new observations (therefore, a total count of observations in the buckets is zero), the function fails to return the expected result.
Steps to Reproduce
There is a Prometheus histogram in InfluxDB (v2 mapping) that is not currently being incremented due to zero traffic condition.
Try to plot the quantile of the histogram using the histogramQuantile() function.
Notice that the resulting plot defaults the result to the value of the highest bucket boundary in the histogram, even though there have been no observations in this period.
Expected Behaviour
The histogramQuantile() function should return nothing if the total count of the buckets is zero.
Actual Behaviour
The histogramQuantile() function returns the value of the highest bucket. This is because rankIdx will always be the highest bucket, as rank ≥ b.count will always be true if rank := t.spec.Quantile * totalCount is zero and b.count is also zero. The rankIdx switch case then assumes that the quantile lies above the highest upper bounds and returns the highest upper bound as the result.
Possible Solution
Add a return condition to the computeQuantile() function in histogram_quantile.go that checks if the totalCount is zero.
iftotalCount==0 {
return0, false, nil
}
The text was updated successfully, but these errors were encountered:
Thanks for filing this. Rather than make it produce a zero, I made it produce a null value in this PR, since we can't compute a quantile at all in the absence of any observations: #5419
Description
There is an issue with the Flux
histogramQuantile()
function that causes it to display incorrect results. Specifically, when trying to calculate the quantile for a histogram with no new observations (therefore, a total count of observations in the buckets is zero), the function fails to return the expected result.Steps to Reproduce
histogramQuantile()
function.Expected Behaviour
The
histogramQuantile()
function should return nothing if the total count of the buckets is zero.Actual Behaviour
The
histogramQuantile()
function returns the value of the highest bucket. This is becauserankIdx
will always be the highest bucket, asrank ≥ b.count
will always be true ifrank := t.spec.Quantile * totalCount
is zero andb.count
is also zero. TherankIdx
switch case then assumes that the quantile lies above the highest upper bounds and returns the highest upper bound as the result.Possible Solution
Add a return condition to the
computeQuantile()
function inhistogram_quantile.go
that checks if thetotalCount
is zero.The text was updated successfully, but these errors were encountered: