> Alerting is still in very early development. Please be aware.
The roadmap for alerting is described in [issue #2209](https://github.com/grafana/grafana/issues/2209#issuecomment-210077445) and the current state can be found at this page.
The roadmap for alerting is described in [issue #2209](https://github.com/grafana/grafana/issues/2209#issuecomment-210077445) and the current state can be found at this page.
## Introduction
## Introduction
So far Grafana does only support saving alering rules but not execute it. This means that any one using grafana for alerts have to extract the alerts from grafana and then import them into their own monitoring systems. The current defintion of an alert rule looks like this:
So far Grafana does only support saving alering rules but not execute it. This means that you have to export them from grafana using the api and import them into your monitoring tool of choice. The current defintion of an alert rule looks like this:
``` go
``` go
typeAlertRulestruct{
typeAlertRulestruct{
...
@@ -42,14 +42,17 @@ QueryRange: The time range for which the query should look back.
...
@@ -42,14 +42,17 @@ QueryRange: The time range for which the query should look back.
Aggregator: How the result should be reduced into a single value. ex avg, sum, min, max
Aggregator: How the result should be reduced into a single value. ex avg, sum, min, max
State: Current state of the alert OK, WARN, CRITICAL, ACKNOWLEGED.
State: Current state of the alert OK, WARN, CRITICAL, ACKNOWLEGED.
You can configure these settings in the Alerting tab on graph panels in edit mode. When the dashboard is saved the alert is created or updated based on the dashboard. If you wish to delete an alert you simply set the query to '- select query -' in the alerting tab and save the dashboard. (this will be improved within the UI later on).
You can configure these settings in the Alerting tab on graph panels in edit mode. When the dashboard is saved the alert is created or updated based on the dashboard. If you wish to delete an alert you simply set the query to '- select query -' in the alerting tab and save the dashboard.
## Api
## Api
Endpoints
### Alert rules
```http
```url
GET /api/alerts/rules
GET /api/alerts/rules
```
``` http
state //array of strings *optional*
state //array of strings *optional*
dashboardId //int *optional*
dashboardId //int *optional*
panelId //int *optional*
panelId //int *optional*
...
@@ -59,27 +62,13 @@ Result
...
@@ -59,27 +62,13 @@ Result
```
```
``` http
``` http
GET /api/alerts/changes
GET /api/alerts/rules/:alertId
limit //array of strings *optional*
sinceId //int *optional*
Result
[
{
id: incrementing id,
alertId: alertId,
type: CREATED/UPDATED/DELETED,
created: timestamp,
}
]
```
``` http
GET /api/alerts/rulres/:alertId
Result AlertRule
Result AlertRule
```
```
### Alert state
``` http
``` http
GET /api/alerts/rulres/:alertId/states
GET /api/alerts/rulres/:alertId/states
...
@@ -103,3 +92,20 @@ Request
...
@@ -103,3 +92,20 @@ Request
info: description of what might have caused the changed alert state
info: description of what might have caused the changed alert state