Alerting: extend rules export API to filter by folder and group (#74423)

update endpoint `GET /api/v1/provisioning/alert-rules/export` to accept query parameters `folderUid` and `group`
This commit is contained in:
Yuri Tseretyan
2023-09-07 17:34:32 -04:00
committed by GitHub
parent 5cc737bb24
commit 0df3647367
8 changed files with 117 additions and 18 deletions
+17 -3
View File
@@ -3851,6 +3851,7 @@
"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"
@@ -3886,7 +3887,7 @@
"$ref": "#/definitions/Userinfo"
}
},
"title": "URL is a custom URL type that allows validation at configuration load time.",
"title": "A URL represents a parsed URL (technically, a URI reference).",
"type": "object"
},
"Userinfo": {
@@ -4066,7 +4067,6 @@
"type": "object"
},
"alertGroup": {
"description": "AlertGroup alert group",
"properties": {
"alerts": {
"description": "alerts",
@@ -4090,6 +4090,7 @@
"type": "object"
},
"alertGroups": {
"description": "AlertGroups alert groups",
"items": {
"$ref": "#/definitions/alertGroup"
},
@@ -4249,13 +4250,13 @@
"type": "object"
},
"gettableAlerts": {
"description": "GettableAlerts gettable alerts",
"items": {
"$ref": "#/definitions/gettableAlert"
},
"type": "array"
},
"gettableSilence": {
"description": "GettableSilence gettable silence",
"properties": {
"comment": {
"description": "comment",
@@ -4493,6 +4494,7 @@
"type": "object"
},
"receiver": {
"description": "Receiver receiver",
"properties": {
"active": {
"description": "active",
@@ -4684,6 +4686,18 @@
"in": "query",
"name": "format",
"type": "string"
},
{
"description": "UID of folder from which export rules",
"in": "query",
"name": "folderUid",
"type": "string"
},
{
"description": "Name of group of rules to export. Must be specified only together with folder UID",
"in": "query",
"name": "group",
"type": "string"
}
],
"responses": {
@@ -9,7 +9,7 @@ type AlertingFileExport struct {
Policies []NotificationPolicyExport `json:"policies,omitempty" yaml:"policies,omitempty"`
}
// swagger:parameters RouteGetAlertRuleGroupExport RouteGetAlertRuleExport RouteGetAlertRulesExport RouteGetContactpointsExport RouteGetContactpointExport
// swagger:parameters RouteGetAlertRuleGroupExport RouteGetAlertRuleExport RouteGetContactpointsExport RouteGetContactpointExport
type ExportQueryParams struct {
// Whether to initiate a download of the file or not.
// in: query
@@ -71,6 +71,20 @@ import (
// Responses:
// 204: description: The alert rule was deleted successfully.
// swagger:parameters RouteGetAlertRulesExport
type AlertRulesExportParameters struct {
ExportQueryParams
// UID of folder from which export rules
// in:query
// required:false
FolderUID string `json:"folderUid"`
// Name of group of rules to export. Must be specified only together with folder UID
// in:query
// required: false
GroupName string `json:"group"`
}
// swagger:parameters RouteGetAlertRule RoutePutAlertRule RouteDeleteAlertRule RouteGetAlertRuleExport
type AlertRuleUIDReference struct {
// Alert rule UID
+12 -5
View File
@@ -4066,7 +4066,6 @@
"type": "object"
},
"alertGroup": {
"description": "AlertGroup alert group",
"properties": {
"alerts": {
"description": "alerts",
@@ -4195,7 +4194,6 @@
"type": "object"
},
"gettableAlert": {
"description": "GettableAlert gettable alert",
"properties": {
"annotations": {
"$ref": "#/definitions/labelSet"
@@ -4251,14 +4249,12 @@
"type": "object"
},
"gettableAlerts": {
"description": "GettableAlerts gettable alerts",
"items": {
"$ref": "#/definitions/gettableAlert"
},
"type": "array"
},
"gettableSilence": {
"description": "GettableSilence gettable silence",
"properties": {
"comment": {
"description": "comment",
@@ -4307,7 +4303,6 @@
"type": "object"
},
"gettableSilences": {
"description": "GettableSilences gettable silences",
"items": {
"$ref": "#/definitions/gettableSilence"
},
@@ -6469,6 +6464,18 @@
"in": "query",
"name": "format",
"type": "string"
},
{
"description": "UID of folder from which export rules",
"in": "query",
"name": "folderUid",
"type": "string"
},
{
"description": "Name of group of rules to export. Must be specified only together with folder UID",
"in": "query",
"name": "group",
"type": "string"
}
],
"responses": {
+12 -5
View File
@@ -1877,6 +1877,18 @@
"description": "Format of the downloaded file, either yaml or json. Accept header can also be used, but the query parameter will take precedence.",
"name": "format",
"in": "query"
},
{
"type": "string",
"description": "UID of folder from which export rules",
"name": "folderUid",
"in": "query"
},
{
"type": "string",
"description": "Name of group of rules to export. Must be specified only together with folder UID",
"name": "group",
"in": "query"
}
],
"responses": {
@@ -6913,7 +6925,6 @@
}
},
"alertGroup": {
"description": "AlertGroup alert group",
"type": "object",
"required": [
"alerts",
@@ -7044,7 +7055,6 @@
}
},
"gettableAlert": {
"description": "GettableAlert gettable alert",
"type": "object",
"required": [
"labels",
@@ -7101,7 +7111,6 @@
"$ref": "#/definitions/gettableAlert"
},
"gettableAlerts": {
"description": "GettableAlerts gettable alerts",
"type": "array",
"items": {
"$ref": "#/definitions/gettableAlert"
@@ -7109,7 +7118,6 @@
"$ref": "#/definitions/gettableAlerts"
},
"gettableSilence": {
"description": "GettableSilence gettable silence",
"type": "object",
"required": [
"comment",
@@ -7159,7 +7167,6 @@
"$ref": "#/definitions/gettableSilence"
},
"gettableSilences": {
"description": "GettableSilences gettable silences",
"type": "array",
"items": {
"$ref": "#/definitions/gettableSilence"