Alerting: API paths for cortextool to import Loki rules (#101409)

Alerting: Legacy rules paths for cortextool
This commit is contained in:
Alexander Akhmetov
2025-02-27 17:20:49 +01:00
committed by GitHub
parent 843d876f16
commit ef86582dfc
12 changed files with 1049 additions and 255 deletions
+251 -1
View File
@@ -4493,6 +4493,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\nThe Host field contains the host and port subcomponents of the URL.\nWhen the port is present, it is separated from the host with a colon.\nWhen the host is an IPv6 address, it must be enclosed in square brackets:\n\"[fe80::1]:80\". The [net.JoinHostPort] function combines a host and port\ninto a string suitable for the Host field, adding square brackets to\nthe host when necessary.\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 [URL.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"
@@ -4528,7 +4529,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"
},
"UpdateRuleGroupResponse": {
@@ -4770,6 +4771,7 @@
"type": "object"
},
"alertGroups": {
"description": "AlertGroups alert groups",
"items": {
"$ref": "#/definitions/alertGroup",
"type": "object"
@@ -5056,6 +5058,7 @@
"type": "object"
},
"gettableSilences": {
"description": "GettableSilences gettable silences",
"items": {
"$ref": "#/definitions/gettableSilence",
"type": "object"
@@ -6398,6 +6401,253 @@
]
}
},
"/convert/api/prom/rules": {
"get": {
"operationId": "RouteConvertPrometheusCortexGetRules",
"produces": [
"application/yaml"
],
"responses": {
"200": {
"description": "PrometheusNamespace",
"schema": {
"$ref": "#/definitions/PrometheusNamespace"
}
},
"403": {
"description": "ForbiddenError",
"schema": {
"$ref": "#/definitions/ForbiddenError"
}
},
"404": {
"description": "NotFound",
"schema": {
"$ref": "#/definitions/NotFound"
}
}
},
"summary": "Gets all Grafana-managed alert rules that were imported from Prometheus-compatible sources, grouped by namespace.",
"tags": [
"convert_prometheus"
]
}
},
"/convert/api/prom/rules/{NamespaceTitle}": {
"delete": {
"operationId": "RouteConvertPrometheusCortexDeleteNamespace",
"parameters": [
{
"in": "path",
"name": "NamespaceTitle",
"required": true,
"type": "string"
}
],
"produces": [
"application/json"
],
"responses": {
"202": {
"description": "ConvertPrometheusResponse",
"schema": {
"$ref": "#/definitions/ConvertPrometheusResponse"
}
},
"403": {
"description": "ForbiddenError",
"schema": {
"$ref": "#/definitions/ForbiddenError"
}
}
},
"summary": "Deletes all rule groups that were imported from Prometheus-compatible sources within the specified namespace.",
"tags": [
"convert_prometheus"
]
},
"get": {
"operationId": "RouteConvertPrometheusCortexGetNamespace",
"parameters": [
{
"in": "path",
"name": "NamespaceTitle",
"required": true,
"type": "string"
}
],
"produces": [
"application/yaml"
],
"responses": {
"200": {
"description": "PrometheusNamespace",
"schema": {
"$ref": "#/definitions/PrometheusNamespace"
}
},
"403": {
"description": "ForbiddenError",
"schema": {
"$ref": "#/definitions/ForbiddenError"
}
},
"404": {
"description": "NotFound",
"schema": {
"$ref": "#/definitions/NotFound"
}
}
},
"summary": "Gets Grafana-managed alert rules that were imported from Prometheus-compatible sources for a specified namespace (folder).",
"tags": [
"convert_prometheus"
]
},
"post": {
"consumes": [
"application/yaml"
],
"description": "If the group already exists and was not imported from a Prometheus-compatible source initially,\nit will not be replaced and an error will be returned.",
"operationId": "RouteConvertPrometheusCortexPostRuleGroup",
"parameters": [
{
"in": "path",
"name": "NamespaceTitle",
"required": true,
"type": "string"
},
{
"in": "header",
"name": "x-grafana-alerting-datasource-uid",
"type": "string"
},
{
"in": "header",
"name": "x-grafana-alerting-recording-rules-paused",
"type": "boolean"
},
{
"in": "header",
"name": "x-grafana-alerting-alert-rules-paused",
"type": "boolean"
},
{
"in": "body",
"name": "Body",
"schema": {
"$ref": "#/definitions/PrometheusRuleGroup"
}
}
],
"produces": [
"application/json"
],
"responses": {
"202": {
"description": "ConvertPrometheusResponse",
"schema": {
"$ref": "#/definitions/ConvertPrometheusResponse"
}
},
"403": {
"description": "ForbiddenError",
"schema": {
"$ref": "#/definitions/ForbiddenError"
}
}
},
"summary": "Converts a Prometheus rule group into a Grafana rule group and creates or updates it within the specified namespace.",
"tags": [
"convert_prometheus"
],
"x-raw-request": "true"
}
},
"/convert/api/prom/rules/{NamespaceTitle}/{Group}": {
"delete": {
"operationId": "RouteConvertPrometheusCortexDeleteRuleGroup",
"parameters": [
{
"in": "path",
"name": "NamespaceTitle",
"required": true,
"type": "string"
},
{
"in": "path",
"name": "Group",
"required": true,
"type": "string"
}
],
"produces": [
"application/json"
],
"responses": {
"202": {
"description": "ConvertPrometheusResponse",
"schema": {
"$ref": "#/definitions/ConvertPrometheusResponse"
}
},
"403": {
"description": "ForbiddenError",
"schema": {
"$ref": "#/definitions/ForbiddenError"
}
}
},
"summary": "Deletes a specific rule group if it was imported from a Prometheus-compatible source.",
"tags": [
"convert_prometheus"
]
},
"get": {
"operationId": "RouteConvertPrometheusCortexGetRuleGroup",
"parameters": [
{
"in": "path",
"name": "NamespaceTitle",
"required": true,
"type": "string"
},
{
"in": "path",
"name": "Group",
"required": true,
"type": "string"
}
],
"produces": [
"application/yaml"
],
"responses": {
"200": {
"description": "PrometheusRuleGroup",
"schema": {
"$ref": "#/definitions/PrometheusRuleGroup"
}
},
"403": {
"description": "ForbiddenError",
"schema": {
"$ref": "#/definitions/ForbiddenError"
}
},
"404": {
"description": "NotFound",
"schema": {
"$ref": "#/definitions/NotFound"
}
}
},
"summary": "Gets a single rule group in Prometheus-compatible format if it was imported from a Prometheus-compatible source.",
"tags": [
"convert_prometheus"
]
}
},
"/convert/prometheus/config/v1/rules": {
"get": {
"operationId": "RouteConvertPrometheusGetRules",