Kevin
Kevin

Reputation: 1106

InfluxQL: select records from last 24 hours?

This is my query :

SELECT mean("value") FROM "autogen"."°C" WHERE ("entity_id" = 'shelly_1l_our_room_device_temperature') AND $timeFilter GROUP BY time($__interval) fill(null)

I'm trying to add a second query with the same data but 24h behind

I tried many thing but it's doesn't seems to work :

SELECT mean("value") FROM "autogen"."°C" WHERE ("entity_id" = 'shelly_1l_our_room_device_temperature') AND DATE_SUB(NOW(), INTERVAL 24 HOUR) GROUP BY time(20s) fill(null)


SELECT mean("value") FROM "autogen"."°C" WHERE ("entity_id" = 'shelly_1l_our_room_device_temperature') AND time >= now() - 48h and time <= now() - 24h GROUP BY time($__interval) fill(null)

As you can see I have barely no experience with InfluxQL.

Upvotes: 0

Views: 1521

Answers (1)

Munin
Munin

Reputation: 1639

Your syntax looks good to me. It might be the data itself which has some issues.

To confirm, could you please try this:

  1. See whether there are some data from last 24 hours

    SELECT "value" FROM "autogen"."°C" WHERE ("entity_id" = 'shelly_1l_our_room_device_temperature') AND time >= now() - 24h

  2. Apply the aggregate

    SELECT mean("value") FROM "autogen"."°C" WHERE ("entity_id" = 'shelly_1l_our_room_device_temperature') AND time >= now() - 24h GROUP BY time(20s) FILL(null)

See more details here.

Upvotes: 2

Related Questions