Discussion:
[influxdb] ignore last group when grouping by time
o***@gmail.com
2017-11-01 18:47:17 UTC
Permalink
Whenever we do a `select sum(foo) from bar group by time(10m)`, the last group reported has lower numbers because it's not complete yet. If you keep running the same query over and over, the value for the last group will increase until it gets to the real value, until `now()` is at a round 10 minute mark, and then it'll go down to 0 again.

I'd like to be able to either (1) set the `group by time()` offset to the interval between the last "round" time interval OR (2) just have influx discard all data points between the end of the last round timestamp and `now()`.

I did a lot of reading of the documentation, github issues, and this group, and it seems like 1 is not possible. Is there a clean way to do 2?
--
Remember to include the version number!
---
You received this message because you are subscribed to the Google Groups "InfluxData" group.
To unsubscribe from this group and stop receiving emails from it, send an email to influxdb+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/influxdb.
To view this discussion on the web visit https://groups.google.com/d/msgid/influxdb/d9fe63c8-95aa-4413-98df-a0a177488261%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Frank Inselbuch
2017-11-02 13:04:31 UTC
Permalink
Use a where clause to restrict the values being considered... basically 2)
... but YOU have to do it

where time < now() - (you put in the number of minutes/hours, etc. here)

When the query language is richer you will be able to do things like
construct timestamps, round timestamps, etc. But some of those
functions/capabilities don't exist yet. In the short term what I have been
doing is generating the SQL programmatically in Python, then querying the
database with constructed SQL... consider this construct

q = "select sum(foo) from bar where time > now() - {}m".format(minutes_back)
results = iclient.query(q).get_points()
Post by o***@gmail.com
Whenever we do a `select sum(foo) from bar group by time(10m)`, the last
group reported has lower numbers because it's not complete yet. If you keep
running the same query over and over, the value for the last group will
increase until it gets to the real value, until `now()` is at a round 10
minute mark, and then it'll go down to 0 again.
I'd like to be able to either (1) set the `group by time()` offset to the
interval between the last "round" time interval OR (2) just have influx
discard all data points between the end of the last round timestamp and
`now()`.
I did a lot of reading of the documentation, github issues, and this
group, and it seems like 1 is not possible. Is there a clean way to do 2?
--
Remember to include the version number!
---
You received this message because you are subscribed to the Google Groups "InfluxData" group.
To unsubscribe from this group and stop receiving emails from it, send an email to influxdb+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/influxdb.
To view this discussion on the web visit https://groups.google.com/d/msgid/influxdb/5ea9af8d-85ba-4089-8afe-19c8090b95cb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...