influxdata / influxdata/kapacitor
hysterisis alert like zabbix
- Dominant language
- Go
- Stars
- 2.4k
- Forks
- 479
- Avg merge
- 4d 16h
- Merged PRs (30d)
- 4
Description
Hi,
I test kapacitor and have some questions.
## 1. with window but no all()
```
var win = 5s
var origin = stream
|from()
.database('test')
.retentionPolicy('default')
.measurement('ka')
.groupBy('app')
origin
|window()
.period(win)
.every(1s)
|alert()
.id('HTTP_CODE:{{ index .Tags "app" }}')
.message('')
.crit(lambda: "code_match" == 0)
.log('/tmp/alerts.log')
```
### test data
```
i1=(1 1 0 1 0 1 1 1 1 1)
```
### result:
```
window level duration
1,1,0 "CRITICAL" 0
1,1,0,1 "CRITICAL" 0
1,0,1,0 "CRITICAL" 0
0,1,0,1 "CRITICAL" 0
1,0,1,1 "CRITICAL" 2034708173
0,1,1,1 "CRITICAL" 2034708173
1,1,1,1 "OK" 7107346394
```
with windows, if one bad value came in window, kapacitor will trigger immediately and until all bad value leave
## 2. with windows and all()
```
var win = 5s
var origin = stream
|from()
.database('test')
.retentionPolicy('default')
.measurement('ka')
.groupBy('app')
origin
|window()
.period(win)
.every(1s)
|alert()
.id('HTTP_CODE:{{ index .Tags "app" }}')
.message('')
.all()
.crit(lambda: "code_match" == 0)
.log('/tmp/alerts.log')
.all()
```
### test data
```
i1=(1 0 0 0 0 1 1 1 1 1 0 1 1)
```
### result
```
windows level duration
0,0,0,0 "CRITICAL" 0
0,0,0,1 "OK" 1022011392
```
with window and all(), kapacitor will trigger when all point in window is 0, but if one 1 enter in window ,trigger OK immediately
## Hysteresis in Zabbix
description: Sometimes a trigger must have different conditions for different states. For example, we would like to define a trigger which would become PROBLEM when server room temperature is higher than 20C while it should stay in the state until temperature will not become lower than 15C.
I want to get alert like zabbix hystereis, Is there any way to do it?
As a example, if I have some test point:
```
i1=(1 0 0 0 0 1 0 1 1 1 1 1)
```
I want result like this:
```
1,0,0,0 no trigger
0,0,0,0 "CRITICAL"
0,0,0,1 "CRITICAL"
0,0,1,0 "CRITICAL"
0,1,0,1 "CRITICAL"
1,0,1,1 "CRITICAL"
0,1,1,1 "CRITICAL"
1,1,1,1 "OK"
```
furthermore, if I want to let trigger stay in CRITICAL until all point is 1 in `2*window` times, is there any way to realize?
Contributor guide
Research direction
Start by reproducing the reported behavior with the window() and alert() pipeline, including .all() and .crit(), using the supplied test sequences. Trace how alert state changes as windows advance, then define a hysteresis behavior that matches the requested CRITICAL and OK transitions, including the 2*window recovery case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- observability-sre
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100