1
votes

I have a table/serie like this

Message              MessageValue 
 ---------------      ---------------------   
property1                         10            
property2                         9
property3                         7
property2                         22

I want to downsample property2's mean value every 10 minutes. How would I do something like this?

CREATE CONTINUOUS QUERY "cq_10m" ON "DatabaseName" BEGIN SELECT mean(SELECT MessageValue WHERE Message =property2 ) AS "mean_Property2" INTO "RetentionPolicyName"."downsampled_orders" FROM "TableName" GROUP BY time(10m) END

1

1 Answers

0
votes

It would look something like below. Your CQ will query the db every 10 minutes and will calculate the mean of "MessageValue" across that time frame. This will be downsampled into: mean_Property2.

CREATE CONTINUOUS QUERY "cq_10m" ON "dbName"
RESAMPLE EVERY 10m FOR 2h
BEGIN SELECT mean("MessageValue") AS mean_Property2 INTO 
mean_Property2 FROM "retentionPolicyName"."measurementName" WHERE "Message"='property2'
GROUP BY time(10m) END