Grafana alerts are useful since they tell you about the problems in your system moments after they occur. Which in turn results in quickly resolving the issue. Also reducing the disruption time of the service.
Main components of Alerts
- Alerting rule– This consists of one or more query/expression, a condition, the frequency of evaluation. Also the duration (optional) that a condition must met for the alert.
- Contact point – It is the channel for sending notifications when the conditions for an alert met.
- Notification policy – A set of matching and grouping criteria. Which determine where to send notifications. And how frequently to send them.
- Silences – Date and matching criteria used to silence notifications.
We know grafana is a popular tool to analyse and visualize data and alert.
- It combines with a wide variety of data sources, including PostgreSQL, Elasticsearch, MongoDB, Github, and even Google Sheets.
- It is used by Booking, Stack Overflow, eBay, Red Hat and many more.
A notification channel is a way through which you can be notified by Grafana, such as email, slack .You can find the list below-
To create a notification channel, follow these steps:
- In the Grafana side bar, hover your cursor over the Alerting (bell) icon and select Notification channels.
- Click on Add channel.
- Fill the fields as you like or select options as described below.
- Name – Enter a name for the channel. When users add notifications to alert rules they can see the name.
- Type – Select the channel type.
- Default (send on all alerts) – This option will send notification on the channel for all alert rules.
- Include Image– Grafana can render the panel associated with the alert rule as a PNG image and include the same in notification
- Disable Resolve Message – This option disables the resolve message.
- Send reminders – This will send additional information for triggered alerts. You can specify how often reminders should be sent using number of seconds (s), minutes (m) or hours (h), for example
Add alerts to your panels
The basics of alert customization-
- Conditions: The metrics will be alerting when the condition(s) is TRUE.
- Notifications: Select the notification channel where you want to send the alert message.
- Message: To add some extra information to your alert message.
- Rule: “Evaluate every” is the frequency in which alert condition is checked. “For” is the waiting duration before sending an alert, 0m means disabled.
- Moreover in the query section we define the metric for which we want to add the alert. Moreover we can also specify a range.
- Meanwhile query section looks like
query(metricName, start, end)and
query(A, 1m, now)which signifies it will work on metric A. And will check the range from 1 minute ago to now. A signifies the name of the metric.
- For instance
lastfunction picks the latest value in the range. The query picks up data from 1 minute ago to now.
- There are multiple conditions we can work on like last, avg , min etc.
Being one of the most popular monitoring tools, Grafana is extremely beneficial tool with great visuals. It lets you monitor and manage the alerts of various technologies in one place. It’s easy to learn and use. Also it is integrated with alerts which make it more popular. Therefore it is used in most of the companies.