Kapacitor - Alert on same measurement but different tag generating too many alerts

From Telegraf to Kapacitor, I have one measurement that sends the value of multiple alarms that i differentiate through a tag called “io_name”. Then alert ids are generated thanks to this tag.
I have this issue that whenever an alert() is triggered on one id and the other id is OK, the alert node will behave as if there was a change of state. Is it because the .stateChangeOnly() is just tied to the measurement and not the alert id ?
Here is my code, any idea of workaround ?

var id = '{{ index .Tags "io_name"}}'

var message = '{{ .Time }}: {{.Level }} alert has been triggered for {{index .Tags "io_name"}}'

        .crit(lambda: "value" == 1)
    |where(lambda: "id" != '') 

I found a solution, after .database() I added the measurement name and used .groupBy().


Hi bnjroos, I am trying to setup Telegraf to output to Kapacitor.

I tried using the Telegraf’s outputs.influxdb plugin and set it to the port Kapacitor API server is listening on (port 9092 by default), but it did not work.

[Telegraf’s log]
2019-04-03T06:13:48Z E! [outputs.influxdb] when writing to [[httplink]:9092]: Post [httplink]:9092/write?db=telegraf&rp=autogen: dial tcp connect: connection refused

[Kapacitor’s log]
ts=2019-04-03T14:52:29.786+08:00 lvl=error msg=“failed to connect to InfluxDB, retrying…” service=influxdb cluster=kapacitor err=“Get [httplink]:9092/ping: dial tcp connect: connection refused”

urls = ["[httplink]:9092"]
database = “telegraf”
retention_policy = “autogen”

enabled = true
default = true
name = “kapacitor”
urls = ["[httplink]:9092"]
username = “”
password = “”
timeout = 0

[root@xxx kapacitor]# telegraf -version
Telegraf 1.10.1 (git: HEAD a6778f46)

[root@xxx kapacitor]# rpm -qa | grep kapacitor

Can I know how did you manage to get it to work?


You have to output to Influxdb, not Kapacitor directly.