diff --git a/docs/sources/developers/http_api/_index.md b/docs/sources/developers/http_api/_index.md
index 03546de0e01..6ea19b3df63 100644
--- a/docs/sources/developers/http_api/_index.md
+++ b/docs/sources/developers/http_api/_index.md
@@ -22,8 +22,7 @@ dashboards, creating users, and updating data sources.
## HTTP APIs
- [Admin API]({{< relref "admin/" >}})
-- [Alerting Notification Channels API]({{< relref "alerting_notification_channels/" >}})
-- [Alerting API]({{< relref "alerting/" >}})
+- [Alerting Provisioning API]({{< relref "alerting_provisioning/" >}})
- [Annotations API]({{< relref "annotations/" >}})
- [Authentication API]({{< relref "auth/" >}})
- [Dashboard API]({{< relref "dashboard/" >}})
@@ -43,6 +42,11 @@ dashboards, creating users, and updating data sources.
- [Team API]({{< relref "team/" >}})
- [User API]({{< relref "user/" >}})
+## Deprecated HTTP APIs
+
+- [Alerting Notification Channels API]({{< relref "alerting_notification_channels/" >}})
+- [Alerting API]({{< relref "alerting/" >}})
+
## Grafana Enterprise HTTP APIs
Grafana Enterprise includes all of the Grafana OSS APIs as well as those that follow:
diff --git a/docs/sources/developers/http_api/alerting_provisioning.md b/docs/sources/developers/http_api/alerting_provisioning.md
new file mode 100644
index 00000000000..1abcb73107f
--- /dev/null
+++ b/docs/sources/developers/http_api/alerting_provisioning.md
@@ -0,0 +1,1050 @@
+---
+aliases:
+ - /docs/grafana/latest/developers/http_api/alerting_provisioning/
+ - /docs/grafana/latest/http_api/alerting_provisioning/
+description: Grafana Alerts HTTP API
+keywords:
+ - grafana
+ - http
+ - documentation
+ - api
+ - alerting
+ - alerts
+title: 'Alerting Provisioning HTTP API '
+---
+
+# Alerting provisioning API
+
+## Information
+
+### Version
+
+1.0.0
+
+## Content negotiation
+
+### Consumes
+
+- application/json
+
+### Produces
+
+- application/json
+
+## All endpoints
+
+### Alert rules
+
+| Method | URI | Name | Summary |
+| ------ | ----------------------------------------------------------- | --------------------------------------------------------- | ------------------------------------ |
+| GET | /api/v1/provisioning/alert-rules/{UID} | [route get alert rule](#route-get-alert-rule) | Get a specific alert rule by UID. |
+| POST | /api/v1/provisioning/alert-rules | [route post alert rule](#route-post-alert-rule) | Create a new alert rule. |
+| PUT | /api/v1/provisioning/alert-rules/{UID} | [route put alert rule](#route-put-alert-rule) | Update an existing alert rule. |
+| PUT | /api/v1/provisioning/folder/{FolderUID}/rule-groups/{Group} | [route put alert rule group](#route-put-alert-rule-group) | Update the interval of a rule group. |
+| DELETE | /api/v1/provisioning/alert-rules/{UID} | [route delete alert rule](#route-delete-alert-rule) | Delete a specific alert rule by UID. |
+
+### Contact points
+
+| Method | URI | Name | Summary |
+| ------ | ----------------------------------------- | --------------------------------------------------------- | --------------------------------- |
+| GET | /api/v1/provisioning/contact-points | [route get contactpoints](#route-get-contactpoints) | Get all the contact points. |
+| POST | /api/v1/provisioning/contact-points | [route post contactpoints](#route-post-contactpoints) | Create a contact point. |
+| PUT | /api/v1/provisioning/contact-points/{UID} | [route put contactpoint](#route-put-contactpoint) | Update an existing contact point. |
+| DELETE | /api/v1/provisioning/contact-points/{UID} | [route delete contactpoints](#route-delete-contactpoints) | Delete a contact point. |
+
+### Notification policies
+
+| Method | URI | Name | Summary |
+| ------ | ----------------------------- | ----------------------------------------------- | ---------------------------------- |
+| GET | /api/v1/provisioning/policies | [route get policy tree](#route-get-policy-tree) | Get the notification policy tree. |
+| PUT | /api/v1/provisioning/policies | [route put policy tree](#route-put-policy-tree) | Sets the notification policy tree. |
+
+### Mute timings
+
+| Method | URI | Name | Summary |
+| ------ | ---------------------------------------- | ----------------------------------------------------- | -------------------------------- |
+| GET | /api/v1/provisioning/mute-timings | [route get mute timings](#route-get-mute-timings) | Get all the mute timings. |
+| GET | /api/v1/provisioning/mute-timings/{name} | [route get mute timing](#route-get-mute-timing) | Get a mute timing. |
+| POST | /api/v1/provisioning/mute-timings | [route post mute timing](#route-post-mute-timing) | Create a new mute timing. |
+| PUT | /api/v1/provisioning/mute-timings/{name} | [route put mute timing](#route-put-mute-timing) | Replace an existing mute timing. |
+| DELETE | /api/v1/provisioning/mute-timings/{name} | [route delete mute timing](#route-delete-mute-timing) | Delete a mute timing. |
+
+### Templates
+
+| Method | URI | Name | Summary |
+| ------ | ------------------------------------- | ----------------------------------------------- | ------------------------------ |
+| GET | /api/v1/provisioning/templates | [route get templates](#route-get-templates) | Get all message templates. |
+| GET | /api/v1/provisioning/templates/{name} | [route get template](#route-get-template) | Get a message template. |
+| PUT | /api/v1/provisioning/templates/{name} | [route put template](#route-put-template) | Creates or updates a template. |
+| DELETE | /api/v1/provisioning/templates/{name} | [route delete template](#route-delete-template) | Delete a template. |
+
+## Paths
+
+### Delete a specific alert rule by UID. (_RouteDeleteAlertRule_)
+
+```
+DELETE /api/v1/provisioning/alert-rules/{UID}
+```
+
+#### Parameters
+
+| Name | Source | Type | Go type | Separator | Required | Default | Description |
+| ---- | ------ | ------ | -------- | --------- | :------: | ------- | ----------- |
+| UID | `path` | string | `string` | | ✓ | | |
+
+#### All responses
+
+| Code | Status | Description | Has headers | Schema |
+| ----------------------------------- | ----------- | ---------------------------------------- | :---------: | --------------------------------------------- |
+| [204](#route-delete-alert-rule-204) | No Content | The alert rule was deleted successfully. | | [schema](#route-delete-alert-rule-204-schema) |
+| [400](#route-delete-alert-rule-400) | Bad Request | ValidationError | | [schema](#route-delete-alert-rule-400-schema) |
+
+#### Responses
+
+##### 204 - The alert rule was deleted successfully.
+
+Status: No Content
+
+###### Schema
+
+##### 400 - ValidationError
+
+Status: Bad Request
+
+###### Schema
+
+[ValidationError](#validation-error)
+
+### Delete a contact point. (_RouteDeleteContactpoints_)
+
+```
+DELETE /api/v1/provisioning/contact-points/{UID}
+```
+
+#### Consumes
+
+- application/json
+
+#### Parameters
+
+| Name | Source | Type | Go type | Separator | Required | Default | Description |
+| ---- | ------ | ------ | -------- | --------- | :------: | ------- | ------------------------------------------------- |
+| UID | `path` | string | `string` | | ✓ | | UID should be the contact point unique identifier |
+
+#### All responses
+
+| Code | Status | Description | Has headers | Schema |
+| -------------------------------------- | ----------- | --------------- | :---------: | ------------------------------------------------ |
+| [202](#route-delete-contactpoints-202) | Accepted | Ack | | [schema](#route-delete-contactpoints-202-schema) |
+| [400](#route-delete-contactpoints-400) | Bad Request | ValidationError | | [schema](#route-delete-contactpoints-400-schema) |
+
+#### Responses
+
+##### 202 - Ack
+
+Status: Accepted
+
+###### Schema
+
+[Ack](#ack)
+
+##### 400 - ValidationError
+
+Status: Bad Request
+
+###### Schema
+
+[ValidationError](#validation-error)
+
+### Delete a mute timing. (_RouteDeleteMuteTiming_)
+
+```
+DELETE /api/v1/provisioning/mute-timings/{name}
+```
+
+#### Parameters
+
+| Name | Source | Type | Go type | Separator | Required | Default | Description |
+| ---- | ------ | ------ | -------- | --------- | :------: | ------- | ------------- |
+| name | `path` | string | `string` | | ✓ | | Template Name |
+
+#### All responses
+
+| Code | Status | Description | Has headers | Schema |
+| ------------------------------------ | ---------- | ----------- | :---------: | ---------------------------------------------- |
+| [204](#route-delete-mute-timing-204) | No Content | Ack | | [schema](#route-delete-mute-timing-204-schema) |
+
+#### Responses
+
+##### 204 - Ack
+
+Status: No Content
+
+###### Schema
+
+[Ack](#ack)
+
+### Delete a template. (_RouteDeleteTemplate_)
+
+```
+DELETE /api/v1/provisioning/templates/{name}
+```
+
+#### Parameters
+
+| Name | Source | Type | Go type | Separator | Required | Default | Description |
+| ---- | ------ | ------ | -------- | --------- | :------: | ------- | ------------- |
+| name | `path` | string | `string` | | ✓ | | Template Name |
+
+#### All responses
+
+| Code | Status | Description | Has headers | Schema |
+| --------------------------------- | ---------- | ----------- | :---------: | ------------------------------------------- |
+| [204](#route-delete-template-204) | No Content | Ack | | [schema](#route-delete-template-204-schema) |
+
+#### Responses
+
+##### 204 - Ack
+
+Status: No Content
+
+###### Schema
+
+[Ack](#ack)
+
+### Get a specific alert rule by UID. (_RouteGetAlertRule_)
+
+```
+GET /api/v1/provisioning/alert-rules/{UID}
+```
+
+#### Parameters
+
+| Name | Source | Type | Go type | Separator | Required | Default | Description |
+| ---- | ------ | ------ | -------- | --------- | :------: | ------- | ----------- |
+| UID | `path` | string | `string` | | ✓ | | |
+
+#### All responses
+
+| Code | Status | Description | Has headers | Schema |
+| -------------------------------- | ----------- | --------------- | :---------: | ------------------------------------------ |
+| [200](#route-get-alert-rule-200) | OK | AlertRule | | [schema](#route-get-alert-rule-200-schema) |
+| [400](#route-get-alert-rule-400) | Bad Request | ValidationError | | [schema](#route-get-alert-rule-400-schema) |
+
+#### Responses
+
+##### 200 - AlertRule
+
+Status: OK
+
+###### Schema
+
+[AlertRule](#alert-rule)
+
+##### 400 - ValidationError
+
+Status: Bad Request
+
+###### Schema
+
+[ValidationError](#validation-error)
+
+### Get all the contact points. (_RouteGetContactpoints_)
+
+```
+GET /api/v1/provisioning/contact-points
+```
+
+#### All responses
+
+| Code | Status | Description | Has headers | Schema |
+| ----------------------------------- | ----------- | --------------- | :---------: | --------------------------------------------- |
+| [200](#route-get-contactpoints-200) | OK | Route | | [schema](#route-get-contactpoints-200-schema) |
+| [400](#route-get-contactpoints-400) | Bad Request | ValidationError | | [schema](#route-get-contactpoints-400-schema) |
+
+#### Responses
+
+##### 200 - Route
+
+Status: OK
+
+###### Schema
+
+[Route](#route)
+
+##### 400 - ValidationError
+
+Status: Bad Request
+
+###### Schema
+
+[ValidationError](#validation-error)
+
+### Get a mute timing. (_RouteGetMuteTiming_)
+
+```
+GET /api/v1/provisioning/mute-timings/{name}
+```
+
+#### Parameters
+
+| Name | Source | Type | Go type | Separator | Required | Default | Description |
+| ---- | ------ | ------ | -------- | --------- | :------: | ------- | ------------- |
+| name | `path` | string | `string` | | ✓ | | Template Name |
+
+#### All responses
+
+| Code | Status | Description | Has headers | Schema |
+| --------------------------------- | ----------- | ---------------- | :---------: | ------------------------------------------- |
+| [200](#route-get-mute-timing-200) | OK | MuteTimeInterval | | [schema](#route-get-mute-timing-200-schema) |
+| [400](#route-get-mute-timing-400) | Bad Request | ValidationError | | [schema](#route-get-mute-timing-400-schema) |
+
+#### Responses
+
+##### 200 - MuteTimeInterval
+
+Status: OK
+
+###### Schema
+
+[MuteTimeInterval](#mute-time-interval)
+
+##### 400 - ValidationError
+
+Status: Bad Request
+
+###### Schema
+
+[ValidationError](#validation-error)
+
+### Get all the mute timings. (_RouteGetMuteTimings_)
+
+```
+GET /api/v1/provisioning/mute-timings
+```
+
+#### All responses
+
+| Code | Status | Description | Has headers | Schema |
+| ---------------------------------- | ----------- | --------------- | :---------: | -------------------------------------------- |
+| [200](#route-get-mute-timings-200) | OK | MuteTimings | | [schema](#route-get-mute-timings-200-schema) |
+| [400](#route-get-mute-timings-400) | Bad Request | ValidationError | | [schema](#route-get-mute-timings-400-schema) |
+
+#### Responses
+
+##### 200 - MuteTimings
+
+Status: OK
+
+###### Schema
+
+[MuteTimings](#mute-timings)
+
+##### 400 - ValidationError
+
+Status: Bad Request
+
+###### Schema
+
+[ValidationError](#validation-error)
+
+### Get the notification policy tree. (_RouteGetPolicyTree_)
+
+```
+GET /api/v1/provisioning/policies
+```
+
+#### All responses
+
+| Code | Status | Description | Has headers | Schema |
+| --------------------------------- | ----------- | --------------- | :---------: | ------------------------------------------- |
+| [200](#route-get-policy-tree-200) | OK | Route | | [schema](#route-get-policy-tree-200-schema) |
+| [400](#route-get-policy-tree-400) | Bad Request | ValidationError | | [schema](#route-get-policy-tree-400-schema) |
+
+#### Responses
+
+##### 200 - Route
+
+Status: OK
+
+###### Schema
+
+[Route](#route)
+
+##### 400 - ValidationError
+
+Status: Bad Request
+
+###### Schema
+
+[ValidationError](#validation-error)
+
+### Get a message template. (_RouteGetTemplate_)
+
+```
+GET /api/v1/provisioning/templates/{name}
+```
+
+#### Parameters
+
+| Name | Source | Type | Go type | Separator | Required | Default | Description |
+| ---- | ------ | ------ | -------- | --------- | :------: | ------- | ------------- |
+| name | `path` | string | `string` | | ✓ | | Template Name |
+
+#### All responses
+
+| Code | Status | Description | Has headers | Schema |
+| ------------------------------ | --------- | --------------- | :---------: | ---------------------------------------- |
+| [200](#route-get-template-200) | OK | MessageTemplate | | [schema](#route-get-template-200-schema) |
+| [404](#route-get-template-404) | Not Found | NotFound | | [schema](#route-get-template-404-schema) |
+
+#### Responses
+
+##### 200 - MessageTemplate
+
+Status: OK
+
+###### Schema
+
+[MessageTemplate](#message-template)
+
+##### 404 - NotFound
+
+Status: Not Found
+
+###### Schema
+
+[NotFound](#not-found)
+
+### Get all message templates. (_RouteGetTemplates_)
+
+```
+GET /api/v1/provisioning/templates
+```
+
+#### All responses
+
+| Code | Status | Description | Has headers | Schema |
+| ------------------------------- | ----------- | --------------- | :---------: | ----------------------------------------- |
+| [200](#route-get-templates-200) | OK | MessageTemplate | | [schema](#route-get-templates-200-schema) |
+| [400](#route-get-templates-400) | Bad Request | ValidationError | | [schema](#route-get-templates-400-schema) |
+
+#### Responses
+
+##### 200 - MessageTemplate
+
+Status: OK
+
+###### Schema
+
+[MessageTemplate](#message-template)
+
+##### 400 - ValidationError
+
+Status: Bad Request
+
+###### Schema
+
+[ValidationError](#validation-error)
+
+### Create a new alert rule. (_RoutePostAlertRule_)
+
+```
+POST /api/v1/provisioning/alert-rules
+```
+
+#### Parameters
+
+| Name | Source | Type | Go type | Separator | Required | Default | Description |
+| ---- | ------ | ------------------------ | ------------------ | --------- | :------: | ------- | ----------- |
+| Body | `body` | [AlertRule](#alert-rule) | `models.AlertRule` | | | | |
+
+#### All responses
+
+| Code | Status | Description | Has headers | Schema |
+| --------------------------------- | ----------- | --------------- | :---------: | ------------------------------------------- |
+| [201](#route-post-alert-rule-201) | Created | AlertRule | | [schema](#route-post-alert-rule-201-schema) |
+| [400](#route-post-alert-rule-400) | Bad Request | ValidationError | | [schema](#route-post-alert-rule-400-schema) |
+
+#### Responses
+
+##### 201 - AlertRule
+
+Status: Created
+
+###### Schema
+
+[AlertRule](#alert-rule)
+
+##### 400 - ValidationError
+
+Status: Bad Request
+
+###### Schema
+
+[ValidationError](#validation-error)
+
+### Create a contact point. (_RoutePostContactpoints_)
+
+```
+POST /api/v1/provisioning/contact-points
+```
+
+#### Consumes
+
+- application/json
+
+#### Parameters
+
+| Name | Source | Type | Go type | Separator | Required | Default | Description |
+| ---- | ------ | ----------------------------------------------- | ----------------------------- | --------- | :------: | ------- | ----------- |
+| Body | `body` | [EmbeddedContactPoint](#embedded-contact-point) | `models.EmbeddedContactPoint` | | | | |
+
+#### All responses
+
+| Code | Status | Description | Has headers | Schema |
+| ------------------------------------ | ----------- | --------------- | :---------: | ---------------------------------------------- |
+| [202](#route-post-contactpoints-202) | Accepted | Ack | | [schema](#route-post-contactpoints-202-schema) |
+| [400](#route-post-contactpoints-400) | Bad Request | ValidationError | | [schema](#route-post-contactpoints-400-schema) |
+
+#### Responses
+
+##### 202 - Ack
+
+Status: Accepted
+
+###### Schema
+
+[Ack](#ack)
+
+##### 400 - ValidationError
+
+Status: Bad Request
+
+###### Schema
+
+[ValidationError](#validation-error)
+
+### Create a new mute timing. (_RoutePostMuteTiming_)
+
+```
+POST /api/v1/provisioning/mute-timings
+```
+
+#### Consumes
+
+- application/json
+
+#### Parameters
+
+| Name | Source | Type | Go type | Separator | Required | Default | Description |
+| ---- | ------ | --------------------------------------- | ------------------------- | --------- | :------: | ------- | ----------- |
+| Body | `body` | [MuteTimeInterval](#mute-time-interval) | `models.MuteTimeInterval` | | | | |
+
+#### All responses
+
+| Code | Status | Description | Has headers | Schema |
+| ---------------------------------- | ----------- | ---------------- | :---------: | -------------------------------------------- |
+| [201](#route-post-mute-timing-201) | Created | MuteTimeInterval | | [schema](#route-post-mute-timing-201-schema) |
+| [400](#route-post-mute-timing-400) | Bad Request | ValidationError | | [schema](#route-post-mute-timing-400-schema) |
+
+#### Responses
+
+##### 201 - MuteTimeInterval
+
+Status: Created
+
+###### Schema
+
+[MuteTimeInterval](#mute-time-interval)
+
+##### 400 - ValidationError
+
+Status: Bad Request
+
+###### Schema
+
+[ValidationError](#validation-error)
+
+### Update an existing alert rule. (_RoutePutAlertRule_)
+
+```
+PUT /api/v1/provisioning/alert-rules/{UID}
+```
+
+#### Consumes
+
+- application/json
+
+#### Parameters
+
+| Name | Source | Type | Go type | Separator | Required | Default | Description |
+| ---- | ------ | ------------------------ | ------------------ | --------- | :------: | ------- | ----------- |
+| UID | `path` | string | `string` | | ✓ | | |
+| Body | `body` | [AlertRule](#alert-rule) | `models.AlertRule` | | | | |
+
+#### All responses
+
+| Code | Status | Description | Has headers | Schema |
+| -------------------------------- | ----------- | --------------- | :---------: | ------------------------------------------ |
+| [200](#route-put-alert-rule-200) | OK | AlertRule | | [schema](#route-put-alert-rule-200-schema) |
+| [400](#route-put-alert-rule-400) | Bad Request | ValidationError | | [schema](#route-put-alert-rule-400-schema) |
+
+#### Responses
+
+##### 200 - AlertRule
+
+Status: OK
+
+###### Schema
+
+[AlertRule](#alert-rule)
+
+##### 400 - ValidationError
+
+Status: Bad Request
+
+###### Schema
+
+[ValidationError](#validation-error)
+
+### Update the interval of a rule group. (_RoutePutAlertRuleGroup_)
+
+```
+PUT /api/v1/provisioning/folder/{FolderUID}/rule-groups/{Group}
+```
+
+#### Consumes
+
+- application/json
+
+#### Parameters
+
+| Name | Source | Type | Go type | Separator | Required | Default | Description |
+| --------- | ------ | ----------------------------------- | ----------------------- | --------- | :------: | ------- | ----------- |
+| FolderUID | `path` | string | `string` | | ✓ | | |
+| Group | `path` | string | `string` | | ✓ | | |
+| Body | `body` | [AlertRuleGroup](#alert-rule-group) | `models.AlertRuleGroup` | | | | |
+
+#### All responses
+
+| Code | Status | Description | Has headers | Schema |
+| -------------------------------------- | ----------- | --------------- | :---------: | ------------------------------------------------ |
+| [200](#route-put-alert-rule-group-200) | OK | AlertRuleGroup | | [schema](#route-put-alert-rule-group-200-schema) |
+| [400](#route-put-alert-rule-group-400) | Bad Request | ValidationError | | [schema](#route-put-alert-rule-group-400-schema) |
+
+#### Responses
+
+##### 200 - AlertRuleGroup
+
+Status: OK
+
+###### Schema
+
+[AlertRuleGroup](#alert-rule-group)
+
+##### 400 - ValidationError
+
+Status: Bad Request
+
+###### Schema
+
+[ValidationError](#validation-error)
+
+### Update an existing contact point. (_RoutePutContactpoint_)
+
+```
+PUT /api/v1/provisioning/contact-points/{UID}
+```
+
+#### Consumes
+
+- application/json
+
+#### Parameters
+
+| Name | Source | Type | Go type | Separator | Required | Default | Description |
+| ---- | ------ | ----------------------------------------------- | ----------------------------- | --------- | :------: | ------- | ------------------------------------------------- |
+| UID | `path` | string | `string` | | ✓ | | UID should be the contact point unique identifier |
+| Body | `body` | [EmbeddedContactPoint](#embedded-contact-point) | `models.EmbeddedContactPoint` | | | | |
+
+#### All responses
+
+| Code | Status | Description | Has headers | Schema |
+| ---------------------------------- | ----------- | --------------- | :---------: | -------------------------------------------- |
+| [202](#route-put-contactpoint-202) | Accepted | Ack | | [schema](#route-put-contactpoint-202-schema) |
+| [400](#route-put-contactpoint-400) | Bad Request | ValidationError | | [schema](#route-put-contactpoint-400-schema) |
+
+#### Responses
+
+##### 202 - Ack
+
+Status: Accepted
+
+###### Schema
+
+[Ack](#ack)
+
+##### 400 - ValidationError
+
+Status: Bad Request
+
+###### Schema
+
+[ValidationError](#validation-error)
+
+### Replace an existing mute timing. (_RoutePutMuteTiming_)
+
+```
+PUT /api/v1/provisioning/mute-timings/{name}
+```
+
+#### Consumes
+
+- application/json
+
+#### Parameters
+
+| Name | Source | Type | Go type | Separator | Required | Default | Description |
+| ---- | ------ | --------------------------------------- | ------------------------- | --------- | :------: | ------- | ------------- |
+| name | `path` | string | `string` | | ✓ | | Template Name |
+| Body | `body` | [MuteTimeInterval](#mute-time-interval) | `models.MuteTimeInterval` | | | | |
+
+#### All responses
+
+| Code | Status | Description | Has headers | Schema |
+| --------------------------------- | ----------- | ---------------- | :---------: | ------------------------------------------- |
+| [200](#route-put-mute-timing-200) | OK | MuteTimeInterval | | [schema](#route-put-mute-timing-200-schema) |
+| [400](#route-put-mute-timing-400) | Bad Request | ValidationError | | [schema](#route-put-mute-timing-400-schema) |
+
+#### Responses
+
+##### 200 - MuteTimeInterval
+
+Status: OK
+
+###### Schema
+
+[MuteTimeInterval](#mute-time-interval)
+
+##### 400 - ValidationError
+
+Status: Bad Request
+
+###### Schema
+
+[ValidationError](#validation-error)
+
+### Sets the notification policy tree. (_RoutePutPolicyTree_)
+
+```
+PUT /api/v1/provisioning/policies
+```
+
+#### Consumes
+
+- application/json
+
+#### Parameters
+
+| Name | Source | Type | Go type | Separator | Required | Default | Description |
+| ---- | ------ | --------------- | -------------- | --------- | :------: | ------- | ----------- |
+| Body | `body` | [Route](#route) | `models.Route` | | | | |
+
+#### All responses
+
+| Code | Status | Description | Has headers | Schema |
+| --------------------------------- | ----------- | --------------- | :---------: | ------------------------------------------- |
+| [202](#route-put-policy-tree-202) | Accepted | Ack | | [schema](#route-put-policy-tree-202-schema) |
+| [400](#route-put-policy-tree-400) | Bad Request | ValidationError | | [schema](#route-put-policy-tree-400-schema) |
+
+#### Responses
+
+##### 202 - Ack
+
+Status: Accepted
+
+###### Schema
+
+[Ack](#ack)
+
+##### 400 - ValidationError
+
+Status: Bad Request
+
+###### Schema
+
+[ValidationError](#validation-error)
+
+### Updates an existing template. (_RoutePutTemplate_)
+
+```
+PUT /api/v1/provisioning/templates/{name}
+```
+
+#### Consumes
+
+- application/json
+
+#### Parameters
+
+| Name | Source | Type | Go type | Separator | Required | Default | Description |
+| ---- | ------ | --------------------------------------------------- | ------------------------------- | --------- | :------: | ------- | ------------- |
+| name | `path` | string | `string` | | ✓ | | Template Name |
+| Body | `body` | [MessageTemplateContent](#message-template-content) | `models.MessageTemplateContent` | | | | |
+
+#### All responses
+
+| Code | Status | Description | Has headers | Schema |
+| ------------------------------ | ----------- | --------------- | :---------: | ---------------------------------------- |
+| [202](#route-put-template-202) | Accepted | Ack | | [schema](#route-put-template-202-schema) |
+| [400](#route-put-template-400) | Bad Request | ValidationError | | [schema](#route-put-template-400-schema) |
+
+#### Responses
+
+##### 202 - Ack
+
+Status: Accepted
+
+###### Schema
+
+[Ack](#ack)
+
+##### 400 - ValidationError
+
+Status: Bad Request
+
+###### Schema
+
+[ValidationError](#validation-error)
+
+### AlertQuery
+
+**Properties**
+
+| Name | Type | Go type | Required | Default | Description | Example |
+| --------------------------------------------------------- | ----------------------------------------- | ------------------- | :------: | ------- | -------------------------------------------------------------------------------------------------- | ------- |
+| DatasourceUID | string | `string` | | | Grafana data source unique identifier; it should be '-100' for a Server Side Expression operation. | |
+| Model | object | `interface{}` | | | JSON is the raw JSON query and includes the above properties as well as custom properties. | |
+| QueryType | string | `string` | | | QueryType is an optional identifier for the type of query. |
+| It can be used to distinguish different types of queries. | |
+| RefID | string | `string` | | | RefID is the unique identifier of the query, set by the frontend call. | |
+| relativeTimeRange | [RelativeTimeRange](#relative-time-range) | `RelativeTimeRange` | | | | |
+
+### AlertRule
+
+**Properties**
+
+| Name | Type | Go type | Required | Default | Description | Example |
+| ------------ | ---------------------------- | ------------------- | :------: | ------- | ----------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| Annotations | map of string | `map[string]string` | | | | `{"runbook_url":"https://supercoolrunbook.com/page/13"}` |
+| Condition | string | `string` | ✓ | | | `A` |
+| Data | [][alertquery](#alert-query) | `[]*AlertQuery` | ✓ | | | `[{"datasourceUid":"-100","model":{"conditions":[{"evaluator":{"params":[0,0],"type":"gt"},"operator":{"type":"and"},"query":{"params":[]},"reducer":{"params":[],"type":"avg"},"type":"query"}],"datasource":{"type":"__expr__","uid":"__expr__"},"expression":"1 == 1","hide":false,"intervalMs":1000,"maxDataPoints":43200,"refId":"A","type":"math"},"queryType":"","refId":"A","relativeTimeRange":{"from":0,"to":0}}]` |
+| ExecErrState | string | `string` | ✓ | | Allowed values: "OK", "Alerting", "Error" | |
+| FolderUID | string | `string` | ✓ | | | `project_x` |
+| ID | int64 (formatted integer) | `int64` | | | | |
+| Labels | map of string | `map[string]string` | | | | `{"team":"sre-team-1"}` |
+| NoDataState | string | `string` | ✓ | | Allowed values: "OK", "NoData", "Error" | |
+| OrgID | int64 (formatted integer) | `int64` | ✓ | | | |
+| RuleGroup | string | `string` | ✓ | | | `eval_group_1` |
+| Title | string | `string` | ✓ | | | `Always firing` |
+| UID | string | `string` | | | | |
+| Updated | date-time (formatted string) | `strfmt.DateTime` | | | | |
+| for | [Duration](#duration) | `Duration` | ✓ | | | |
+| provenance | string | `Provenance` | | | | |
+
+### AlertRuleGroup
+
+**Properties**
+
+| Name | Type | Go type | Required | Default | Description | Example |
+| -------- | ------------------------- | ------- | :------: | ------- | ----------- | ------- |
+| Interval | int64 (formatted integer) | `int64` | | | | |
+
+### DayOfMonthRange
+
+**Properties**
+
+| Name | Type | Go type | Required | Default | Description | Example |
+| ----- | ------------------------- | ------- | :------: | ------- | ----------- | ------- |
+| Begin | int64 (formatted integer) | `int64` | | | | |
+| End | int64 (formatted integer) | `int64` | | | | |
+
+### Duration
+
+| Name | Type | Go type | Default | Description | Example |
+| -------- | ------------------------- | ------- | ------- | ----------- | ------- |
+| Duration | int64 (formatted integer) | int64 | | | |
+
+### EmbeddedContactPoint
+
+> EmbeddedContactPoint is the contact point type that is used
+> by grafanas embedded alertmanager implementation.
+
+**Properties**
+
+| Name | Type | Go type | Required | Default | Description | Example |
+| --------------------- | ------- | -------- | :------: | ------- | ---------------------------------------------------------------------------------------------------- | ----------------------- |
+| DisableResolveMessage | boolean | `bool` | | | | `false` |
+| Name | string | `string` | ✓ | | Name is used as grouping key in the UI. Contact points with the same name will be grouped in the UI. | `webhook_1` |
+| Provenance | string | `string` | | | | |
+| Type | string | `string` | ✓ | | | `webhook` |
+| UID | string | `string` | | | UID is the unique identifier of the contact point. The UID can be set by the user. | `my_external_reference` |
+| settings | object | `JSON` | ✓ | | | |
+
+### MatchType
+
+| Name | Type | Go type | Default | Description | Example |
+| --------- | ------------------------- | ------- | ------- | ---------------------------------------------------------------------- | ------- |
+| MatchType | int64 (formatted integer) | int64 | | 0 = MatchEqual, 1 = MatchNotEqual, 2 = MatchRegexp, 3 = MatchNotRegexp | |
+
+### Matcher
+
+**Properties**
+
+| Name | Type | Go type | Required | Default | Description | Example |
+| ----- | ------------------------ | ----------- | :------: | ------- | ----------- | ------- |
+| Name | string | `string` | | | | |
+| Type | [MatchType](#match-type) | `MatchType` | | | | |
+| Value | string | `string` | | | | |
+
+### Matchers
+
+> Matchers is a slice of Matchers that is sortable, implements Stringer, and
+> provides a Matches method to match a LabelSet against all Matchers in the
+> slice. Note that some users of Matchers might require it to be sorted.
+
+[][matcher](#matcher)
+
+### MessageTemplate
+
+**Properties**
+
+| Name | Type | Go type | Required | Default | Description | Example |
+| ---------- | ------ | ------------ | :------: | ------- | ----------- | ------- |
+| Name | string | `string` | | | | |
+| Template | string | `string` | | | | |
+| provenance | string | `Provenance` | | | | |
+
+### MessageTemplateContent
+
+**Properties**
+
+| Name | Type | Go type | Required | Default | Description | Example |
+| -------- | ------ | -------- | :------: | ------- | ----------- | ------- |
+| Template | string | `string` | | | | |
+
+### MonthRange
+
+**Properties**
+
+| Name | Type | Go type | Required | Default | Description | Example |
+| ----- | ------------------------- | ------- | :------: | ------- | ----------- | ------- |
+| Begin | int64 (formatted integer) | `int64` | | | | |
+| End | int64 (formatted integer) | `int64` | | | | |
+
+### MuteTimeInterval
+
+**Properties**
+
+| Name | Type | Go type | Required | Default | Description | Example |
+| ------------- | -------------------------------- | ----------------- | :------: | ------- | ----------- | ------- |
+| Name | string | `string` | | | | |
+| TimeIntervals | [][timeinterval](#time-interval) | `[]*TimeInterval` | | | | |
+
+### MuteTimings
+
+[][mutetimeinterval](#mute-time-interval)
+
+### NotFound
+
+[interface{}](#interface)
+
+### ObjectMatchers
+
+[Matchers](#matchers)
+
+#### Inlined models
+
+### RelativeTimeRange
+
+> RelativeTimeRange is the per query start and end time
+> for requests.
+
+**Properties**
+
+| Name | Type | Go type | Required | Default | Description | Example |
+| ---- | --------------------- | ---------- | :------: | ------- | ----------- | ------- |
+| from | [Duration](#duration) | `Duration` | | | | |
+| to | [Duration](#duration) | `Duration` | | | | |
+
+### Route
+
+> A Route is a node that contains definitions of how to handle alerts.
+
+**Properties**
+
+| Name | Type | Go type | Required | Default | Description | Example |
+| ----------------- | ---------------------------------- | ---------------- | :------: | ------- | ----------- | ------- |
+| Continue | boolean | `bool` | | | | |
+| GroupByStr | []string | `[]string` | | | | |
+| MuteTimeIntervals | []string | `[]string` | | | | |
+| Receiver | string | `string` | | | | |
+| Routes | [][route](#route) | `[]*Route` | | | | |
+| group_interval | [Duration](#duration) | `Duration` | | | | |
+| group_wait | [Duration](#duration) | `Duration` | | | | |
+| object_matchers | [ObjectMatchers](#object-matchers) | `ObjectMatchers` | | | | |
+| provenance | string | `Provenance` | | | | |
+| repeat_interval | [Duration](#duration) | `Duration` | | | | |
+
+### TimeInterval
+
+> TimeInterval describes intervals of time. ContainsTime will tell you if a golang time is contained
+> within the interval.
+
+**Properties**
+
+| Name | Type | Go type | Required | Default | Description | Example |
+| ----------- | ---------------------------------------- | -------------------- | :------: | ------- | ----------- | ------- |
+| DaysOfMonth | [][dayofmonthrange](#day-of-month-range) | `[]*DayOfMonthRange` | | | | |
+| Months | [][monthrange](#month-range) | `[]*MonthRange` | | | | |
+| Times | [][timerange](#time-range) | `[]*TimeRange` | | | | |
+| Weekdays | [][weekdayrange](#weekday-range) | `[]*WeekdayRange` | | | | |
+| Years | [][yearrange](#year-range) | `[]*YearRange` | | | | |
+
+### TimeRange
+
+> For example, 4:00PM to End of the day would Begin at 1020 and End at 1440.
+
+**Properties**
+
+| Name | Type | Go type | Required | Default | Description | Example |
+| ----------- | ------------------------- | ------- | :------: | ------- | ----------- | ------- |
+| EndMinute | int64 (formatted integer) | `int64` | | | | |
+| StartMinute | int64 (formatted integer) | `int64` | | | | |
+
+### ValidationError
+
+**Properties**
+
+| Name | Type | Go type | Required | Default | Description | Example |
+| ---- | ------ | -------- | :------: | ------- | ----------- | ------- |
+| Msg | string | `string` | | | | |
+
+### WeekdayRange
+
+**Properties**
+
+| Name | Type | Go type | Required | Default | Description | Example |
+| ----- | ------------------------- | ------- | :------: | ------- | ----------- | ------- |
+| Begin | int64 (formatted integer) | `int64` | | | | |
+| End | int64 (formatted integer) | `int64` | | | | |
+
+### YearRange
+
+**Properties**
+
+| Name | Type | Go type | Required | Default | Description | Example |
+| ----- | ------------------------- | ------- | :------: | ------- | ----------- | ------- |
+| Begin | int64 (formatted integer) | `int64` | | | | |
+| End | int64 (formatted integer) | `int64` | | | | |
diff --git a/pkg/services/ngalert/api/tooling/definitions/provisioning_alert_rules.go b/pkg/services/ngalert/api/tooling/definitions/provisioning_alert_rules.go
index 7e6de39c079..39a09f22321 100644
--- a/pkg/services/ngalert/api/tooling/definitions/provisioning_alert_rules.go
+++ b/pkg/services/ngalert/api/tooling/definitions/provisioning_alert_rules.go
@@ -54,21 +54,43 @@ type AlertRulePayload struct {
}
type AlertRule struct {
- ID int64 `json:"id"`
- UID string `json:"uid"`
- OrgID int64 `json:"orgID"`
- FolderUID string `json:"folderUID"`
- RuleGroup string `json:"ruleGroup"`
- Title string `json:"title"`
- Condition string `json:"condition"`
- Data []models.AlertQuery `json:"data"`
- Updated time.Time `json:"updated,omitempty"`
- NoDataState models.NoDataState `json:"noDataState"`
+ ID int64 `json:"id"`
+ UID string `json:"uid"`
+ // required: true
+ OrgID int64 `json:"orgID"`
+ // required: true
+ // example: project_x
+ FolderUID string `json:"folderUID"`
+ // required: true
+ // minLength: 1
+ // maxLength: 190
+ // example: eval_group_1
+ RuleGroup string `json:"ruleGroup"`
+ // required: true
+ // minLength: 1
+ // maxLength: 190
+ // example: Always firing
+ Title string `json:"title"`
+ // required: true
+ // example: A
+ Condition string `json:"condition"`
+ // required: true
+ // example: [{"refId":"A","queryType":"","relativeTimeRange":{"from":0,"to":0},"datasourceUid":"-100","model":{"conditions":[{"evaluator":{"params":[0,0],"type":"gt"},"operator":{"type":"and"},"query":{"params":[]},"reducer":{"params":[],"type":"avg"},"type":"query"}],"datasource":{"type":"__expr__","uid":"__expr__"},"expression":"1 == 1","hide":false,"intervalMs":1000,"maxDataPoints":43200,"refId":"A","type":"math"}}]
+ Data []models.AlertQuery `json:"data"`
+ // readonly: true
+ Updated time.Time `json:"updated,omitempty"`
+ // required: true
+ NoDataState models.NoDataState `json:"noDataState"`
+ // required: true
ExecErrState models.ExecutionErrorState `json:"execErrState"`
- For time.Duration `json:"for"`
- Annotations map[string]string `json:"annotations,omitempty"`
- Labels map[string]string `json:"labels,omitempty"`
- Provenance models.Provenance `json:"provenance,omitempty"`
+ // required: true
+ For time.Duration `json:"for"`
+ // example: {"runbook_url": "https://supercoolrunbook.com/page/13"}
+ Annotations map[string]string `json:"annotations,omitempty"`
+ // example: {"team": "sre-team-1"}
+ Labels map[string]string `json:"labels,omitempty"`
+ // readonly: true
+ Provenance models.Provenance `json:"provenance,omitempty"`
}
func (a *AlertRule) UpstreamModel() models.AlertRule {
diff --git a/pkg/services/ngalert/api/tooling/definitions/provisioning_contactpoints.go b/pkg/services/ngalert/api/tooling/definitions/provisioning_contactpoints.go
index dbb1f502eb0..9d35fca6094 100644
--- a/pkg/services/ngalert/api/tooling/definitions/provisioning_contactpoints.go
+++ b/pkg/services/ngalert/api/tooling/definitions/provisioning_contactpoints.go
@@ -50,7 +50,7 @@ import (
// swagger:parameters RoutePutContactpoint RouteDeleteContactpoints
type ContactPointUIDReference struct {
- // ContactPointUID should be the contact point UID identifier
+ // UID should be the contact point unique identifier
// in:path
UID string
}
@@ -64,16 +64,24 @@ type ContactPointPayload struct {
// EmbeddedContactPoint is the contact point type that is used
// by grafanas embedded alertmanager implementation.
type EmbeddedContactPoint struct {
- // UID is the unique identifier of the contact point. This will be
- // automatically set be the Grafana.
+ // UID is the unique identifier of the contact point. The UID can be
+ // set by the user.
+ // example: my_external_reference
UID string `json:"uid"`
// Name is used as grouping key in the UI. Contact points with the
// same name will be grouped in the UI.
- Name string `json:"name" binding:"required"`
- Type string `json:"type" binding:"required"`
- Settings *simplejson.Json `json:"settings" binding:"required"`
- DisableResolveMessage bool `json:"disableResolveMessage"`
- Provenance string `json:"provenance"`
+ // example: webhook_1
+ Name string `json:"name" binding:"required"`
+ // required: true
+ // example: webhook
+ // enum: alertmanager, dingding, discord, email, googlechat, kafka, line, opsgenie, pagerduty, pushover, sensugo, slack, teams, telegram, threema, victorops, webhook, wecom
+ Type string `json:"type" binding:"required"`
+ // required: true
+ Settings *simplejson.Json `json:"settings" binding:"required"`
+ // example: false
+ DisableResolveMessage bool `json:"disableResolveMessage"`
+ // readonly: true
+ Provenance string `json:"provenance,omitempty"`
}
const RedactedValue = "[REDACTED]"
diff --git a/pkg/services/ngalert/api/tooling/post.json b/pkg/services/ngalert/api/tooling/post.json
index 7fecceb91ce..779cf127d35 100644
--- a/pkg/services/ngalert/api/tooling/post.json
+++ b/pkg/services/ngalert/api/tooling/post.json
@@ -200,14 +200,63 @@
"additionalProperties": {
"type": "string"
},
+ "example": {
+ "runbook_url": "https://supercoolrunbook.com/page/13"
+ },
"type": "object",
"x-go-name": "Annotations"
},
"condition": {
+ "example": "A",
"type": "string",
"x-go-name": "Condition"
},
"data": {
+ "example": [
+ {
+ "datasourceUid": "-100",
+ "model": {
+ "conditions": [
+ {
+ "evaluator": {
+ "params": [
+ 0,
+ 0
+ ],
+ "type": "gt"
+ },
+ "operator": {
+ "type": "and"
+ },
+ "query": {
+ "params": []
+ },
+ "reducer": {
+ "params": [],
+ "type": "avg"
+ },
+ "type": "query"
+ }
+ ],
+ "datasource": {
+ "type": "__expr__",
+ "uid": "__expr__"
+ },
+ "expression": "1 == 1",
+ "hide": false,
+ "intervalMs": 1000,
+ "maxDataPoints": 43200,
+ "refId": "A",
+ "type": "math"
+ },
+ "queryType": "",
+ "refId": "A",
+ "relativeTimeRange": {
+ "from": 0,
+ "to": 0
+ }
+ }
+ ],
"items": {
"$ref": "#/definitions/AlertQuery"
},
@@ -215,9 +264,18 @@
"x-go-name": "Data"
},
"execErrState": {
- "$ref": "#/definitions/ExecutionErrorState"
+ "description": "\nAlerting AlertingErrState\nError ErrorErrState\nOK OkErrState",
+ "enum": [
+ "Alerting",
+ "Error",
+ "OK"
+ ],
+ "type": "string",
+ "x-go-enum-desc": "Alerting AlertingErrState\nError ErrorErrState\nOK OkErrState",
+ "x-go-name": "ExecErrState"
},
"folderUID": {
+ "example": "project_x",
"type": "string",
"x-go-name": "FolderUID"
},
@@ -233,11 +291,22 @@
"additionalProperties": {
"type": "string"
},
+ "example": {
+ "team": "sre-team-1"
+ },
"type": "object",
"x-go-name": "Labels"
},
"noDataState": {
- "$ref": "#/definitions/NoDataState"
+ "description": "\nAlerting Alerting\nNoData NoData\nOK OK",
+ "enum": [
+ "Alerting",
+ "NoData",
+ "OK"
+ ],
+ "type": "string",
+ "x-go-enum-desc": "Alerting Alerting\nNoData NoData\nOK OK",
+ "x-go-name": "NoDataState"
},
"orgID": {
"format": "int64",
@@ -248,10 +317,16 @@
"$ref": "#/definitions/Provenance"
},
"ruleGroup": {
+ "example": "eval_group_1",
+ "maxLength": 190,
+ "minLength": 1,
"type": "string",
"x-go-name": "RuleGroup"
},
"title": {
+ "example": "Always firing",
+ "maxLength": 190,
+ "minLength": 1,
"type": "string",
"x-go-name": "Title"
},
@@ -261,10 +336,22 @@
},
"updated": {
"format": "date-time",
+ "readOnly": true,
"type": "string",
"x-go-name": "Updated"
}
},
+ "required": [
+ "orgID",
+ "folderUID",
+ "ruleGroup",
+ "title",
+ "condition",
+ "data",
+ "noDataState",
+ "execErrState",
+ "for"
+ ],
"type": "object",
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
@@ -673,15 +760,18 @@
"description": "EmbeddedContactPoint is the contact point type that is used\nby grafanas embedded alertmanager implementation.",
"properties": {
"disableResolveMessage": {
+ "example": false,
"type": "boolean",
"x-go-name": "DisableResolveMessage"
},
"name": {
"description": "Name is used as grouping key in the UI. Contact points with the\nsame name will be grouped in the UI.",
+ "example": "webhook_1",
"type": "string",
"x-go-name": "Name"
},
"provenance": {
+ "readOnly": true,
"type": "string",
"x-go-name": "Provenance"
},
@@ -689,15 +779,41 @@
"$ref": "#/definitions/Json"
},
"type": {
+ "enum": [
+ "alertmanager",
+ " dingding",
+ " discord",
+ " email",
+ " googlechat",
+ " kafka",
+ " line",
+ " opsgenie",
+ " pagerduty",
+ " pushover",
+ " sensugo",
+ " slack",
+ " teams",
+ " telegram",
+ " threema",
+ " victorops",
+ " webhook",
+ " wecom"
+ ],
+ "example": "webhook",
"type": "string",
"x-go-name": "Type"
},
"uid": {
- "description": "UID is the unique identifier of the contact point. This will be\nautomatically set be the Grafana.",
+ "description": "UID is the unique identifier of the contact point. The UID can be\nset by the user.",
+ "example": "my_external_reference",
"type": "string",
"x-go-name": "UID"
}
},
+ "required": [
+ "type",
+ "settings"
+ ],
"type": "object",
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
@@ -748,10 +864,6 @@
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"EvalQueriesResponse": {},
- "ExecutionErrorState": {
- "type": "string",
- "x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/models"
- },
"ExtendedReceiver": {
"properties": {
"email_configs": {
@@ -1552,10 +1664,6 @@
"type": "object",
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
- "NoDataState": {
- "type": "string",
- "x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/models"
- },
"NotFound": {
"type": "object",
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
@@ -3255,7 +3363,6 @@
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
},
"alertGroup": {
- "description": "AlertGroup alert group",
"properties": {
"alerts": {
"description": "alerts",
@@ -3277,7 +3384,9 @@
"labels",
"receiver"
],
- "type": "object"
+ "type": "object",
+ "x-go-name": "AlertGroup",
+ "x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
},
"alertGroups": {
"description": "AlertGroups alert groups",
@@ -3530,12 +3639,11 @@
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
},
"gettableSilences": {
+ "description": "GettableSilences gettable silences",
"items": {
"$ref": "#/definitions/gettableSilence"
},
- "type": "array",
- "x-go-name": "GettableSilences",
- "x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
+ "type": "array"
},
"labelSet": {
"additionalProperties": {
@@ -3664,6 +3772,7 @@
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
},
"postableSilence": {
+ "description": "PostableSilence postable silence",
"properties": {
"comment": {
"description": "comment",
@@ -3703,9 +3812,7 @@
"matchers",
"startsAt"
],
- "type": "object",
- "x-go-name": "PostableSilence",
- "x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
+ "type": "object"
},
"receiver": {
"properties": {
@@ -5676,7 +5783,7 @@
"operationId": "RouteDeleteContactpoints",
"parameters": [
{
- "description": "ContactPointUID should be the contact point UID identifier",
+ "description": "UID should be the contact point unique identifier",
"in": "path",
"name": "UID",
"required": true,
@@ -5709,7 +5816,7 @@
"operationId": "RoutePutContactpoint",
"parameters": [
{
- "description": "ContactPointUID should be the contact point UID identifier",
+ "description": "UID should be the contact point unique identifier",
"in": "path",
"name": "UID",
"required": true,
diff --git a/pkg/services/ngalert/api/tooling/spec.json b/pkg/services/ngalert/api/tooling/spec.json
index ee3e57b7a13..cdbeaa4b219 100644
--- a/pkg/services/ngalert/api/tooling/spec.json
+++ b/pkg/services/ngalert/api/tooling/spec.json
@@ -1871,7 +1871,7 @@
"parameters": [
{
"type": "string",
- "description": "ContactPointUID should be the contact point UID identifier",
+ "description": "UID should be the contact point unique identifier",
"name": "UID",
"in": "path",
"required": true
@@ -1912,7 +1912,7 @@
"parameters": [
{
"type": "string",
- "description": "ContactPointUID should be the contact point UID identifier",
+ "description": "UID should be the contact point unique identifier",
"name": "UID",
"in": "path",
"required": true
@@ -2591,31 +2591,100 @@
},
"AlertRule": {
"type": "object",
+ "required": [
+ "orgID",
+ "folderUID",
+ "ruleGroup",
+ "title",
+ "condition",
+ "data",
+ "noDataState",
+ "execErrState",
+ "for"
+ ],
"properties": {
"annotations": {
"type": "object",
"additionalProperties": {
"type": "string"
},
- "x-go-name": "Annotations"
+ "x-go-name": "Annotations",
+ "example": {
+ "runbook_url": "https://supercoolrunbook.com/page/13"
+ }
},
"condition": {
"type": "string",
- "x-go-name": "Condition"
+ "x-go-name": "Condition",
+ "example": "A"
},
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/AlertQuery"
},
- "x-go-name": "Data"
+ "x-go-name": "Data",
+ "example": [
+ {
+ "datasourceUid": "-100",
+ "model": {
+ "conditions": [
+ {
+ "evaluator": {
+ "params": [
+ 0,
+ 0
+ ],
+ "type": "gt"
+ },
+ "operator": {
+ "type": "and"
+ },
+ "query": {
+ "params": []
+ },
+ "reducer": {
+ "params": [],
+ "type": "avg"
+ },
+ "type": "query"
+ }
+ ],
+ "datasource": {
+ "type": "__expr__",
+ "uid": "__expr__"
+ },
+ "expression": "1 == 1",
+ "hide": false,
+ "intervalMs": 1000,
+ "maxDataPoints": 43200,
+ "refId": "A",
+ "type": "math"
+ },
+ "queryType": "",
+ "refId": "A",
+ "relativeTimeRange": {
+ "from": 0,
+ "to": 0
+ }
+ }
+ ]
},
"execErrState": {
- "$ref": "#/definitions/ExecutionErrorState"
+ "description": "\nAlerting AlertingErrState\nError ErrorErrState\nOK OkErrState",
+ "type": "string",
+ "enum": [
+ "Alerting",
+ "Error",
+ "OK"
+ ],
+ "x-go-enum-desc": "Alerting AlertingErrState\nError ErrorErrState\nOK OkErrState",
+ "x-go-name": "ExecErrState"
},
"folderUID": {
"type": "string",
- "x-go-name": "FolderUID"
+ "x-go-name": "FolderUID",
+ "example": "project_x"
},
"for": {
"$ref": "#/definitions/Duration"
@@ -2630,10 +2699,21 @@
"additionalProperties": {
"type": "string"
},
- "x-go-name": "Labels"
+ "x-go-name": "Labels",
+ "example": {
+ "team": "sre-team-1"
+ }
},
"noDataState": {
- "$ref": "#/definitions/NoDataState"
+ "description": "\nAlerting Alerting\nNoData NoData\nOK OK",
+ "type": "string",
+ "enum": [
+ "Alerting",
+ "NoData",
+ "OK"
+ ],
+ "x-go-enum-desc": "Alerting Alerting\nNoData NoData\nOK OK",
+ "x-go-name": "NoDataState"
},
"orgID": {
"type": "integer",
@@ -2645,11 +2725,17 @@
},
"ruleGroup": {
"type": "string",
- "x-go-name": "RuleGroup"
+ "maxLength": 190,
+ "minLength": 1,
+ "x-go-name": "RuleGroup",
+ "example": "eval_group_1"
},
"title": {
"type": "string",
- "x-go-name": "Title"
+ "maxLength": 190,
+ "minLength": 1,
+ "x-go-name": "Title",
+ "example": "Always firing"
},
"uid": {
"type": "string",
@@ -2658,7 +2744,8 @@
"updated": {
"type": "string",
"format": "date-time",
- "x-go-name": "Updated"
+ "x-go-name": "Updated",
+ "readOnly": true
}
},
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
@@ -3068,31 +3155,60 @@
"EmbeddedContactPoint": {
"description": "EmbeddedContactPoint is the contact point type that is used\nby grafanas embedded alertmanager implementation.",
"type": "object",
+ "required": [
+ "type",
+ "settings"
+ ],
"properties": {
"disableResolveMessage": {
"type": "boolean",
- "x-go-name": "DisableResolveMessage"
+ "x-go-name": "DisableResolveMessage",
+ "example": false
},
"name": {
"description": "Name is used as grouping key in the UI. Contact points with the\nsame name will be grouped in the UI.",
"type": "string",
- "x-go-name": "Name"
+ "x-go-name": "Name",
+ "example": "webhook_1"
},
"provenance": {
"type": "string",
- "x-go-name": "Provenance"
+ "x-go-name": "Provenance",
+ "readOnly": true
},
"settings": {
"$ref": "#/definitions/Json"
},
"type": {
"type": "string",
- "x-go-name": "Type"
+ "enum": [
+ "alertmanager",
+ " dingding",
+ " discord",
+ " email",
+ " googlechat",
+ " kafka",
+ " line",
+ " opsgenie",
+ " pagerduty",
+ " pushover",
+ " sensugo",
+ " slack",
+ " teams",
+ " telegram",
+ " threema",
+ " victorops",
+ " webhook",
+ " wecom"
+ ],
+ "x-go-name": "Type",
+ "example": "webhook"
},
"uid": {
- "description": "UID is the unique identifier of the contact point. This will be\nautomatically set be the Grafana.",
+ "description": "UID is the unique identifier of the contact point. The UID can be\nset by the user.",
"type": "string",
- "x-go-name": "UID"
+ "x-go-name": "UID",
+ "example": "my_external_reference"
}
},
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
@@ -3146,10 +3262,6 @@
"EvalQueriesResponse": {
"$ref": "#/definitions/EvalQueriesResponse"
},
- "ExecutionErrorState": {
- "type": "string",
- "x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/models"
- },
"ExtendedReceiver": {
"type": "object",
"properties": {
@@ -3951,10 +4063,6 @@
},
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
- "NoDataState": {
- "type": "string",
- "x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/models"
- },
"NotFound": {
"type": "object",
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
@@ -5654,7 +5762,6 @@
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
},
"alertGroup": {
- "description": "AlertGroup alert group",
"type": "object",
"required": [
"alerts",
@@ -5677,6 +5784,8 @@
"$ref": "#/definitions/receiver"
}
},
+ "x-go-name": "AlertGroup",
+ "x-go-package": "github.com/prometheus/alertmanager/api/v2/models",
"$ref": "#/definitions/alertGroup"
},
"alertGroups": {
@@ -5934,12 +6043,11 @@
"$ref": "#/definitions/gettableSilence"
},
"gettableSilences": {
+ "description": "GettableSilences gettable silences",
"type": "array",
"items": {
"$ref": "#/definitions/gettableSilence"
},
- "x-go-name": "GettableSilences",
- "x-go-package": "github.com/prometheus/alertmanager/api/v2/models",
"$ref": "#/definitions/gettableSilences"
},
"labelSet": {
@@ -6069,6 +6177,7 @@
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
},
"postableSilence": {
+ "description": "PostableSilence postable silence",
"type": "object",
"required": [
"comment",
@@ -6109,8 +6218,6 @@
"x-go-name": "StartsAt"
}
},
- "x-go-name": "PostableSilence",
- "x-go-package": "github.com/prometheus/alertmanager/api/v2/models",
"$ref": "#/definitions/postableSilence"
},
"receiver": {
diff --git a/pkg/services/ngalert/models/alert_rule.go b/pkg/services/ngalert/models/alert_rule.go
index 15cffa0251a..827e0b26884 100644
--- a/pkg/services/ngalert/models/alert_rule.go
+++ b/pkg/services/ngalert/models/alert_rule.go
@@ -24,6 +24,7 @@ var (
ErrAlertRuleUniqueConstraintViolation = errors.New("a conflicting alert rule is found: rule title under the same organisation and folder should be unique")
)
+// swagger:enum NoDataState
type NoDataState string
func (noDataState NoDataState) String() string {
@@ -49,6 +50,7 @@ const (
OK NoDataState = "OK"
)
+// swagger:enum ExecutionErrorState
type ExecutionErrorState string
func (executionErrorState ExecutionErrorState) String() string {
diff --git a/pkg/services/ngalert/provisioning/alert_rules.go b/pkg/services/ngalert/provisioning/alert_rules.go
index 7de30f4824c..04e4e9a8987 100644
--- a/pkg/services/ngalert/provisioning/alert_rules.go
+++ b/pkg/services/ngalert/provisioning/alert_rules.go
@@ -53,6 +53,9 @@ func (service *AlertRuleService) GetAlertRule(ctx context.Context, orgID int64,
return *query.Result, provenance, nil
}
+// CreateAlertRule creates a new alert rule. This function will ignore any
+// interval that is set in the rule struct and use the already existing group
+// interval or the default one.
func (service *AlertRuleService) CreateAlertRule(ctx context.Context, rule models.AlertRule, provenance models.Provenance) (models.AlertRule, error) {
if rule.UID == "" {
rule.UID = util.GenerateShortUID()
@@ -117,6 +120,9 @@ func (service *AlertRuleService) UpdateRuleGroup(ctx context.Context, orgID int6
})
}
+// CreateAlertRule creates a new alert rule. This function will ignore any
+// interval that is set in the rule struct and fetch the current group interval
+// from database.
func (service *AlertRuleService) UpdateAlertRule(ctx context.Context, rule models.AlertRule, provenance models.Provenance) (models.AlertRule, error) {
storedRule, storedProvenance, err := service.GetAlertRule(ctx, rule.OrgID, rule.UID)
if err != nil {