in a simple tick script, how can i query points and edit some key/values ?
i have this tick script:
var data = batch
|query(''' SELECT * FROM "telegraf"."autogen"."cpu" ''')
.period(5m)
.every(10s)
.groupBy(*)
|influxDBOut()
.database('telegraf)
.retentionPolicy('autogen')
.measurement('modified_data)
that queries some data, i want to change the CPU field on each point and add 5 to its value.
how can i do that ? thanks. Dave.
Normally, you change the fields inside CPU measurement.
For example, let's say your CPU measurement contains a field named time_idle, then you just have to insert an "eval" node before the output node.
var data = batch
|query(''' SELECT * FROM "telegraf"."autogen"."cpu" ''')
.period(5m)
.every(10s)
.groupBy(*)
|eval(lambda: "time_idle" + 5)
.as('time_idle_plus_5')
|influxDBOut()
.database('telegraf')
.retentionPolicy('autogen')
.measurement('modified_data')
Would be a good idea to read more about eval node here and about TICKScript nodes in general.