Hi all!
In my database I have data being inserted on a “origin” measurement, with a low-duration retention policy, and some continuous queries acting on it producing other measurements, with coarser aggregation. For a specific information I need to retrieve one CQ is not enough (I’d need to make something like a count distinct, or a count on a group by, and I read that this can’t be done atm); therefore I’ve been concatenating two CQs.
The second CQ though it’s returning wrong values for the Sum aggregation: being the first measurement “aggrdata.minly.usrs”, and the second one “aggrdata.hourly.usxp”, if for each time-bin of the former you count how many distinct values the tag “usrs” takes for a specific “cnt”, you get one, while the latter shows count values higher than that.
I’m really clueless about why this is happening, I fear I’ve been doing things unorthodoxly, like the two concatenate CQs, or or maybe the way I used CQ’s advanced syntax … I must confess that, needing shorter durations for my retention policies, I even changed the MinRetentionPolicyDuration variable in Influxdb’s source and custom built it. Though I don’t see why any of these should affect how Sum aggregations works. Can anyone cast some light on this mystery? Thanks in advance!
I’ll append the continuous query, and some queries that show what I just now tried to explain. I don’t think my config file is necessary, but if you think otherwise just tell me and I’ll attach it. (also, at the moment the shortest duration for my retention policies is 30m, even though I plan to take it down to 1 or 2m)
CREATE CONTINUOUS QUERY CQ_usexp_m ON aggrdata
RESAMPLE EVERY 1m FOR 2m
BEGIN
SELECT count(n_files) AS n_users,
mean(n_files) AS avg_files
INTO aggrdata.st_m.usexp
FROM aggrdata.minly_rt.usrs
GROUP BY time(1m), brwsr, cnt
END
select * from minly_rt.usrs where cnt='SOrBDPy' and brwsr='2' and time > now() - 30m
name: usrs
time brwsr cnt n_files usr
---- ----- --- ------- ---
2017-06-06T14:09:00Z 2 SOrBDPy 12 714e70fb-f84d-4914-a6fa-ccaa5287f4e0
2017-06-06T14:10:00Z 2 SOrBDPy 12 714e70fb-f84d-4914-a6fa-ccaa5287f4e0
2017-06-06T14:11:00Z 2 SOrBDPy 12 714e70fb-f84d-4914-a6fa-ccaa5287f4e0
2017-06-06T14:12:00Z 2 SOrBDPy 12 714e70fb-f84d-4914-a6fa-ccaa5287f4e0
2017-06-06T14:13:00Z 2 SOrBDPy 12 714e70fb-f84d-4914-a6fa-ccaa5287f4e0
2017-06-06T14:14:00Z 2 SOrBDPy 12 714e70fb-f84d-4914-a6fa-ccaa5287f4e0
2017-06-06T14:15:00Z 2 SOrBDPy 12 714e70fb-f84d-4914-a6fa-ccaa5287f4e0
2017-06-06T14:16:00Z 2 SOrBDPy 12 714e70fb-f84d-4914-a6fa-ccaa5287f4e0
2017-06-06T14:17:00Z 2 SOrBDPy 12 714e70fb-f84d-4914-a6fa-ccaa5287f4e0
2017-06-06T14:18:00Z 2 SOrBDPy 12 714e70fb-f84d-4914-a6fa-ccaa5287f4e0
2017-06-06T14:19:00Z 2 SOrBDPy 12 714e70fb-f84d-4914-a6fa-ccaa5287f4e0
2017-06-06T14:20:00Z 2 SOrBDPy 12 714e70fb-f84d-4914-a6fa-ccaa5287f4e0
2017-06-06T14:21:00Z 2 SOrBDPy 12 714e70fb-f84d-4914-a6fa-ccaa5287f4e0
2017-06-06T14:22:00Z 2 SOrBDPy 12 714e70fb-f84d-4914-a6fa-ccaa5287f4e0
2017-06-06T14:23:00Z 2 SOrBDPy 12 714e70fb-f84d-4914-a6fa-ccaa5287f4e0
2017-06-06T14:24:00Z 2 SOrBDPy 12 714e70fb-f84d-4914-a6fa-ccaa5287f4e0
2017-06-06T14:25:00Z 2 SOrBDPy 12 714e70fb-f84d-4914-a6fa-ccaa5287f4e0
2017-06-06T14:26:00Z 2 SOrBDPy 12 714e70fb-f84d-4914-a6fa-ccaa5287f4e0
2017-06-06T14:27:00Z 2 SOrBDPy 12 714e70fb-f84d-4914-a6fa-ccaa5287f4e0
2017-06-06T14:28:00Z 2 SOrBDPy 12 714e70fb-f84d-4914-a6fa-ccaa5287f4e0
2017-06-06T14:29:00Z 2 SOrBDPy 12 714e70fb-f84d-4914-a6fa-ccaa5287f4e0
2017-06-06T14:30:00Z 2 SOrBDPy 12 714e70fb-f84d-4914-a6fa-ccaa5287f4e0
2017-06-06T14:31:00Z 2 SOrBDPy 12 714e70fb-f84d-4914-a6fa-ccaa5287f4e0
2017-06-06T14:32:00Z 2 SOrBDPy 12 714e70fb-f84d-4914-a6fa-ccaa5287f4e0
2017-06-06T14:33:00Z 2 SOrBDPy 12 714e70fb-f84d-4914-a6fa-ccaa5287f4e0
2017-06-06T14:34:00Z 2 SOrBDPy 12 714e70fb-f84d-4914-a6fa-ccaa5287f4e0
2017-06-06T14:35:00Z 2 SOrBDPy 12 714e70fb-f84d-4914-a6fa-ccaa5287f4e0
2017-06-06T14:36:00Z 2 SOrBDPy 13 714e70fb-f84d-4914-a6fa-ccaa5287f4e0
2017-06-06T14:37:00Z 2 SOrBDPy 12 714e70fb-f84d-4914-a6fa-ccaa5287f4e0
select * from st_m.usexp where cnt='SOrBDPy' and brwsr='2' and time > now() - 30m
name: usexp
time avg_files brwsr cnt n_users
---- --------- ----- --- -------
2017-06-06T14:09:00Z 12 2 SOrBDPy 1
2017-06-06T14:10:00Z 12 2 SOrBDPy 1
2017-06-06T14:11:00Z 12 2 SOrBDPy 3
2017-06-06T14:12:00Z 12 2 SOrBDPy 1
2017-06-06T14:13:00Z 12 2 SOrBDPy 3
2017-06-06T14:14:00Z 12 2 SOrBDPy 1
2017-06-06T14:15:00Z 12 2 SOrBDPy 3
2017-06-06T14:16:00Z 12 2 SOrBDPy 1
2017-06-06T14:17:00Z 12 2 SOrBDPy 3
2017-06-06T14:18:00Z 12 2 SOrBDPy 1
2017-06-06T14:19:00Z 12 2 SOrBDPy 3
2017-06-06T14:20:00Z 12 2 SOrBDPy 5
2017-06-06T14:21:00Z 12 2 SOrBDPy 1
2017-06-06T14:22:00Z 12 2 SOrBDPy 3
2017-06-06T14:23:00Z 12 2 SOrBDPy 1
2017-06-06T14:24:00Z 12 2 SOrBDPy 3
2017-06-06T14:25:00Z 12 2 SOrBDPy 1
2017-06-06T14:26:00Z 12 2 SOrBDPy 1
2017-06-06T14:27:00Z 12 2 SOrBDPy 3
2017-06-06T14:28:00Z 12 2 SOrBDPy 1
2017-06-06T14:29:00Z 12 2 SOrBDPy 3
2017-06-06T14:30:00Z 12 2 SOrBDPy 5
2017-06-06T14:31:00Z 12 2 SOrBDPy 1
2017-06-06T14:32:00Z 12 2 SOrBDPy 1
2017-06-06T14:33:00Z 12 2 SOrBDPy 3
2017-06-06T14:34:00Z 12 2 SOrBDPy 5
2017-06-06T14:35:00Z 12 2 SOrBDPy 1
2017-06-06T14:36:00Z 13 2 SOrBDPy 1
2017-06-06T14:37:00Z 12 2 SOrBDPy 3