Want to make and api call in kapacitor tick script to fetch email based on tags of kapacitor output

Hello All,
I have successfully implemented a cpu alert with kapacitor.
tick script below

dbrp “telegraf”.“autogen”

batch
|query(‘SELECT mean(usage_system) as usage_system from “telegraf”.“autogen”.“cpu” where customer = ‘customer’’)
.groupBy(‘host’, time(1m))
.period(5m)
.every(2m)
|alert()
.warn(lambda: “usage_system” > 90)
.warnReset(lambda: “usage_system” < 90)
.crit(lambda: “usage_system” > 95)
.critReset(lambda: “usage_system” < 95)
.message(’{{ index .Tags “host” }} has {{ index .Fields “usage_system” | printf “%.2f” }}% cpu usage’)
.topic(‘cpu’)
.email()
.to(‘xyz@gmail.com’)

I want to implement a script in between .email() and .to() functions.
the script will trigger an api call based on the host of the alert output and send output to the mail address which matches host in api.

can we implement this in kapacitor,
I can handle the script to make the API call based upon the output of kapacitor script. Is there a way to fetch the output of kapacitor sctipt in the tick script itself so that i can use that output to run a script using the .exec() function and print the email output so that kapacitor can send an email alert to that email instead of statically giving an email.

While I have no experience with this function, I think you might want to take a look at the sideload() command to fetch a local configuration file. It can’t call external APIs at this time.

If you truly want to call a remote API to fetch data, I think your best bet is a UDF.

can i just print the output of the kapacitor triggered alert

@srikanthvamaraju were you able to make this work based tags?