I don’t understand why a specific variable (dbfield) that I’m passing into the QUERY node is not being recognized within the tick script.
Here is my task_template:
// Which measurement to consume
var measurement string
// Optional list of group by dimensions
var groups =
// Which field to process
var dbfield string
// How much data to window
var window duration
// What interval to show data
var interval duration
// What fill type to use (null, previous, linear, etc)
var fill string
// What destination DB to use
var outDB string
// What destination measurement to use
var outMeasurement string
var data = batch
|query('''
SELECT last('dbfield')
FROM "telemetry_backbone_prod_clean"."autogen"."interfaces"
''')
.period(window)
.every(interval)
.groupBy(time(interval), *)
.fill(fill)
|influxDBOut()
.database(outDB)
.retentionPolicy('autogen')
.measurement(outMeasurement)
Here is my vars.json file:
{
“template-id”: “juniper_backfill_template”,
“dbrps”: [{“db”: “telemetry_backbone_prod_clean”, “rp”: “autogen”}],
“vars”: {
“measurement”: {“type” : “string”, “value” : “interfaces” },
“groups”: {“type”: “list”, “value”: [{“type”:“string”, “value”:"*"}]},
"dbfield": {“type” : “string”, “value” : “in-octets” },
“window”: {“type” : “duration”, “value” : “5m” },
“interval”: {“type” : “duration”, “value” : “1m” },
“fill”: {“type” : “string”, “value” : “linear”},
“outDB”: {“type” : “string”, “value” : “telemetry_backbone_prod_clean_stats_test”},
“outMeasurement”: {“type” : “string”, “value” : “interfaces”}
}
}
The kapacitor show command does show the variable coming over:
Vars:
Name Type Value
dbfield string in-octets
fill string linear
groups list [*]
interval duration 1m0s
measurement string interfaces
outDB string telemetry_backbone_prod_clean_stats_test
outMeasurement string interfaces
window duration 5m0s
But when I enable the task I get the following message which doesn’t show the correct value for dbfield:
ts=2019-11-18T17:19:14.974Z lvl=debug msg="starting next batch query" service=kapacitor task_master=main task=juniper_ **backfill** _task node=query1 query="SELECT last(dbfield) FROM telemetry_backbone_prod_clean.autogen.interfaces WHERE time >= '2019-11-18T17:14:14.974526704Z' AND time < '2019-11-18T17:19:14.974526704Z' GROUP BY time(1m, 0s), * fill(linear)"
I even tried putting this value for dbfield inside the vars.json file but it did not help:
"\"in-octets\""
Any help would be greatly appreciated.
Thank you,
Mohsin