Search code examples
influxdb

InfluxDB average for day of the week


Currently my data in Influx is the following

measurement: revenue_count
field: users
field: revenue #
timestamp: (auto generated by influx)

What i'm looking to do is find a way to get the average revenue for a day in the week. i.e What is the average revenue for Monday, Tuesday etc.

What's the best way to do this in influx?


Solution

  • You should use continuous queries to schedule automated rollups/downsampling and then select the data from these pre-calculated series.

    If you don't have too many points, you might not need the CQ's. In that case an on-the-fly group by will most probably be enough.

    I wasn't able to find info on whether you can "select all points for a certain day" by just specifying a date. As far as I know, this is currently not possible because if you specify something like time == '2016-02-22 what this will effectively mean is 2016-02-22 00:00:00 (it won't mean give me everything from 22nd Feb 2016).

    What you may need to do is specify an interval (two time points) between which you expect your downsampled point to be placed.