Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kapacitor get tag value for influxdb series #2727

Open
pratikdas44 opened this issue Oct 14, 2022 · 1 comment
Open

Kapacitor get tag value for influxdb series #2727

pratikdas44 opened this issue Oct 14, 2022 · 1 comment

Comments

@pratikdas44
Copy link

Hi, I am using Tickscript and my purpose is to run the python script if the value is 0. Below is my code:
`var data = batch
|queryFlux('''
from(bucket: "bucket_name")
|> range(start: -3h)
|> filter(fn: (r) => r["_measurement"] == "measurement_name")
|> filter(fn: (r) => r["_field"] == "field_name")
|> filter(fn: (r) => r["_value"] > 0)
|> truncateTimeColumn(unit: 1h)
''')
.org('org_name')
.period(190m)
.every(30m)

var alert = data
|alert()
.crit(lambda: "_value" > 0)
.exec('python3', 'python-file-location', '--node', '{{ index .Fields "_value" }}')`

I was trying to use template and pass a random parameter, However I am getting “{{ index .Fields “_value” }}” in python file instead of some actual string. My requirement is to pass value of tag column say “A” as an argument to python file. How can I get that value.

@izenn
Copy link

izenn commented Mar 30, 2023

have you tried setting what you want to send as a variable? (i've noticed some weird things when using {{ something }})
var value = '{{ index .Fields "_value" }}'

and then change your exec line to:
.exec('python3', 'python-file-location', '--node', "value")
(not sure if you need the quotes around value)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants