Last NaN data point messes the Average

Hello,

I have seen that whenever my query returns a “NaN” as the last data point of a time period, the Single Stat Panel shows a “NaN” even if there are many other data points with proper values and i have set the Stat parameter to be “Average”. When the query returns a proper value as the last data point, everything works as expected; average is calculated and presented by the panel.
We are using a custom data store plugin in order to work with Netflix Atlas telemetry system. Is there a possibility that the bug is in the plugin?

Hi,

By NaN, do you mean null or something else? I think that a non-available value always should be represented as null for the singlestat panel to work correctly. Can you possibly try/verify this?

Marcus

Hello,

In Netflix Atlas, NaN means that for the specific timestamp, there is no data point.

The thing is that the panel works ok when NaN values are present in any other timestamp of the selected time window, expect the last one. So, executing a query for a time window of 1 hour and with an Atlas server step size of 1 minute, i get back 60 data points. The first 20 may be NaN, then the rest of them may have proper values. In this case, panel works ok and it actually averages the 40 values. However, if the last data point is NaN, then panel shows NaN, even if there are many other data points with a proper value.

I will go into checking why my query returns a NaN as the last data point from time to time, but i think this is orthogonal to the current issue which smells like a bug.

Maybe related to this issue.

Maybe the easiest would be to add a test for your NaN scenario here.

Marcus

I am experiencing this issue irrespective of the last datapoint being NaN or a number in grafana v7.3.6