influxdata / influxdata/kapacitor
TickScript deadman groupby nil value
- Dominant language
- Go
- Stars
- 2.4k
- Forks
- 479
- Avg merge
- 4d 16h
- Merged PRs (30d)
- 4
Description
Hi all, I have a strange problem with the deadman type alert. I defined a groupby condition on a tag that by the time the script is deployed the data hasn't arrived yet, so a "nil" error is thrown. Is there a way to ignore when the bucket is empty and not throw this kind of error?
This is the current script:
```
var db = 'test-db'
var rp = 'test-rp'
var measurement = 'my-test'
var groupBy = ['unique-field']
var whereFilter = lambda: ("condition" == 'false') AND ("description" == 'my-desc')
var period = 1m
var name = 'Dead-unique'
var idVar = name + '-{{.Group}}'
var message = ''
var idTag = 'alertID'
var levelTag = 'level'
var messageField = 'message'
var durationField = 'duration'
var outputDB = 'alarms-db'
var outputRP = 'alarms-rp'
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)
.message(message)
.id(idVar)
.idTag(idTag)
.levelTag(levelTag)
.messageField(messageField)
.durationField(durationField)
.stateChangesOnly()
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')
```
and this is the error with nil value:
```JSON
{
"id": "Dead-unique-nil",
"message": "",
"details": "....",
"duration": 0,
"level": "CRITICAL",
"data": {
"series": [
{
"name": "stats",
"columns": [
"time",
"emitted"
],
"values": [
[
"2023-03-13T11:01:00Z",
0
]
]
}
]
},
"previousLevel": "OK",
"recoverable": true
}
```
Contributor guide
Research direction
Start by reproducing the supplied TickScript with an empty group-by tag, focusing on the from().groupBy() and deadman() entry points. Determine whether a nil group can be ignored without changing alert output, then verify that deployment succeeds and no Dead-unique-nil alert is emitted for the empty bucket.
Written by the indexing model from the issue text.
Assessment
- Domain
- observability-sre
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100