I'm trying to write a simple Elastic SQL that polls the temperature value in the last 3 minutes but i'm not able to select such a small timeframe. It should be as simple as NOW() - INTERVAL 3 MINUTES but that returns nothing.
If I increase the INTERVAL to 250 minutes, that somehow equates to the last 10 minutes and I don't understand how that can be.
What could I be doing wrong here?
sql> SELECT timestamp AS TIME, round(TEMPERATURE_A,1) AS TEMP FROM \"test*\" WHERE agent.hostname = 'b-1-1' AND TEMP is not null AND TIME < NOW() AND TIME > NOW() - INTERVAL 250 MINUTES ORDER BY TIME DESC LIMIT 1;
TIME | TEMP
------------------------+---------------
2019-10-14T11:42:00.000Z|-166.9
sql> SELECT timestamp AS TIME, round(TEMPERATURE_A,1) AS TEMP FROM \"test*\" WHERE agent.hostname = 'b-1-1' AND TEMP is not null AND TIME < NOW() AND TIME > NOW() - INTERVAL 250 MINUTES ORDER BY TIME ASC LIMIT 1;
TIME | TEMP
------------------------+---------------
2019-10-14T11:33:00.000Z|-166.9
241 seems like it represents the last minute but again, I am at a loss
sql> SELECT timestamp AS TIME, round(TEMPERATURE_A,1) AS TEMP FROM \"test*\" WHERE agent.hostname = 'b-1-1' AND TEMP is not null AND TIME < NOW() AND TIME > NOW() - INTERVAL 240 MINUTES ORDER BY TIME ASC;
TIME | TEMP
---------------+---------------
sql> SELECT timestamp AS TIME, round(TEMPERATURE_A,1) AS TEMP FROM \"test*\" WHERE agent.hostname = 'b-1-1' AND TEMP is not null AND TIME < NOW() AND TIME > NOW() - INTERVAL 241 MINUTES ORDER BY TIME ASC;
TIME | TEMP
------------------------+---------------
2019-10-14T11:50:00.000Z|-166.9
2019-10-14T11:50:00.000Z|-166.9
2019-10-14T11:50:00.000Z|-166.9
sql>
Any ideas?