I created a custom panel plugin (TypeScript + React) that get data from ElasticSearch to monitor our systems. The plugin with custom logic (based on data) shows the state of the systems.
Now I would like to send an email to a SMS gateway (or even to voice gateway). That just means send an email to a specific email address with phone numbers in the subject and a body with a specific format.
As far as I know Grafana can send an email via alerts that are linked with some graph panel and some threshold. I don’t have any of that.
Is there a way to send (trigger via code) an email when my panel logic detects an error/warning? Do I have to write the sending logic (in the panel) myself with some nodeJS lib (without grafana) or is there some other way?
What I end up doing is to make an NodeJS app backend that sends emails using nodemailer lib as this can’t be part of the frontend (Grafana panel).
This nodeJS server runs alongside Grafana on the same virtual machine. I used Express lib to expose an endpoint to Grafana.
So from the custom Grafana panel I just have to send a POST request to
localhost:port/api/sendEmail along with some json data to be used for the subject and body
The dependencies that I used
“@types/express”: “^4.17.13”,
“@types/node”: “^17.0.22”,
“@types/nodemailer”: “^6.4.4”,
“express”: “^4.17.3”,
“nodemailer”: “^6.7.3”,
“ts-node”: “^10.7.0”,
“typescript”: “^4.6.2”
@marcusolsson
if I call an API (axios) to send an email (node backend) from the panel (custom plugin code) does that mean that the email will be sent only when the panel is rendered (i.e. when someone has the dashboard open)? I want that an email is sent automatically when some criteria is met (based on grafana data that comes from ElasticSearch).
Is this more suitable for a Grafana backend plugin?