influxdata / influxdata/kapacitor

How can we pass a variable to the alert.exec() property?

Open
#1,560 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
2.4k
Forks
479
Avg merge
4d 16h
Merged PRs (30d)
4

Description

Hi,

I have a bash script I execute when an alert is triggered as define in this TICKscript:

```
var key = 'battery:capacity'

stream
|from()
.measurement('battery')
|eval(lambda: string("value"))
.as('power')
|alert()
.id('{{ .Name }}/{{ .Group }}')
.message('hello there')
.crit(lambda: "value" < 0.05)
.log('/tmp/alerts.log')
.exec('alert.sh', key, power)
```

I want to pass the 'power' as defined in the eval node, as an argument to the bash script. However when I try to register the TICKscript with the following command:

`kapacitor define alert -type stream -tick alert.tick -dbrp database_name`

I get the following error:

`invalid TICKscript: name "power" is undefined. Names in scope: stream,key,time`

Is there any way to pass down the 'power' value?

Many thanks.

Contributor guide

Open the contributing guide

Research direction

Start with the alert.exec() and eval nodes in alert.tick, then reproduce the scope error with the shown kapacitor define command. Determine whether the evaluated power value can be passed to alert.sh as an exec argument; done means a supported invocation is identified or the limitation is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash
Domain
observability
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.