> I have series collected every minute detailing the number of users per service per region. Let's say the measurement is called online_users with tags service and region. A region can have more than one service.
> I want to view the total number of users in a region in the last day: > SELECT sum(value) FROM online_users WHERE region='xyz' AND time > NOW() - 1d > I get my back expected results with 1 sample per minute with a sum of all users in all services in that region. All good so far. I'm confused. That won't give you the number of users per day in the 'xyz' region, that will give you the total person-minutes for the region. For example, let's say that these are the metrics for a 5 minute period: 0 users = 12 60 users = 12 120 users = 13 180 users = 14 240 users = 14 300 users = 13 Summing those gives 78, but there aren't 78 users playing, there are a total of 14 players who have been online for 1-5 minutes each. Can you clarify your examples with actual numbers and the expected output? Maybe you meant to give this as the query? SELECT sum(value) FROM online_users WHERE region='xyz' AND time > NOW() - 1d GROUP BY time(1m) On Fri, Sep 9, 2016 at 10:56 PM, <[email protected]> wrote: > Hi, > > I think the answer to this question is "use CQ", but it seems like an > obvious use case so maybe I've overlooked a better solution: > > I have series collected every minute detailing the number of users per > service per region. Let's say the measurement is called online_users with > tags service and region. A region can have more than one service. > > I want to view the total number of users in a region in the last day: > > SELECT sum(value) FROM online_users WHERE region='xyz' AND time > NOW() - > 1d > > I get my back expected results with 1 sample per minute with a sum of all > users in all services in that region. All good so far. > > When I use Grafana and want to let it choose an appropriate interval (say > 10 minutes), I would probably try this first: > > SELECT sum(value) FROM online_users WHERE region='xyz' AND time > NOW() - > 1d GROUP BY time(10m) > > But this will give me the sum of all samples in that 10 minute period, > effectively multiplying my results by 10. I could just divide by 10, but I > don't have a way of conveniently being able to derive the number of > expected samples per $interval. > > I could also take the mean and multiply it by the number of services, but > I don't think a COUNT(DISTINCT()) works on tags. > > sum(mean()) gets thrown out by the parser. > > As I mentioned, this is something I do commonly in other TSDBs so I'm > hoping I'm missing something obvious. > > Thanks! > > -- > Remember to include the InfluxDB version number with all issue reports > --- > You received this message because you are subscribed to the Google Groups > "InfluxDB" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > 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/133633cd-4010-4a5c-88db-68b97f73e393%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- Sean Beckett Director of Support and Professional Services InfluxDB -- Remember to include the InfluxDB version number with all issue reports --- You received this message because you are subscribed to the Google Groups "InfluxDB" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. 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/CALGqCvOY0od89E__OZWi9W3zoZDxBQxV%3DavgOg-%2BkLU5i5YFCA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
