Hi all.
I need some help with Continuous Query.
I have next measurement ‘test’:
- value (filed).
- event (tag).
- direction (tag).
For example:
time direction event value
1509463455 “direction1” “event1” 12
1509463456 “direction1” “event1” 14
1509463457 “direction1” “event2” 18
1509463458 “direction1” “event2” 10
1509463459 “direction1” “event3” 15
1509463460 “direction2” “event2” 10
1509463461 “direction2” “event2” 15
My problem is: I need to create Continuous Query, that I can calculate SUM of values GROUP BY direction and event.
Ok, I have wrote next Continuous Query:
CREATE CONTINUOUS QUERY “cq_test” ON "telegraf"
RESAMPLE EVERY 1d
BEGIN
SELECT SUM(value) INTO “test_sum” FROM “test” GROUP BY direction, event, time(1h)
END
But, this CQ calculates total SUM by all events group by one direction.
Therefore, I got:
time direction value
1509463455 “direction1” 69
1509463456 “direction2” 25
But, I want to get something like this:
time direction event value
1509463455 “direction1” “event1” 26
1509463457 “direction1” “event2” 28
1509463459 “direction1” “event3” 15
1509463460 “direction2” “event2” 25
Please, could you clarify, how can I do it (if it possible by CQ)?
Thank you in advance.