Reputation: 9140
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?
Upvotes: 3
Views: 4406
Reputation: 1836
InfluxDB has no concept of days of the week. You can get the average revenue per day, where a day is midnight to midnight UTC with the following:
SELECT MEAN(revenue) FROM revenue_count WHERE time > now() - 7d GROUP BY time(1d)
Upvotes: 2
Reputation: 8622
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.
Upvotes: 2