Need the Grafana slack monitoring alert? Let’s create it now.

Reading Time: 3 minutes

In my previous blog, we created the first Grafana dashboard. Now in this blog, we will create our first monitoring Grafana alert.

Before creating monitoring alerts, we need to add the notification channel through which we will be notified. Here, we will be adding slack as the notification channel.

Slack notification channel:

First, open the URL http://localhost:3000 in the browser and log in to the Grafana. Then click on the “Notification Channels” option at the left-hand side.

notification_option

Then click on “Add Channel” button and you will get the following screen:

slack_alert

Then, select the Slack from Type field and provide the Slack webhook URL. (Other fields are not mandatory). We can set up other alerts as well by selecting the option from Type field. For slack webhook URL, please see the guide here.

Few key points:

  • If you want to add this channel to all the alerts by default then tick the checkbox for “Send on all alerts”.
  • If you want reminders then tick the checkbox for “Send reminders” and reminder frequency time.

You can test the setup by clicking on “Send Test” button at the bottom.  After setting up all the fields, just click on the Save button. For more details, check out here.

Now let’s create the alert.

Go to Dashboard → Manage →  (Please find these options at left-hand side). Click on Dashboard Edit to set alerts:

edit_dashboard

Go to the Alert section of the dashboard and create an alert there:

alert_section

In alert section, Set the Alert Config and Notification as per the requirement.

alert config:

alert-config

In alert config, we need to add the conditions. We can add multiple conditions here. We need to use either AND or OR to make the relationship between multiple conditions.

As a condition, we get only 5 options:

  • IS ABOVE
  • IS BELOW
  • IS OUTSIDE RANGE
  • IS WITHIN RANGE
  • HAS NO VALUE

You will find “Evaluate every” option there which takes 2 values:

  1. every: Within how many seconds/minutes conditions need to be evaluated
  2. for: For how long the condition needs to be evaluated.

For ex: Evaluate every 20s for 40s.

It means conditions will be evaluated in every 20 seconds but for 40 seconds. It means it will be evaluated 2 times.

Alert is having 3 states:

  • OK: When the overall value of conditions are false
  • Pending: When the overall value of conditions is true
  • Alerting: When the overall value of condition is true continuously until the value of for.

If we take the above example then it will go in alerting mode when the conditions get true for continuous 40 seconds.

notification:

alert_message

Here, we add the notification channel where alert needs to be sent and the alert message. For more details, check out here.

That’s it. I hope, it will be helpful for you and you will be able to create your first alert easily.

References:

https://grafana.com/docs/alerting/rules/

https://grafana.com/docs/alerting/notifications/

Knoldus-blog-footer-image

Written by 

Rishi is a Lead Consultant, with experience of more than 7 years. Rishi is product focused developer who loves developing both front-end user interfaces and scalable back-end infrastructure. He is a good team player, quick learner and a humble person. He has good time management skills, aimed to give best results and fully dedicated towards his work & responsibilities. He is able to work as individual and as well as in team. He loves to share his knowledge, therefore he often writes technical blogs.

Knoldus Pune Careers - Hiring Freshers

Get a head start on your career at Knoldus. Join us!