influxdata / influxdata/kapacitor
Convert Node type to string
- Dominant language
- Go
- Stars
- 2.4k
- Forks
- 479
- Avg merge
- 4d 16h
- Merged PRs (30d)
- 4
Description
Is there a possibility to convert any Node type to string?
One of the usage examples is to dynamically set topics or notification teams.
Here is non working example of tick script
```
var name = 'system.load'
var warn = 75
var crit = 100
var period = 30s
var every = 10s
var idVar = name + ':{{.Group}}'
var idTag = 'alertID'
var outputDB = 'chronograf'
var outputRP = 'autogen'
var outputMeasurement = 'alerts'
var messageField = 'message'
var durationField = 'duration'
var triggerType = 'threshold'
var data = batch
|query('''SELECT "load1" / "n_cpus" * 100 AS value FROM "telegraf"."autogen"."system"''')
.period(period)
.every(every)
.groupBy('host')
var trigger = data
|alert()
.id(idVar)
.idTag(idTag)
.levelTag('level')
.messageField(messageField)
.durationField(durationField)
.message('{{ .Level }} - ' + name + '/{{ index .Tags "host" }}: Load average for last 5 minutes is {{ index .Fields "value" | printf "%0.2f" }}%')
.warn(lambda: "value" > warn)
.crit(lambda: "value" > crit)
.slack()
.opsGenie2().teams("team")
.stateChangesOnly()
|eval(lambda: strReplace("host", '/', '.', -1))
.as('host')
.tags('host')
.keep('value')
trigger
|influxDBOut()
.create()
.database(outputDB)
.retentionPolicy(outputRP)
.measurement(outputMeasurement)
.tag('alertName', name)
.tag('triggerType', triggerType)
```
Kapacitor errors with
```
invalid TICKscript: line 34 char 22: cannot assign *ast.ReferenceNode to type string, did you use double quotes instead of single quotes?
```
Contributor guide
Research direction
Start with Kapacitor's TICKscript type-checking and the handling of alert().teams(), using the reported line 34 error and the ReferenceNode-to-string mismatch as entry points. Determine the intended conversion behavior for Node values, then verify that the supplied dynamic team or topic example validates successfully.
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
- 30/100