Alerting: Rule Modify Export APIs (#75322)
* extend RuleStore interface to get namespace by UID * add new export API endpoints * implement request handlers * update authorization and wire handlers to paths * add folder error matchers to errorToResponse * add tests for export methods
This commit is contained in:
@@ -137,7 +137,7 @@
|
||||
"type": "string"
|
||||
},
|
||||
"relativeTimeRange": {
|
||||
"$ref": "#/definitions/RelativeTimeRange"
|
||||
"$ref": "#/definitions/RelativeTimeRangeExport"
|
||||
}
|
||||
},
|
||||
"title": "AlertQueryExport is the provisioned export of models.AlertQuery.",
|
||||
@@ -418,6 +418,9 @@
|
||||
"for": {
|
||||
"type": "string"
|
||||
},
|
||||
"keep_firing_for": {
|
||||
"type": "string"
|
||||
},
|
||||
"labels": {
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
@@ -1223,6 +1226,12 @@
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"msteams_configs": {
|
||||
"items": {
|
||||
"$ref": "#/definitions/MSTeamsConfig"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"name": {
|
||||
"description": "A unique identifier for this receiver.",
|
||||
"type": "string"
|
||||
@@ -1257,12 +1266,6 @@
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"teams_configs": {
|
||||
"items": {
|
||||
"$ref": "#/definitions/MSTeamsConfig"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"telegram_configs": {
|
||||
"items": {
|
||||
"$ref": "#/definitions/TelegramConfig"
|
||||
@@ -1316,6 +1319,9 @@
|
||||
"grafana_alert": {
|
||||
"$ref": "#/definitions/GettableGrafanaRule"
|
||||
},
|
||||
"keep_firing_for": {
|
||||
"type": "string"
|
||||
},
|
||||
"labels": {
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
@@ -2289,6 +2295,12 @@
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"msteams_configs": {
|
||||
"items": {
|
||||
"$ref": "#/definitions/MSTeamsConfig"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"name": {
|
||||
"description": "A unique identifier for this receiver.",
|
||||
"type": "string"
|
||||
@@ -2323,12 +2335,6 @@
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"teams_configs": {
|
||||
"items": {
|
||||
"$ref": "#/definitions/MSTeamsConfig"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"telegram_configs": {
|
||||
"items": {
|
||||
"$ref": "#/definitions/TelegramConfig"
|
||||
@@ -2382,6 +2388,9 @@
|
||||
"grafana_alert": {
|
||||
"$ref": "#/definitions/PostableGrafanaRule"
|
||||
},
|
||||
"keep_firing_for": {
|
||||
"type": "string"
|
||||
},
|
||||
"labels": {
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
@@ -2753,6 +2762,9 @@
|
||||
"token_file": {
|
||||
"type": "string"
|
||||
},
|
||||
"ttl": {
|
||||
"type": "string"
|
||||
},
|
||||
"url": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -2869,6 +2881,12 @@
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"msteams_configs": {
|
||||
"items": {
|
||||
"$ref": "#/definitions/MSTeamsConfig"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"name": {
|
||||
"description": "A unique identifier for this receiver.",
|
||||
"type": "string"
|
||||
@@ -2903,12 +2921,6 @@
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"teams_configs": {
|
||||
"items": {
|
||||
"$ref": "#/definitions/MSTeamsConfig"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"telegram_configs": {
|
||||
"items": {
|
||||
"$ref": "#/definitions/TelegramConfig"
|
||||
@@ -2978,6 +2990,19 @@
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"RelativeTimeRangeExport": {
|
||||
"properties": {
|
||||
"from": {
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"to": {
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"ResponseDetails": {
|
||||
"properties": {
|
||||
"msg": {
|
||||
@@ -3857,7 +3882,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"
|
||||
@@ -3893,7 +3917,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": {
|
||||
@@ -4073,7 +4097,6 @@
|
||||
"type": "object"
|
||||
},
|
||||
"alertGroup": {
|
||||
"description": "AlertGroup alert group",
|
||||
"properties": {
|
||||
"alerts": {
|
||||
"description": "alerts",
|
||||
@@ -4202,6 +4225,7 @@
|
||||
"type": "object"
|
||||
},
|
||||
"gettableAlert": {
|
||||
"description": "GettableAlert gettable alert",
|
||||
"properties": {
|
||||
"annotations": {
|
||||
"$ref": "#/definitions/labelSet"
|
||||
@@ -4257,6 +4281,7 @@
|
||||
"type": "object"
|
||||
},
|
||||
"gettableAlerts": {
|
||||
"description": "GettableAlerts gettable alerts",
|
||||
"items": {
|
||||
"$ref": "#/definitions/gettableAlert"
|
||||
},
|
||||
@@ -4318,6 +4343,7 @@
|
||||
"type": "array"
|
||||
},
|
||||
"integration": {
|
||||
"description": "Integration integration",
|
||||
"properties": {
|
||||
"lastNotifyAttempt": {
|
||||
"description": "A timestamp indicating the last attempt to deliver a notification regardless of the outcome.\nFormat: date-time",
|
||||
@@ -4461,7 +4487,6 @@
|
||||
"type": "array"
|
||||
},
|
||||
"postableSilence": {
|
||||
"description": "PostableSilence postable silence",
|
||||
"properties": {
|
||||
"comment": {
|
||||
"description": "comment",
|
||||
@@ -5799,6 +5824,67 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/ruler/grafana/api/v1/export/rules": {
|
||||
"get": {
|
||||
"consumes": [
|
||||
"application/json",
|
||||
"application/yaml"
|
||||
],
|
||||
"description": "List rules in provisioning format",
|
||||
"operationId": "RouteGetRulesForExport",
|
||||
"parameters": [
|
||||
{
|
||||
"default": false,
|
||||
"description": "Whether to initiate a download of the file or not.",
|
||||
"in": "query",
|
||||
"name": "download",
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"default": "yaml",
|
||||
"description": "Format of the downloaded file, either yaml or json. Accept header can also be used, but the query parameter will take precedence.",
|
||||
"in": "query",
|
||||
"name": "format",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"description": "UIDs of folders from which to export rules",
|
||||
"in": "query",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": "folderUid",
|
||||
"type": "array"
|
||||
},
|
||||
{
|
||||
"description": "Name of group of rules to export. Must be specified only together with a single folder UID",
|
||||
"in": "query",
|
||||
"name": "group",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"description": "UID of alert rule to export. If specified, parameters folderUid and group must be empty.",
|
||||
"in": "query",
|
||||
"name": "ruleUid",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "AlertingFileExport",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/AlertingFileExport"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": " Not found."
|
||||
}
|
||||
},
|
||||
"tags": [
|
||||
"ruler"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/ruler/grafana/api/v1/rules": {
|
||||
"get": {
|
||||
"description": "List rule groups",
|
||||
@@ -5917,6 +6003,59 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/ruler/grafana/api/v1/rules/{Namespace}/export": {
|
||||
"post": {
|
||||
"consumes": [
|
||||
"application/json",
|
||||
"application/yaml"
|
||||
],
|
||||
"description": "Converts submitted rule group to provisioning format",
|
||||
"operationId": "RoutePostRulesGroupForExport",
|
||||
"parameters": [
|
||||
{
|
||||
"in": "path",
|
||||
"name": "Namespace",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"in": "body",
|
||||
"name": "Body",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/PostableRuleGroupConfig"
|
||||
}
|
||||
},
|
||||
{
|
||||
"default": false,
|
||||
"description": "Whether to initiate a download of the file or not.",
|
||||
"in": "query",
|
||||
"name": "download",
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"default": "yaml",
|
||||
"description": "Format of the downloaded file, either yaml or json. Accept header can also be used, but the query parameter will take precedence.",
|
||||
"in": "query",
|
||||
"name": "format",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "AlertingFileExport",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/AlertingFileExport"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": " Not found."
|
||||
}
|
||||
},
|
||||
"tags": [
|
||||
"ruler"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/ruler/grafana/api/v1/rules/{Namespace}/{Groupname}": {
|
||||
"delete": {
|
||||
"description": "Delete rule group",
|
||||
|
||||
Reference in New Issue
Block a user