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.