You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: Get started with Grafana Alerting by creating your first alert in just a few minutes. Learn how to set up an alert, send alert notifications to a public webhook, and generate sample data to observe your alert in action.
8
+
id: alerting-get-started
9
+
labels:
10
+
products:
11
+
- enterprise
12
+
- oss
13
+
- cloud
14
+
tags:
15
+
- beginner
16
+
title: Get started with Grafana Alerting
17
+
weight: 50
18
+
---
19
+
20
+
# Get Started with Grafana Alerting
2
21
3
22
In this guide, we'll walk you through the process of setting up your first alert in just a few minutes. You'll witness your alert in action with real-time data, as well as sending alert notifications.
4
23
@@ -7,7 +26,7 @@ In this tutorial you will:
7
26
- Set up an Alert
8
27
- Send an alert notification to a public webhook.
9
28
10
-
# Before you begin
29
+
##Before you begin
11
30
12
31
Ensure you have the following applications installed.
13
32
@@ -22,27 +41,27 @@ Download the files to your local machine.
22
41
23
42
1. Clone the [tutorial environment repository](www.github.com/grafana/tutorial-environment).
1. Change to the directory where you cloned the repository:
30
49
31
-
```
50
+
```promql
32
51
cd tutorial-environment
33
52
```
34
53
35
54
1. Make sure Docker is running:
36
55
37
-
```
56
+
```promql
38
57
docker --version
39
58
```
40
59
41
60
This command will display the installed Docker version if the installation was successful.
42
61
43
62
1. Start the sample application:
44
63
45
-
```
64
+
```promql
46
65
docker compose up -d
47
66
```
48
67
@@ -54,15 +73,15 @@ Download the files to your local machine.
54
73
55
74
1. Ensure all services are up-and-running:
56
75
57
-
```
76
+
```promql
58
77
docker compose ps
59
78
```
60
79
61
80
In the State column, it should say Up for all services.
62
81
63
82
The Grafana News app should be live on [localhost:8081](http://localhost:8081/).
64
83
65
-
## Generate data
84
+
###Generate data
66
85
67
86
To enhance the hands-on aspect of this tutorial, you can actively participate in the Grafana News application to simulate web traffic and interactions. This enables you to observe data within Grafana and set up alerts accordingly.
68
87
@@ -78,18 +97,15 @@ To add a link:
78
97
The link will appear listed under the Grafana News heading.
79
98
1. To vote for a link, click the triangle icon next to the name of the link.
80
99
81
-
## Log in to Grafana
100
+
## Create a contact point for Grafana Managed Alerts
82
101
83
102
Besides being an open-source observability tool, Grafana has its own built-in alerting service. This means that you can receive notifications whenever there is an event of interest in your data, and even see these events graphed in your visualizations.
84
103
85
-
In your browser, navigate to [localhost:3000](http://localhost:3000).
86
-
You should get logged in automatically
87
-
88
-
## Create a contact point for Grafana Managed Alerts
89
-
90
104
In this step, we'll set up a new contact point. This contact point will use the _webhooks_ channel. In order to make this work, we also need an endpoint for our webhook channel to receive the alert. We will use [requestbin.com](https://requestbin.com) to quickly set up that test endpoint. This way we can make sure that our alert is actually sending a notification somewhere.
91
105
92
-
1. Browse to [requestbin.com](https://requestbin.com).
106
+
1. In your browser, navigate to [localhost:3000](http://localhost:3000), where Grafana is running.
107
+
You should get logged in automatically.
108
+
1. In another window, go to [requestbin.com](https://requestbin.com).
93
109
1. Under the **Create Request Bin** button, click the link to create a **public bin** instead.
94
110
1. From Request Bin, copy the endpoint URL.
95
111
@@ -115,9 +131,8 @@ Next, we'll establish an alert within Grafana Alerting to notify us whenever our
115
131
116
132
In Grafana, **navigate to Alerting** > **Alert rules**. Click on **New alert rule**.
117
133
118
-
## Enter alert rule name
119
-
120
-
1. Make it short and descriptive as this will appear in your alert notification. For instance, **server-requests-duration**
134
+
1. Enter alert rule name
135
+
Make it short and descriptive as this will appear in your alert notification. For instance, **server-requests-duration**
121
136
122
137
## Define query and alert condition
123
138
@@ -130,24 +145,25 @@ In this section, we define queries, expressions (used to manipulate the data), a
130
145
{{< /admonition >}}
131
146
132
147
1. In the Query editor, switch to **Code** mode by clicking the button at the right.
This [PromQL](https://prometheus.io/docs/prometheus/latest/querying/basics/) query calculates the sum of the per-second average rates of increase of the `tns_request_duration_seconds_count` metric over the last 1 minute, grouped by the HTTP method used in the requests. This can be useful for analyzing the request duration trends for different HTTP methods.
140
155
141
156
1. Keep expressions “B” and “C” as they are. These expressions (**Reduce** and **Threshold**, respectively) come by default when creating a new rule.
157
+
142
158
The Reduce expression “B”, selects the last value of our query “A”, while the Threshold expression “C” will check if the last value from expression “B” is above a specific value. In addition, the Threshold expression is the alert condition by default. Enter `0.2` as threshold value. You can read more about queries and conditions [here](https://grafana.com/docs/grafana/latest/alerting/fundamentals/alert-rules/queries-conditions/#expression-queries).
143
159
144
160
1. Click Preview to run the queries.
145
161
146
-
You should see the request duration for different HTTP methods.
162
+
You should see the request duration for different HTTP methods.
147
163
148
-
{{<admonitiontype="note">}}
149
-
If it returns “No data,” or an error, you are welcome to post questions in our [Grafana Community forum](https://community.grafana.com/).
150
-
{{</admonition>}}
164
+
{{<admonitiontype="note">}}
165
+
If it returns “No data,” or an error, you are welcome to post questions in our [Grafana Community forum](https://community.grafana.com/).
166
+
{{</admonition>}}
151
167
152
168
## Set evaluation behavior
153
169
@@ -164,23 +180,19 @@ An evaluation group defines an evaluation interval - how often a rule is checked
164
180
165
181
Add labels to ease searching or route notifications to a policy.
166
182
167
-
### Labels
168
-
169
-
1. Add `app` as the label key, and `grafana-news` as the value
170
-
171
-
### Notifications
172
-
173
-
Select who should receive a notification when an alert rule fires.
183
+
1. Add a label.
184
+
Add `app` as the label key, and `grafana-news` as the value.
174
185
175
-
1. Under **Contact point**, select **RequestBin** from the drop-down menu.
186
+
1. Add a notification recipient.
187
+
Under **Contact point**, select **RequestBin** from the drop-down menu.
176
188
177
-
##Add Annotations
189
+
1. Add an annotation (optional).
178
190
179
-
To provide more context on the alert, you can link a dashboard and panel to our Alert. For that, click **Link Dashboard and panel** button.
191
+
To provide more context on the alert, you can link a dashboard and panel to our Alert. To do this, click **Link Dashboard and panel** button.
180
192
181
-
Linking an alert rule to a panel adds an annotation to the panel when the status of your alert rulechanges. If you don’t have a panel already, and since this is optional, you can skip this step for now and link it after you have finished configuring the alert rule.
193
+
Linking an alert rule to a panel adds an annotation to the panel when the status of your alert rulechanges. If you don’t have a panel already, and since this is optional, you can skip this step for now and link it after you have finished configuring the alert rule.
182
194
183
-
Click **Save rule and exit** at the top right corner.
195
+
1.Click **Save rule and exit** at the top right corner.
184
196
185
197
## Trigger an alert
186
198
@@ -196,7 +208,7 @@ Once the query `sum(rate(tns_request_duration_seconds_count[1m])) by(method)` re
196
208
197
209
In this tutorial, you have learned how to set up an alert, send alert notifications to a public webhook, and generate some sample data to observe your alert in action. By following these steps, you've gained a foundational understanding of how to leverage Grafana's alerting capabilities to monitor and respond to events of interest in your data. Happy monitoring!
198
210
199
-
# Learn more
211
+
##Learn more
200
212
201
213
Check out the links below to continue your learning journey with Grafana's LGTM stack.
0 commit comments