influxdata / influxdata/kapacitor
Unable to use logical operator (OR) on lambda whereFilter
- Dominant language
- Go
- Stars
- 2.4k
- Forks
- 479
- Avg merge
- 4d 16h
- Merged PRs (30d)
- 4
Description
Hi there,
I've a working deadman alert generated through the wizard, but when I add another server to the alert it stop working.
Working
...
var whereFilter = lambda: ("host" == 'dev-mongodb-n1' )
...
Not Working
...
var whereFilter = lambda: ("host" == 'dev-mongodb-n1' OR "host" == 'dev-mongodb-n2')
...
Is it possible to use wildcards instead ?
Thanks in advance!
**Full Code**
var db = 'telegraf'
var rp = 'autogen'
var measurement = 'procstat'
var groupBy = []
var whereFilter = lambda: ("host" == 'dev-mongodb-slave-2')
var period = 1m
var name = 'mongod-process-is-not-running'
var idVar = name
var message = 'TEST! DEV {{.Level}}: {{.ID}} from {{.Time}}'
var idTag = 'alertID'
var levelTag = 'level'
var messageField = 'message'
var durationField = 'duration'
var outputDB = 'chronograf'
var outputRP = 'autogen'
var outputMeasurement = 'alerts'
var triggerType = 'deadman'
var threshold = 0.0
var data = stream
|from()
.database(db)
.retentionPolicy(rp)
.measurement(measurement)
.groupBy(groupBy)
.where(whereFilter)
var trigger = data
|deadman(threshold, period)
.stateChangesOnly()
.message(message)
.id(idVar)
.idTag(idTag)
.levelTag(levelTag)
.messageField(messageField)
.durationField(durationField)
.opsGenie2()
.teams()
.recipients()
trigger
|eval(lambda: "emitted")
.as('value')
.keep('value', messageField, durationField)
|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
Research direction
Start with the whereFilter lambda in the full TICKscript and reproduce the difference between the single-host predicate and the predicate using OR. Trace how the deadman alert handles the multi-host filter; done means the intended host selection works reliably, with the supported wildcard behavior clarified if applicable.
Written by the indexing model from the issue text.
Assessment
- Domain
- observability
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100