influxdata / influxdata/kapacitor
stateChangeOnly triggers more alerts for each state
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 2.4k
- Forks
- 479
- Avg merge
- 4d 16h
- Merged PRs (30d)
- 4
Description
Hello
InfluxDB: 1.6.4
Chronograf: 1.6.2 (git: 8ba29804dd3e52859363851b3fe73abab442dd0e)
Kapacitor: OSS 1.5.1 (git: HEAD 89828ffff6cf5cd4cb2b34bf883e134395f734de)
I'm quite new to kapacitor and Chronograf but I have tried to setup and high flow alarm which should only trigger once per state change. The problem I'm facing is that even though the ".stateChangeOnly()" have been set on the Alert node then I still get multiple alerts for each state. I do not get for all the metrics values but for around 80% so some are sorted out.
The image shows all alerts and the actual data from my influx measurement. I would have expected only to get the two alerts marked with red.

Could this have something to do with the bulk writing to influx? that multiple messages are write in one write request?
And here is my kapacitor TICK script:
```
var db = 'OPCUA'
var rp = 'autogen'
var measurement = 'water0.flow.hot'
var groupBy = []
var whereFilter = lambda: TRUE
var name = 'Varmt vand forbrug HH'
var idVar = name
var message = 'Vand forbrug udenfor er højt, lige nu !!! '
var idTag = 'alertID'
var levelTag = 'level'
var messageField = 'message'
var durationField = 'duration'
var outputDB = 'chronograf'
var outputRP = 'autogen'
var outputMeasurement = 'alerts'
var triggerType = 'threshold'
var crit = 4
var data = stream
|from()
.database(db)
.retentionPolicy(rp)
.measurement(measurement)
.groupBy(groupBy)
.where(whereFilter)
|eval(lambda: "value")
.as('value')
var trigger = data
|alert()
.crit(lambda: "value" > crit)
.message(message)
.id(idVar)
.idTag(idTag)
.levelTag(levelTag)
.messageField(messageField)
.durationField(durationField)
.stateChangesOnly()
trigger
|eval(lambda: float("value"))
.as('value')
.keep()
|influxDBOut()
.create()
.database(outputDB)
.retentionPolicy(outputRP)
.measurement(outputMeasurement)
.tag('alertName', name)
.tag('triggerType', triggerType)
trigger
|httpOut('output')
```
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the supplied TICK script and the alert node's stateChangesOnly() behavior. Compare the incoming measurement points with the generated alert output, including the grouped state and bulk writes. Done means repeated values within one state produce no additional alerts while transitions still produce one alert.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- observability
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100