2022-06-09 10:08:07 +01:00
---
2022-10-26 12:32:47 -04:00
canonical: https://grafana.com/docs/oncall/latest/oncall-api-reference/alertgroups/
2022-06-09 10:08:07 +01:00
title: Alert groups HTTP API
2024-08-15 15:29:56 -04:00
weight: 0
2024-08-09 15:24:24 +01:00
refs:
pagination:
- pattern: /docs/oncall/
destination: /docs/oncall/< ONCALL_VERSION > /oncall-api-reference/#pagination
- pattern: /docs/grafana-cloud/
destination: /docs/grafana-cloud/alerting-and-irm/oncall/oncall-api-reference/#pagination
2022-06-09 10:08:07 +01:00
---
2022-06-03 08:09:47 -06:00
2024-06-17 11:31:35 -04:00
# Alert groups HTTP API
## List alert groups
2022-06-03 08:09:47 -06:00
```shell
curl "{{API_URL}}/api/v1/alert_groups/" \
--request GET \
--header "Authorization: meowmeowmeow" \
2022-06-09 10:08:07 +01:00
--header "Content-Type: application/json"
2022-06-03 08:09:47 -06:00
```
The above command returns JSON structured in the following way:
```json
{
2022-06-09 10:08:07 +01:00
"count": 1,
"next": null,
"previous": null,
"results": [
{
"id": "I68T24C13IFW1",
"integration_id": "CFRPV98RPR1U8",
"route_id": "RIYGUJXCPFHXY",
"alerts_count": 3,
"state": "resolved",
"created_at": "2020-05-19T12:37:01.430444Z",
"resolved_at": "2020-05-19T13:37:01.429805Z",
"acknowledged_at": null,
2024-02-05 11:02:55 -03:00
"acknowledged_by": null,
"resolved_by": "UCGEIXI1MR1NZ",
2022-09-22 15:17:17 +02:00
"title": "Memory above 90% threshold",
"permalinks": {
2022-09-28 16:59:57 +02:00
"slack": "https://ghostbusters.slack.com/archives/C1H9RESGA/p135854651500008",
"telegram": "https://t.me/c/5354/1234?thread=1234"
2024-03-07 00:50:33 +05:30
},
"silenced_at": "2020-05-19T13:37:01.429805Z",
2024-10-03 01:09:50 +08:00
"last_alert": {
"id": "AA74DN7T4JQB6",
"alert_group_id": "I68T24C13IFW1",
"created_at": "2020-05-11T20:08:43Z",
"payload": {
"state": "alerting",
"title": "[Alerting] Test notification",
"ruleId": 0,
"message": "Someone is testing the alert notification within Grafana.",
"ruleUrl": "{{API_URL}}/",
"ruleName": "Test notification",
"evalMatches": [
{
"tags": null,
"value": 100,
"metric": "High value"
},
{
"tags": null,
"value": 200,
"metric": "Higher Value"
}
]
}
},
2022-06-09 10:08:07 +01:00
}
augment API response pagination attributes (#2471)
# What this PR does
This PR:
- adds a few attributes to paginated API responses
- removes channel filter "send demo alert" internal API endpoint + tests
(this endpoint was marked as deprecated + not consumed by the web UI)
With the new paginated API response schema, the web UI will no longer
need to:
- hardcode `ITEMS_PER_PAGE` for each table
- manually calculate total number of pages
(these two things ☝️ will be done in
https://github.com/grafana/oncall/issues/2476)
For `GET /api/internal/v1/alertgroups` the response will now look like
this:
```diff
{
"next": <url> | None,
"previous": <url> | None,
"results": [],
++ "page_size": <int>
}
```
For all other paginated API responses, the response will now look like:
```diff
{
"count": <int>,
"next": <url> | None,
"previous": <url> | None,
"results": [],
++ "page_size": <int>,
++ "current_page_number": <int>,
++ "total_pages": <int>
}
```
## TODO
- [x] update public API docs to include these new attributes
## Checklist
- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-07-14 17:19:40 +02:00
],
"current_page_number": 1,
"page_size": 50,
"total_pages": 1
2022-06-03 08:09:47 -06:00
}
```
2024-08-09 15:24:24 +01:00
> **Note**: The response is [paginated](ref:pagination). You may need to make multiple requests to get all records.
2022-06-03 08:09:47 -06:00
These available filter parameters should be provided as `GET` arguments:
2024-08-15 16:58:25 -03:00
- `id` (Exact match, alert group ID)
- `route_id` (Exact match, route ID)
- `integration_id` (Exact match, integration ID)
- `label` (Matching labels, can be passed multiple times; expected format: `key1:value1` )
- `team_id` (Exact match, team ID)
- `started_at` (A "{start}_{end}" ISO 8601 timestamp range; expected format: `%Y-%m-%dT%H:%M:%S_%Y-%m-%dT%H:%M:%S` )
- `state` (Possible values: `new` , `acknowledged` , `resolved` or `silenced` )
2022-06-03 08:09:47 -06:00
**HTTP request**
`GET {{API_URL}}/api/v1/alert_groups/`
2024-06-17 11:31:35 -04:00
## Alert group details
2024-02-05 11:02:55 -03:00
```shell
curl "{{API_URL}}/api/v1/alert_groups/I68T24C13IFW1" \
--request GET \
--header "Authorization: meowmeowmeow"
```
**HTTP request**
`GET {{API_URL}}/api/v1/alert_groups/<ALERT_GROUP_ID>`
2024-06-17 11:31:35 -04:00
## Acknowledge an alert group
2023-10-05 09:46:48 +01:00
```shell
curl "{{API_URL}}/api/v1/alert_groups/I68T24C13IFW1/acknowledge" \
--request POST \
--header "Authorization: meowmeowmeow"
```
**HTTP request**
`POST {{API_URL}}/api/v1/alert_groups/<ALERT_GROUP_ID>/acknowledge`
2024-06-17 11:31:35 -04:00
## Unacknowledge an alert group
2023-10-05 09:46:48 +01:00
```shell
curl "{{API_URL}}/api/v1/alert_groups/I68T24C13IFW1/unacknowledge" \
--request POST \
--header "Authorization: meowmeowmeow"
```
**HTTP request**
`POST {{API_URL}}/api/v1/alert_groups/<ALERT_GROUP_ID>/unacknowledge`
2024-06-17 11:31:35 -04:00
## Resolve an alert group
2023-10-05 09:46:48 +01:00
```shell
curl "{{API_URL}}/api/v1/alert_groups/I68T24C13IFW1/resolve" \
--request POST \
--header "Authorization: meowmeowmeow"
```
**HTTP request**
`POST {{API_URL}}/api/v1/alert_groups/<ALERT_GROUP_ID>/resolve`
2024-06-17 11:31:35 -04:00
## Unresolve an alert group
2023-10-05 09:46:48 +01:00
```shell
curl "{{API_URL}}/api/v1/alert_groups/I68T24C13IFW1/unresolve" \
--request POST \
--header "Authorization: meowmeowmeow"
```
**HTTP request**
`POST {{API_URL}}/api/v1/alert_groups/<ALERT_GROUP_ID>/unresolve`
2024-09-23 18:03:12 +05:30
## Silence an alert group
```shell
curl "{{API_URL}}/api/v1/alert_groups/I68T24C13IFW1/silence" \
--request POST \
--header "Authorization: meowmeowmeow" \
--header "Content-Type: application/json" \
--data '{
"delay": 10800
}'
```
**HTTP request**
`POST {{API_URL}}/api/v1/alert_groups/<ALERT_GROUP_ID>/silence`
| Parameter | Required | Description |
|-----------|:--------:|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `delay` | Yes | The duration of silence in seconds, `-1` for silencing the alert forever |
## Unsilence an alert group
```shell
curl "{{API_URL}}/api/v1/alert_groups/I68T24C13IFW1/unsilence" \
--request POST \
--header "Authorization: meowmeowmeow"
```
**HTTP request**
`POST {{API_URL}}/api/v1/alert_groups/<ALERT_GROUP_ID>/unsilence`
2024-06-17 11:31:35 -04:00
## Delete an alert group
2022-06-03 08:09:47 -06:00
```shell
curl "{{API_URL}}/api/v1/alert_groups/I68T24C13IFW1/" \
--request DELETE \
--header "Authorization: meowmeowmeow" \
--header "Content-Type: application/json" \
--data '{
"mode": "wipe"
}'
```
2023-10-05 14:32:40 +01:00
| Parameter | Required | Description |
|-----------|:--------:|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `mode` | No | The default value for this parameter is `wipe` . Using `wipe` will delete the content of the alert group but keep the metadata, which is helpful if you've sent sensitive information to OnCall. On the other hand, passing `delete` will fully erase the alert group and its metadata, as well as delete related messages in Slack and other platforms. |
2022-06-03 08:09:47 -06:00
2022-12-01 14:26:54 +01:00
> **NOTE:** `DELETE` can take a few moments to delete alert groups because Grafana OnCall interacts with 3rd party APIs
> such as Slack. Please check objects using `GET` to be sure the data is removed.
2022-06-03 08:09:47 -06:00
**HTTP request**
2022-06-09 10:08:07 +01:00
`DELETE {{API_URL}}/api/v1/alert_groups/<ALERT_GROUP_ID>`