Grafana stat panel Mean, Max, Min for timerange

Hi all,

I am trying to use stat panel to display the Min, Max and average of a time series data. Indeed I would like the stat panels to only display the these values for the time range that I have selected (e.g. last 5 min, last 15 min, etc.). Unfortunately the stat panel is showing the Min, Max, and average values for the entire data.

Can anybody help me out here.

I am using the grafana version 10.2.1.

With thanks and regards,
Martin

Welcome @meberle to the Grafana forum.

What is your datasource and can you share your query(ies)?

Hi grant2,

Iā€™m using mySql as datasource.

Here is the query:
SELECT operationsData.PathSpeedActual FROM xxx.Sprays
JOIN operationData ON Sprays.SprayID = operationData.SprayID
WHERE Sprays.LogID IN (SELECT LogID FROM xxx.Log WHERE JobReference IN ($jobreference)) AND operationData.Stepchain IN ($step);

I exerpienced the same issue with table visualisation.

Regards,
Martin

Where is the min max avg being calculated?

Hi yosiasz. The min max or avg are selected in value options in the Stats menu. It is not included in the datasource query.

1 Like

Can you share screenshots of what you have configured in Grafana to obtain the above?

From your last reply, I think it could make sense to adapt your query to calculate the min (or max) and use that query in Grafana.

Hi grant2,

I have used this query:
SELECT operationsData.PathSpeedActual FROM xxx.Sprays
JOIN operationData ON Sprays.SprayID = operationData.SprayID
WHERE Sprays.LogID IN (SELECT LogID FROM xxx.Log WHERE JobReference IN ($jobreference)) AND operationData.Stepchain IN ($step);

In the stat panel options under value options and then Calculation I chose Mean (see image)

image

Unfortunately, the value for the mean that is displayed is not affected by the time range selection:

image

Thanks,
Martin

I think this is because you do not reference the time selector in your query. You need a statement in the WHERE clause such as

WHERE $__timeFilter(datetime_column)

1 Like