[v9.5.x] Alerting: Allow provenance disable in alerting provisioning API (#66761)
Alerting: Allow provenance disable in alerting provisioning API (#63650)
* Allow provenance None in alert rule update and rule group replace
* Allow provenance None in contact point update
* Allow updating policies to none by sending x-disable-provenance header
* Allow mute timings to disable provenance with x-disable-provenance header
* Allow disabling provenance by using x-disable-provenance header
* Add provenance helper to lower the cyclomatic complexity
* Do not downgrade provenance except un ReplaceRuleGroup
* Add function explanation and change error handling
* Add docs for x-disable-provenance changes (#66300)
* Add docs for x-disable-provenance changes
* Apply suggestions from code review
Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>
* Update _index.md
---------
Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>
* Update docs/sources/alerting/set-up/provision-alerting-resources/_index.md
Co-authored-by: George Robinson <george.robinson@grafana.com>
* Add error message check in tests
* Change docs
---------
Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>
Co-authored-by: George Robinson <george.robinson@grafana.com>
(cherry picked from commit f64a89727e)
Co-authored-by: Alex Moreno <alexander.moreno@grafana.com>
This commit is contained in:
co-authored by
Alex Moreno
parent
81b78f3af4
commit
3fb37e26b5
@@ -24,22 +24,21 @@ There are three options to choose from:
|
||||
|
||||
For more information on the Alerting Provisioning HTTP API, refer to [Alerting provisioning API](https://grafana.com/docs/grafana/latest/developers/http_api/alerting_provisioning/).
|
||||
|
||||
**Note:**
|
||||
|
||||
Typically, you cannot edit API-provisioned alert rules from the Grafana UI.
|
||||
|
||||
In order to enable editing, add the x-disable-provenance header to the following requests when creating or editing your alert rules in the API:
|
||||
|
||||
POST /api/v1/provisioning/alert-rules
|
||||
|
||||
PUT /api/v1/provisioning/alert-rules/{UID}
|
||||
|
||||
1. Provision your alerting resources using Terraform.
|
||||
|
||||
**Note:**
|
||||
|
||||
Currently, provisioning for Grafana Alerting supports alert rules, contact points, mute timings, and templates. Provisioned alerting resources using file provisioning or Terraform can only be edited in the source that created them and not from within Grafana or any other source. For example, if you provision your alerting resources using files from disk, you cannot edit the data in Terraform or from within Grafana.
|
||||
|
||||
To allow editing of provisioned resources in the Grafana UI, add the `X-Disable-Provenance` header to the following requests in the API:
|
||||
|
||||
- `POST /api/v1/provisioning/alert-rules`
|
||||
- `PUT /api/v1/provisioning/folder/{FolderUID}/rule-groups/{Group}` (calling this endpoint will change provenance for all alert rules within the alert group)
|
||||
- `POST /api/v1/provisioning/contact-points`
|
||||
- `POST /api/v1/provisioning/mute-timings`
|
||||
- `PUT /api/v1/provisioning/policies`
|
||||
- `PUT /api/v1/provisioning/templates/{name}`
|
||||
|
||||
**Useful Links:**
|
||||
|
||||
[Grafana provisioning](/docs/grafana/latest/administration/provisioning/)
|
||||
|
||||
@@ -96,9 +96,10 @@ DELETE /api/v1/provisioning/alert-rules/{UID}
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Source | Type | Go type | Separator | Required | Default | Description |
|
||||
| ---- | ------ | ------ | -------- | --------- | :------: | ------- | -------------- |
|
||||
| UID | `path` | string | `string` | | ✓ | | Alert rule UID |
|
||||
| Name | Source | Type | Go type | Separator | Required | Default | Description |
|
||||
| -------------------- | -------- | ------ | -------- | --------- | :------: | ------- | -------------- |
|
||||
| UID | `path` | string | `string` | | ✓ | | Alert rule UID |
|
||||
| X-Disable-Provenance | `header` | string | `string` | | | | |
|
||||
|
||||
#### All responses
|
||||
|
||||
@@ -637,9 +638,10 @@ POST /api/v1/provisioning/contact-points
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Source | Type | Go type | Separator | Required | Default | Description |
|
||||
| ---- | ------ | ----------------------------------------------- | ----------------------------- | --------- | :------: | ------- | ----------- |
|
||||
| Body | `body` | [EmbeddedContactPoint](#embedded-contact-point) | `models.EmbeddedContactPoint` | | | | |
|
||||
| Name | Source | Type | Go type | Separator | Required | Default | Description |
|
||||
| -------------------- | -------- | ----------------------------------------------- | ----------------------------- | --------- | :------: | ------- | ----------- |
|
||||
| X-Disable-Provenance | `header` | string | `string` | | | | |
|
||||
| Body | `body` | [EmbeddedContactPoint](#embedded-contact-point) | `models.EmbeddedContactPoint` | | | | |
|
||||
|
||||
#### All responses
|
||||
|
||||
@@ -678,9 +680,10 @@ POST /api/v1/provisioning/mute-timings
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Source | Type | Go type | Separator | Required | Default | Description |
|
||||
| ---- | ------ | --------------------------------------- | ------------------------- | --------- | :------: | ------- | ----------- |
|
||||
| Body | `body` | [MuteTimeInterval](#mute-time-interval) | `models.MuteTimeInterval` | | | | |
|
||||
| Name | Source | Type | Go type | Separator | Required | Default | Description |
|
||||
| -------------------- | -------- | --------------------------------------- | ------------------------- | --------- | :------: | ------- | ----------- |
|
||||
| X-Disable-Provenance | `header` | string | `string` | | | | |
|
||||
| Body | `body` | [MuteTimeInterval](#mute-time-interval) | `models.MuteTimeInterval` | | | | |
|
||||
|
||||
#### All responses
|
||||
|
||||
@@ -762,11 +765,12 @@ PUT /api/v1/provisioning/folder/{FolderUID}/rule-groups/{Group}
|
||||
|
||||
#### 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` | | | | |
|
||||
| Name | Source | Type | Go type | Separator | Required | Default | Description |
|
||||
| -------------------- | -------- | ----------------------------------- | ----------------------- | --------- | :------: | ------- | ----------- |
|
||||
| FolderUID | `path` | string | `string` | | ✓ | | |
|
||||
| Group | `path` | string | `string` | | ✓ | | |
|
||||
| X-Disable-Provenance | `header` | string | `string` | | | | |
|
||||
| Body | `body` | [AlertRuleGroup](#alert-rule-group) | `models.AlertRuleGroup` | | | | |
|
||||
|
||||
#### All responses
|
||||
|
||||
@@ -805,10 +809,11 @@ PUT /api/v1/provisioning/contact-points/{UID}
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Source | Type | Go type | Separator | Required | Default | Description |
|
||||
| ---- | ------ | ----------------------------------------------- | ----------------------------- | --------- | :------: | ------- | ------------------------------------------ |
|
||||
| UID | `path` | string | `string` | | ✓ | | UID is the contact point unique identifier |
|
||||
| Body | `body` | [EmbeddedContactPoint](#embedded-contact-point) | `models.EmbeddedContactPoint` | | | | |
|
||||
| Name | Source | Type | Go type | Separator | Required | Default | Description |
|
||||
| -------------------- | -------- | ----------------------------------------------- | ----------------------------- | --------- | :------: | ------- | ------------------------------------------ |
|
||||
| UID | `path` | string | `string` | | ✓ | | UID is the contact point unique identifier |
|
||||
| X-Disable-Provenance | `header` | string | `string` | | | | |
|
||||
| Body | `body` | [EmbeddedContactPoint](#embedded-contact-point) | `models.EmbeddedContactPoint` | | | | |
|
||||
|
||||
#### All responses
|
||||
|
||||
@@ -847,10 +852,11 @@ PUT /api/v1/provisioning/mute-timings/{name}
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Source | Type | Go type | Separator | Required | Default | Description |
|
||||
| ---- | ------ | --------------------------------------- | ------------------------- | --------- | :------: | ------- | ---------------- |
|
||||
| name | `path` | string | `string` | | ✓ | | Mute timing name |
|
||||
| Body | `body` | [MuteTimeInterval](#mute-time-interval) | `models.MuteTimeInterval` | | | | |
|
||||
| Name | Source | Type | Go type | Separator | Required | Default | Description |
|
||||
| -------------------- | -------- | --------------------------------------- | ------------------------- | --------- | :------: | ------- | ---------------- |
|
||||
| name | `path` | string | `string` | | ✓ | | Mute timing name |
|
||||
| X-Disable-Provenance | `header` | string | `string` | | | | |
|
||||
| Body | `body` | [MuteTimeInterval](#mute-time-interval) | `models.MuteTimeInterval` | | | | |
|
||||
|
||||
#### All responses
|
||||
|
||||
@@ -889,9 +895,10 @@ PUT /api/v1/provisioning/policies
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Source | Type | Go type | Separator | Required | Default | Description |
|
||||
| ---- | ------ | --------------- | -------------- | --------- | :------: | ------- | ---------------------------------------- |
|
||||
| Body | `body` | [Route](#route) | `models.Route` | | | | The new notification routing tree to use |
|
||||
| Name | Source | Type | Go type | Separator | Required | Default | Description |
|
||||
| -------------------- | -------- | --------------- | -------------- | --------- | :------: | ------- | ---------------------------------------- |
|
||||
| X-Disable-Provenance | `header` | string | `string` | | | | |
|
||||
| Body | `body` | [Route](#route) | `models.Route` | | | | The new notification routing tree to use |
|
||||
|
||||
#### All responses
|
||||
|
||||
@@ -930,10 +937,11 @@ PUT /api/v1/provisioning/templates/{name}
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Source | Type | Go type | Separator | Required | Default | Description |
|
||||
| ---- | ------ | ------------------------------------------------------------- | ------------------------------------ | --------- | :------: | ------- | ------------- |
|
||||
| name | `path` | string | `string` | | ✓ | | Template Name |
|
||||
| Body | `body` | [NotificationTemplateContent](#notification-template-content) | `models.NotificationTemplateContent` | | | | |
|
||||
| Name | Source | Type | Go type | Separator | Required | Default | Description |
|
||||
| -------------------- | -------- | ------------------------------------------------------------- | ------------------------------------ | --------- | :------: | ------- | ------------- |
|
||||
| name | `path` | string | `string` | | ✓ | | Template Name |
|
||||
| X-Disable-Provenance | `header` | string | `string` | | | | |
|
||||
| Body | `body` | [NotificationTemplateContent](#notification-template-content) | `models.NotificationTemplateContent` | | | | |
|
||||
|
||||
#### All responses
|
||||
|
||||
|
||||
Reference in New Issue
Block a user