Hi everyone,
my goal is to downsample values from 1 minute to 5 minutes and compute mean, max or sum of some fields. Given the Continuous Query
CREATE CONTINUOUS QUERY downsampling_cpumemspace_5min ON mydb RESAMPLE EVERY 5m FOR 60m
BEGIN SELECT mean(cpu) AS cpu, mean(mem) AS mem, max(space) AS space
INTO "5min".cpumemspace FROM "1min".cpumemspace
GROUP BY time(5m), tagA, tagC
END
I created a downsampling TICKscript using BatchNode. Notice all fields are selected and tagB is omitted. This was pretty straightforward:
batch
|query('SELECT mean(cpu) AS cpu, mean(mem) AS mem, max(space) AS space FROM "mydb"."1min".cpumemspace')
.period(60m)
.every(5m)
.groupBy(time(5m), 'tagA', 'tagC')
|influxDBOut()
.database('mydb')
.retentionPolicy('5min')
.measurement('cpumemspace')
.precision('s')
I have now great difficulties to create a TICKscript with a StreamNode. This is the best I have so far:
stream
|from()
.database('mydb')
.retentionPolicy('1min')
.measurement('cpumemspace')
.groupBy(time(5m), 'tagA', 'tagC')
|window()
.period(60m)
.every(5m)
.align()
|influxDBOut()
.database('mydb')
.retentionPolicy('5min')
.measurement('cpumemspace')
.precision('s')
I ran into different problems, e.g. if I don’t specify time(5m)
in .groupBy()
the script generates values every minute - despite of .every(5m)
.
.groupBy(time(5m), 'cpu')
gives me
> invalid TICKscript: invalid dimension object of type kapacitor.TimeDimension
.groupBy(time(5min), "some_tag")
gives me a strange message
> invalid TICKscript: parser: unexpected identifier line 6 char 25 in "By(time(5min), “some”. expected: “)” where the tag is truncated after 4 chars. This is obviously a syntax error because I’m missing something in the docs.
I’m doing this in Chronograf. I have no direct access to log messages other than here with Editor + Logs.
My second problem is: By omitting Mean, Max or Sum of each field I managed to read from all fields. But how can I really convert the original continuous query to a Stream TICKscript including the computations?
Can somebody help me? I really appreciate any help.