Companies use various Dashboards, charts, and other visualization tools to monitor their infrastructure and log analytics. As data grows, it becomes essential for companies to get an overview of data. Many Visualisation tools are available in the market, but still, many companies don’t want to load data to 3rd party vendors for privacy. 

Grafana is an open-source visualization and analytics software that can seamlessly query data no matter where it is stored. Companies use Grafana for visualizing and exploring datasets. Using open-source software like Grafana provides flexibility and allows developers to build plugins from scratch. Grafana can easily integrate with other external data sources using Grafna Webhooks.

Introduction to Grafana

Grafana Logo

Grafana is an open-source tool built to run Data Analytics, extract Key Performance Indicators from the data, and monitor the apps with the help of a dashboard. Grafana has a variety of connections available to connect various data sources like Graphite, Elastic Search, MySQL, PostgreSQL, etc.

Grafana is an open-source tool, and it allows users to build plugins that connect to data sources from scratch, thereby making Grafana a fully customizable tool. It helps the user analyze and monitor data over time and performs time-series analytics on the data.

Introduction to Webhooks

Webhooks Logo

Webhooks are the ways of communicating between two apps by sending notifications or alerts when something happens. There are several use-cases when webhooks are very helpful. Some examples are listed below: 

  • Notification E-Mail from Paypal alerts you when the client pays you.
  • In Bitbucket, every time a user pushes commits in a repository, you can use Webhooks to instantiate the CI pipeline.
  • Sending success/failure E-Mails when the build passes/fails.

Webhooks are event-driven systems, which means it becomes active only when the desired event happens, and they are restricted to communicate over web protocol-HTTP.

Steps to Set Up Grafana Webhooks Integration for Alerts

Now that we have a basic understanding of Grafana Webhook. In this section, you will learn the steps to how to integrate Grafana Webhooks. The steps for Grafana Webhooks are listed below:

Step 1: Adding a Notification Channel

  • Log in to the Grafana console, and on the sidebar, click on Alerting (bell) icon and click Notification channels.
  • Click on Add Channel and select the available options to configure alerts.
Grafana Webhooks - Adding Channel

Step 2: Configuring Notification Channel Fields

  • On the next page, provide the Name of the Notification alerts that you want to create.
  • From the Type section, select the available and supported notifiers. The supported notifiers are listed below:
NameType
DingDingdingding
Discorddiscord
Emailemail
Google Hangouts Chatgooglechat
Hipchathipchat
Kafkakafka
Lineline
Microsoft Teamsteams
Opsgenieopsgenie
Pagerdutypagerduty
Prometheus Alertmanagerprometheus-alertmanager
Pushoverpushover
Sensusensu
Sensu Gosensugo
Slackslack
Telegramtelegram
Threemathreema
VictorOpsvictorops
Webhookwebhook
  • To create Grafana Webhook, Select the Type as Webhook and fill out the form, as shown in the image below.
Grafana Webhooks - Selecting type of Webhook
  • Following is the JSON body for the Grafana Webhook Integration
{
  "dashboardId": 1,
  "evalMatches": [
    {
      "value": 1,
      "metric": "Count",
      "tags": {}
    }
  ],
  "imageUrl": "https://grafana.com/assets/img/blog/mixed_styles.png",
  "message": "Notification Message",
  "orgId": 1,
  "panelId": 2,
  "ruleId": 1,
  "ruleName": "Panel Title alert",
  "ruleUrl": "http://localhost:3000/d/hZ7BuVbWz/test-dashboard?fullscreenu0026editu0026tab=alertu0026panelId=2u0026orgId=1",
  "state": "alerting",
  "tags": {
    "tag name": "tag value"
  },
  "title": "[Alerting] Panel Title alert"
}
  • Once done, click on Save and then click on Test to verify the configurations.
  • Once the test is successful, click on Manage from the left navigation panel.
  • Click on the existing dashboard to add Alerts and rules.
  • Select the Create Alert tab and then click on the Create Alert button.
  • In the Notification section, click the + sign and add the notification channel you have created under Send to.
  • Click Save to save the rules and alerts. 

