Kapacitor how i can create this influx query?

Hi,

I’m new in kapacitor and I don’t know how I can configure the stream about this query

SELECT mean(“usage_system”) AS “mean_usage_system” FROM “telegraf”.“two_weeks”.“cpu” WHERE time > now() - 1h AND (“service”=‘elastic’ OR “service”=‘kafka’) GROUP BY time(10s), “host”

I have something similar to this, but I don’t know how put clausule where (“service”=‘elastic’ OR “service”=‘kafka’)

stream
|from()
.measurement(‘cpu’)
.groupBy(‘host’)
|alert()
.message(’{{ .Level }}: CPU idle usage is above 80% threshold- {{ index .Tags “service” }} - {{ index .Tags “env” }}’)
.stateChangesOnly()
.crit(lambda: “usage_system” < 20)
.log(’/tmp/alerts_test.log’)

Also I have this template:

// Which measurement to consume
var measurement string
// Optional where filter
var where_filter = lambda: TRUE
// Optional list of group by dimensions
var groups = [*]
// Which field to process
var field string
// Warning criteria, has access to ‘mean’ field
var warn lambda
// Critical criteria, has access to ‘mean’ field
var crit lambda
// How much data to window
var window = 5m

stream
|from()
.measurement(measurement)
.where(where_filter)
.groupBy(groups)
|window()
.period(window)
.every(window)
|mean(field)
|alert()
.warn(warn)
.crit(crit)

And this json: cpu_vars.json
{
“measurement”: {“type” : “string”, “value” : “cpu” },
“where_filter”: {“type”: “lambda”, “value”: ““cpu” == ‘cpu-total’”},
“groups”: {“type”: “list”, “value”: [{“type”:“string”, “value”:“host”},{“type”:“string”, “value”:“dc”}]},
“field”: {“type” : “string”, “value” : “usage_idle” },
“warn”: {“type” : “lambda”, “value” : ““mean” < 30.0” },
“crit”: {“type” : “lambda”, “value” : ““mean” < 10.0” },
“window”: {“type” : “duration”, “value” : “1m” }
}

Also how I can modify this json values to include the right clausule where?

Any suggestion? U_U

Thank you very much