How to send tags and fields as parameters to an .exec property in alert node

Hi all,

I was wondering whether it is possible to use values of tags or fields to send them to a .exec() property of an alert node, as part of arguments to the script you are calling.

Given this portion of a tick script

.id(’{{ index .Tags “Site” }}-{{ index .Tags “host” }}’)
.message(‘Origin cache hit ratio lower than 40% for the past 10 minutes ‘)
.warn(lambda: “chr” < warn AND !(hour(“time”) >= 2 AND hour(“time”) <= 6))
.exec(’/opt/influx/bin/tick/’, ‘{{ index .Tags “Site” }}’, ‘{{ index .Tags “host” }}’)

The script accepts two parameters as an input. The problem I’m facing is that it executes but it’s taking the string values instead of the tag value.

Have you ever come accross this issue? Do you know if the .exec() property works like this?

Thanks in advance

Those values are automatically sent in in JSON format over stdin. Just read from stdin into a variable, parse the JSON and you will have your tags. Below is an excerpt in Python.

#!/usr/bin/env python
import sys
import json
alert_data = json.loads(
level = alert_data["level"]
if level == "CRITICAL":
    host_name = alert_data["data"]["series"][0]["tags"]["host"]