Grouping by Month in FLUX/Chronograf

Hi There,

I’ve been trying to group data by month and have posted elsewhere but without traction.
Hoping someone here can help me!

Here is what I’ve been running in chronograf using flux:

from(bucket: “xxx/autogen”)
|> range(start: dashboardTime)
|> filter(fn: ® => …
|> keep(columns: ["_value", “_time”])
|> window(every: 1mo, period: 1mo)
|> sum()

Which yields:

table | _start | _stop | _value
0 | 2019-11-28T00:00:00Z | 2019-12-26T00:00:00Z | 82800
1 | 2019-12-26T00:00:00Z | 2020-01-23T00:00:00Z | 231435
2 | 2020-01-23T00:00:00Z | 2020-02-20T00:00:00Z | 361485
3 | 2020-02-20T00:00:00Z | 2020-02-27T11:30:26.796882252Z | 78480

Is someone able to shed some light on the strange start/stop values - I.e.: why is Jan 23 considered the end of the first month here?
(Same goes for the other periods).

The total is correct when adding up all the tables, but the division/windowing is wrong.

My goal is to have a single table with 4 data points that sums _value by month.

Thanks!
-Phillip

Hello @phillipprahl,
I think this issue #1556 might be related.

Thank you for gertting back!
I also just found this: Fixing intervals for group by. by corylanou · Pull Request #2067 · influxdata/influxdb · GitHub
So, I’ll try to go to 2.0 and see if that works.
In the mean time I just string hacked _time which works but just isn’t very efficient.

Calendar month duration values were added in Flux 0.51.0. The current version that ships with InfluxDB 1.7 is Flux 0.50.0. InfluxDB 1.8.0 will include Flux 0.64.0. If you upgrade to 2.0, you’ll get a more current version of Flux that supports windowing by calendar month using the mo duration unit.

Hi Scott,

Thank you - that makes perfect sense!

-Phillip