I have a problem that I think is quite common, and probably very simple, but I’m new to Influx so would like your input.
I have data that looks like this:
_time, _value, _field, _measurement, asset
2020-03-04T20:54:12, 300, price, tick_data, AAPL
I have many points of data every minute, so I’d like to aggregate to 1min bars (for example) and insert this in to a new bucket called “minuteData”. I think this would be executed once a minute through a “task”.
A few questions:
- Is that a reasonable thing to do, or is it better to just keep the tick data as is and do the aggregating in the query when reading the data?
- How would you suggest I make the insert to a new bucket? I have been messing around with join, to join the four aggregates first, max, min, last, but I’m not sure that’s the best way. Something similar to (removed min and max from example):
open = from(bucket: “myBucket”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: ® => r._measurement == “tick_data”)
|> aggregateWindow(every: 1m, fn: first)
|> yield(name: “open”)
close = from(bucket: “myBucket”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: ® => r._measurement == “tick_data”)
|> aggregateWindow(every: 1m, fn: last)
|> yield(name: “close”)
join(
tables: {open, close},
on: ["_time", “_stop”, “_start”, “_measurement”, “_field”, “asset”]
)
How would you handle this task? I’m I on the right track?
Thanks!