That’s it, you have completed the Grafana Webhook Integrations alerts on the Dashboard. Now when any changes happen on Dashboard will be notified to the users.

Popular Notification Triggers Using Grafana Webhooks

In Grafana, there are several supported triggers available. However, in this article, you will go through a few Grafana Webhooks Triggers. A few notification triggers using Grafana Webhooks are listed below:

E-Mail

  • To set up E-Mail notifications, first, we need to set up the SMTP configurations in Grafana. In Windows, the configuration file will be at – $WORKING_DIR/conf/defaults.ini, and in macOS, the files will be at – /usr/local/etc/grafana/grafana.ini
  • Add the following configurations to the configuration file. Update the <section> with your configurations.
######### SMTP / Emailing #######
[smtp]
;enabled = true
;host = smtp-mail.outlook.com:587 #Port 25(Without TLS/SSL) 
;user = <email-address>
;password = """<Your-Password>"""
;cert_file =
;key_file =
;skip_verify = true
;from_address = <email-address>
;from_name = <Your-Name>
;ehlo_identity =

[emails]
;welcome_email_on_sign_up = false
;templates_pattern = emails/*.html
  • On the Grafana Alerting page, select the Type – E-Mail, add other relevant information, and click on Save.
  • Click on Send Test to test the connection.

That’s it, and you have successfully configured the Grafana Webhook E-Mail Alerts. Now at every event, Grafana Webhook will send an E-Mail to the specified E-Mail addresses.

Kafka

  • You need to set up Kafka REST Proxy endpoint for Kafka Grafana Webhook. To set up Kafka REST Proxy endpoint, refer to the official Confluent Kafka Blog.
  • Once you set up the Kafka successfully, create a Topic that will accept the incoming notifications/alerts from the Grafana.
  • Once the above two properties are set, on the Grafana create alerts page, select the Type as Kafka and provide other necessary information like REST endpoint, Topic name, authentication credentials to set up the Grafana Webhook, as shown in the image below.
Grafana Webhooks - Choosing Kafka Webhooks

Discord

  • To set up the Discord channel Webhook, first, you need to create the Discord channel.
  • To set up a Discord channel, Open the server settings and look for Integration Tab.
  • On the Integration tab, click on Create Webhook to create a new Webhook, as shown in the image below.
Grafana Webhooks - Integrations option in Discord
  • On the next page, you will get several options like changing the Avatar, its Name, and the channel where the Webhook will post the notifications, as shown in the image below.
Grafana Webhooks - Creating Discord Webhook
  • Fill in the required information and then click on Copy Webhook URL to copy the URL.
  • Once you have the Webhook URL, add the URL and necessary credentials to Grafana, and your Grafana Webhook will be ready. 
  • Any updates will be pushed to the Discord channel automatically. 

Conclusion

  • In this article, you read about Grafana which is an open-source Data Analytics tool, Webhooks, and how to integrate Grafana Webhooks along with several supported notification channels.
  • Companies use Grafan to analyze and visualize data that saves cost and is a flexible solution for companies that have to preserve the privacy of data.
  • Customizable Dashboards, charts, graphs need data in an analysis-ready form that can be delivered via Data Warehouses. Manually loading data from multiple sources to Data Warehouse is a tedious process. 

Share your experience of learning about Grafana Webhook Integration in the comments section below!

Vishal Agrawal
Technical Content Writer, Hevo Data

Vishal Agarwal is a Data Engineer with 10+ years of experience in the data field. He has designed scalable and efficient data solutions, and his expertise lies in AWS, Azure, Spark, GCP, SQL, Python, and other related technologies. By combining his passion for writing and the knowledge he has acquired over the years, he wishes to help data practitioners solve the day-to-day challenges they face in data engineering. In his article, Vishal applies his analytical thinking and problem-solving approaches to untangle the intricacies of data integration and analysis.

No-code Data Pipeline For your Data Warehouse