Help with query to include only specific times

  • What Grafana version and what operating system are you using?

Grafana 7.3.7 on Docker on Synology NAS

  • What are you trying to achieve?

Trying to get a max/min value per day, but pull data from only a specific time range per day (i.e. between 08.00 to 13.00)

  • How are you trying to achieve it?

This query works for the full 24h of a day, but I need it to only include a specific time range per day.
SELECT max(“value”) FROM “mqtt_consumer” WHERE (“topic” = ‘tele/BoilerTemp1/temp’) AND $timeFilter GROUP BY time(1d) fill(null)

  • What happened?

It includes data from the full 24h of a day rather than a specific time range I need.

  • What did you expect to happen?

  • Can you copy/paste the configuration(s) that you are having problems with?

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.

This is not a problem I am reporting, hence no errors.

  • Did you follow any online instructions? If so, what is the URL?

Welcome @peros550

If your datasource is InfluxDB, then you appear to be using InfluxQL.

From this:

InfluxQL doesn’t support DatePart-like queries that only return results during specified hours of the day. The Flux hourSelection function returns only data with time values in a specified hour range.

In Flux, you can achieve what you want with a statement like this:

|> hourSelection(start: 8, stop: 13)