Alerting: Create endpoints for exporting in provisioning file format (#58623)
This adds provisioning endpoints for downloading alert rules and alert rule groups in a format that is compatible with file provisioning. Each endpoint supports both json and yaml response types via Accept header as well as a query parameter download=true/false that will set Content-Disposition to recommend initiating a download or inline display. This also makes some package changes to keep structs with potential to drift closer together. Eventually, other alerting file structs should also move into this new file package, but the rest require some refactoring that is out of scope for this PR.
This commit is contained in:
@@ -1746,6 +1746,36 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/provisioning/alert-rules/export": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"provisioning",
|
||||
"stable"
|
||||
],
|
||||
"summary": "Export all alert rules in provisioning file format.",
|
||||
"operationId": "RouteGetAlertRulesExport",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "Whether to initiate a download of the file or not.",
|
||||
"name": "download",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "AlertingFileExport",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/AlertingFileExport"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": " Not found."
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/provisioning/alert-rules/{UID}": {
|
||||
"get": {
|
||||
"tags": [
|
||||
@@ -1844,6 +1874,48 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/provisioning/alert-rules/{UID}/export": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json",
|
||||
"application/yaml",
|
||||
"text/yaml"
|
||||
],
|
||||
"tags": [
|
||||
"provisioning",
|
||||
"stable"
|
||||
],
|
||||
"summary": "Export an alert rule in provisioning file format.",
|
||||
"operationId": "RouteGetAlertRuleExport",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Alert rule UID",
|
||||
"name": "UID",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "Whether to initiate a download of the file or not.",
|
||||
"name": "download",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "AlertingFileExport",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/AlertingFileExport"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": " Not found."
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/provisioning/contact-points": {
|
||||
"get": {
|
||||
"tags": [
|
||||
@@ -2053,6 +2125,53 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/provisioning/folder/{FolderUID}/rule-groups/{Group}/export": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json",
|
||||
"application/yaml",
|
||||
"text/yaml"
|
||||
],
|
||||
"tags": [
|
||||
"provisioning",
|
||||
"stable"
|
||||
],
|
||||
"summary": "Export an alert rule group in provisioning file format.",
|
||||
"operationId": "RouteGetAlertRuleGroupExport",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"name": "FolderUID",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "Group",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "Whether to initiate a download of the file or not.",
|
||||
"name": "download",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "AlertingFileExport",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/AlertingFileExport"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": " Not found."
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/provisioning/mute-timings": {
|
||||
"get": {
|
||||
"tags": [
|
||||
@@ -2612,6 +2731,28 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"AlertQueryExport": {
|
||||
"type": "object",
|
||||
"title": "AlertQueryExport is the provisioned export of models.AlertQuery.",
|
||||
"properties": {
|
||||
"datasourceUid": {
|
||||
"type": "string"
|
||||
},
|
||||
"model": {
|
||||
"type": "object",
|
||||
"additionalProperties": {}
|
||||
},
|
||||
"queryType": {
|
||||
"type": "string"
|
||||
},
|
||||
"refId": {
|
||||
"type": "string"
|
||||
},
|
||||
"relativeTimeRange": {
|
||||
"$ref": "#/definitions/RelativeTimeRange"
|
||||
}
|
||||
}
|
||||
},
|
||||
"AlertResponse": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
@@ -2632,6 +2773,65 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"AlertRuleExport": {
|
||||
"type": "object",
|
||||
"title": "AlertRuleExport is the provisioned file export of models.AlertRule.",
|
||||
"properties": {
|
||||
"annotations": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"condition": {
|
||||
"type": "string"
|
||||
},
|
||||
"dasboardUid": {
|
||||
"type": "string"
|
||||
},
|
||||
"data": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/AlertQueryExport"
|
||||
}
|
||||
},
|
||||
"execErrState": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Alerting",
|
||||
"Error",
|
||||
"OK"
|
||||
]
|
||||
},
|
||||
"for": {
|
||||
"$ref": "#/definitions/Duration"
|
||||
},
|
||||
"labels": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"noDataState": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Alerting",
|
||||
"NoData",
|
||||
"OK"
|
||||
]
|
||||
},
|
||||
"panelId": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"title": {
|
||||
"type": "string"
|
||||
},
|
||||
"uid": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"AlertRuleGroup": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -2653,6 +2853,31 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"AlertRuleGroupExport": {
|
||||
"type": "object",
|
||||
"title": "AlertRuleGroupExport is the provisioned file export of AlertRuleGroupV1.",
|
||||
"properties": {
|
||||
"folder": {
|
||||
"type": "string"
|
||||
},
|
||||
"interval": {
|
||||
"$ref": "#/definitions/Duration"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"orgId": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"rules": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/AlertRuleExport"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"AlertRuleGroupMetadata": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -2662,6 +2887,23 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"AlertingFileExport": {
|
||||
"type": "object",
|
||||
"title": "AlertingFileExport is the full provisioned file export.",
|
||||
"properties": {
|
||||
"apiVersion": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"groups": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/AlertRuleGroupExport"
|
||||
}
|
||||
}
|
||||
},
|
||||
"$ref": "#/definitions/AlertingFileExport"
|
||||
},
|
||||
"AlertingRule": {
|
||||
"description": "adapted from cortex",
|
||||
"type": "object",
|
||||
@@ -5887,7 +6129,6 @@
|
||||
"$ref": "#/definitions/alertGroup"
|
||||
},
|
||||
"alertGroups": {
|
||||
"description": "AlertGroups alert groups",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/alertGroup"
|
||||
@@ -5993,7 +6234,6 @@
|
||||
}
|
||||
},
|
||||
"gettableAlert": {
|
||||
"description": "GettableAlert gettable alert",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"labels",
|
||||
@@ -6057,6 +6297,7 @@
|
||||
"$ref": "#/definitions/gettableAlerts"
|
||||
},
|
||||
"gettableSilence": {
|
||||
"description": "GettableSilence gettable silence",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"comment",
|
||||
@@ -6113,7 +6354,6 @@
|
||||
"$ref": "#/definitions/gettableSilences"
|
||||
},
|
||||
"integration": {
|
||||
"description": "Integration integration",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name",
|
||||
@@ -6296,7 +6536,6 @@
|
||||
"$ref": "#/definitions/postableSilence"
|
||||
},
|
||||
"receiver": {
|
||||
"description": "Receiver receiver",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"active",
|
||||
|
||||
Reference in New Issue
Block a user