With the release of Grafana 4.0 came with Alerting! When its come to monitoring alerting is playing major role, but with open source its was limited or some restriction on place always. Here is New Alerting tool from Grafana which widely used for visualization now a days. Lets see how to setup a alerting..!!
Configuring Grafana for Alerting
There are several ways to receive alerts with Grafana – email, Slack, PagerDuty, Telegram and webhook etc… In this post will will demonstrate alerting through email. Please note that for this to work correctly, SMTP settings must be configured in the Grafana config file, which is located inside your docker container. To enter the Docker container, use the Container ID of the running container. Get the container ID from “# docker ps”. Once you have the container ID, enter into Docker shell by using the command
# docker exec -it CONTAINER_ID /bin/bash
From this terminal, you can access the /etc/grafana/grafana.ini configuration file. Sample Documentation for the configuration file can be found on Grafana’s website.
[smtp] enabled = true host = Servername:port user = "<<UserName>>" password = "XXXXYYYYY" ;cert_file = ;key_file = skip_verify = true from_address = "firstname.lastname@example.org" from_name = Grafana [emails] welcome_email_on_sign_up = false templates_pattern = emails/*.html
Below is a basic, default configuration setting for the SMTP/email section for testing purposes that works for Gmail:
Once you have made changes to the config file, you can restart grafana container to pick up the changes with
# docker restart grafana_containerID
Once you restart the docker container, access the Alert Notification panel by selecting the Grafana icon dropdown in the upper left corner of any Grafana dashboard:
To set up alerting, you need to create an alert notification on this page. You can enter multiple email addresses using a “;” separator
Testing the Configuration
You can test your server’s configuration by clicking the “Send Test” button.
You’ll know that you configured this correctly when you receive the following email:
Enabling Alerting for a Variable
Now that you’ve updated your Grafana config file and tested to ensure your SMTP settings are correct, it’s time to set up an alert for a specific variable. To do that, go the dashboard for which you’re interested in setting up alerting:
- Click the title
- Select “Edit”
- Choose the Alert tab
- Select the “Create Alert” button. In the Alert Config section, you can modify the frequency at which the alert checks for a trigger and the conditions to trigger the alert.
Currently, a known limitation exists with Grafana. Alerting doesn’t support template variables yet. However, there is a feature request on Github to add this functionality in the future. Because of this, template variables must be removed from the Metrics tab of the dashboard you are editing.
Grafana sends an alert email whenever the configured threshold gets passed
Once an alert clears, you will get an all clear email.
Sample Slack Alert Setup