influxdata / influxdata/kapacitor

Kapacitor get tag value for influxdb series

Open
#2,727 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
2.4k
Forks
479
Avg merge
4d 16h
Merged PRs (30d)
4

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the alert().exec() call with the shown queryFlux and template expression, then trace how Kapacitor handles templates for alert execution and tag values. The issue is done when the documented or corrected approach passes the requested tag value, such as “A”, to the Python script instead of the literal template text.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
observability
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.