Alerting: Add endpoint to revert to a previous alertmanager configuration (#65751)

* Alerting: Add endpoint to revert to a previous alertmanager configuration

This endpoint is meant to be used in conjunction with /api/alertmanager/grafana/config/history to
revert to a previously applied alertmanager configuration. This is done by ID instead of raw config
string in order to avoid secure field complications.
This commit is contained in:
Matthew Jacobson
2023-04-05 14:10:03 -04:00
committed by GitHub
parent 6c6427e63f
commit 85f738cdf9
16 changed files with 393 additions and 9 deletions
+41 -2
View File
@@ -3432,7 +3432,6 @@
"type": "object"
},
"URL": {
"description": "The general form represented is:\n\n[scheme:][//[userinfo@]host][/]path[?query][#fragment]\n\nURLs that do not start with a slash after the scheme are interpreted as:\n\nscheme:opaque[?query][#fragment]\n\nNote that the Path field is stored in decoded form: /%47%6f%2f becomes /Go/.\nA consequence is that it is impossible to tell which slashes in the Path were\nslashes in the raw URL and which were %2f. This distinction is rarely important,\nbut when it is, the code should use the EscapedPath method, which preserves\nthe original encoding of Path.\n\nThe RawPath field is an optional field which is only set when the default\nencoding of Path is different from the escaped path. See the EscapedPath method\nfor more details.\n\nURL's String method uses the EscapedPath method to obtain the path.",
"properties": {
"ForceQuery": {
"type": "boolean"
@@ -3468,7 +3467,7 @@
"$ref": "#/definitions/Userinfo"
}
},
"title": "A URL represents a parsed URL (technically, a URI reference).",
"title": "URL is a custom URL type that allows validation at configuration load time.",
"type": "object"
},
"Userinfo": {
@@ -3882,6 +3881,7 @@
"type": "object"
},
"gettableSilences": {
"description": "GettableSilences gettable silences",
"items": {
"$ref": "#/definitions/gettableSilence"
},
@@ -4629,6 +4629,45 @@
]
}
},
"/api/alertmanager/grafana/config/history/{id}/_activate": {
"post": {
"description": "revert Alerting configuration to the historical configuration specified by the given id",
"operationId": "RoutePostGrafanaAlertingConfigHistoryActivate",
"parameters": [
{
"description": "Id should be the id of the GettableHistoricUserConfig",
"format": "int64",
"in": "path",
"name": "id",
"required": true,
"type": "integer"
}
],
"responses": {
"202": {
"description": "Ack",
"schema": {
"$ref": "#/definitions/Ack"
}
},
"400": {
"description": "ValidationError",
"schema": {
"$ref": "#/definitions/ValidationError"
}
},
"404": {
"description": "NotFound",
"schema": {
"$ref": "#/definitions/NotFound"
}
}
},
"tags": [
"alertmanager"
]
}
},
"/api/alertmanager/{DatasourceUID}/api/v2/alerts": {
"get": {
"description": "get alertmanager alerts",