Hi,
I would like Alerts on InfluxDB to trigger a local Python script (that will send me an email alert via Gmail). How can this be done easily? It looks like Alerts expect an HTTP end-point?
Hi,
I would like Alerts on InfluxDB to trigger a local Python script (that will send me an email alert via Gmail). How can this be done easily? It looks like Alerts expect an HTTP end-point?
I use Node-RED for this.
InfluxDB Alert → webhook received by Node-RED (running on same machine) → when webhook is received, send email (or run your Python script, turn on a light or siren, etc.). Node-RED can basically do anything (except make breakfast).
Thank you @grant1!
I have installed Node-RED indeed, and it’s working fine now without even calling Python (I had never used Node-RED before so there was a learning curve!).
Here is my code in the “Function” node:
> var newData = JSON.stringify(msg.payload);
> var o = JSON.parse(newData);
>
> // set email subject
> msg.topic = "Alert from InfluxDB monitoring via Node-RED (" + o.host + ")";
>
> // HTML email body
> msg.payload = "<b>Host:</b> " + o.host
> + "<br><b>Check performed:</b> " + o["_check_name"]
> + "<br><b>Status:</b> " + o["_level"]
> + "<br><b>Type of check:</b> " + o["_type"]
> + "<br><b>Time of alert:</b> " + o["_time"];
>
> return msg;
Awesome news! Thanks for sharing.
Besides using the webhook routine that I mentioned previously, I use Node-RED for dozens of tasks, such as:
I am planning to make an InfluxDB backup node (for v2+) where one can specify the path, token, frequency, etc. and the backup will be done per those settings.