I’m recording the temperature of my house in the Influx DB database and I would like to know, during the day, the MAX and MIN value between the start of day until now ( and now to use now - 1day).
But the time operator “start of day” doesn’t exist in InfluxDB, but I can see this value on grafana, and I tell me that is possible to do that but why .
Could you help me please ?
Thank you !
How are you defining
start of day? Do you mean since 12:00:00 or
now() - 1d ?
In flux you can simply add the function
|> min() to your query to get the min, and likewise the call to
|> max() to get the max for the same window.
SELECT max("temp_c") AS "max_temp_c" FROM "telegraf"."autogen"."environment" WHERE time > :dashboardTime: GROUP BY time(:interval:)
Should do it (you’ll have to adjust for your measurements and fields, of course.
In fact, I would like to get the max and min value, in InfluxDB base (temperature), since the start of day, which means, since for today in example 2019/11/21 at 00:00:00 until now.
Thank you for your help
Hi weado, sorry to resurrect this old post, but i’m trying to do something practically the same as you but for outdoor temperatures measurements in influx.
I don’t know about you, but I’m using influxdb on linux, in which case you can do some magic in bash like via a bash script to do what you’re trying to achieve.
My bash code, put into a file like minmax.sh:
#Assign the current date to a variable
#Add time 00:00 to the variable
#Spit back out the target date/time to check
#Query influx for the data
influx -precision rfc3339 -database airpressure -execute "SELECT MIN("value") AS "min_temp_c" FROM outtemp WHERE time <= now() AND time >= '$datetime'"
Also for windows a batch script could be used (.cmd/.bat file), with the following code:
rem echo %year%-%month%-%day%T00:00:00Z
influx -precision rfc3339 -database airpressure -execute "SELECT MIN("value") AS "min_temp_c" FROM outtemp WHERE time <= now() AND time >= '%datetime%'"