Alerting: conversion API structure (#100258)

This commit is contained in:
Alexander Akhmetov
2025-02-12 08:13:21 +01:00
committed by GitHub
parent 9b37e9249a
commit 9593e51da7
18 changed files with 1333 additions and 8 deletions
+330 -2
View File
@@ -1102,6 +1102,252 @@
}
}
},
"/convert/prometheus/config/v1/rules": {
"get": {
"produces": [
"application/json"
],
"tags": [
"convert_prometheus"
],
"summary": "Gets all namespaces with their rule groups in Prometheus format.",
"operationId": "RouteConvertPrometheusGetRules",
"responses": {
"200": {
"description": "PrometheusNamespace",
"schema": {
"$ref": "#/definitions/PrometheusNamespace"
}
},
"403": {
"description": "ForbiddenError",
"schema": {
"$ref": "#/definitions/ForbiddenError"
}
},
"404": {
"description": "NotFound",
"schema": {
"$ref": "#/definitions/NotFound"
}
}
}
}
},
"/convert/prometheus/config/v1/rules/{NamespaceTitle}": {
"get": {
"produces": [
"application/json"
],
"tags": [
"convert_prometheus"
],
"summary": "Gets rules in prometheus format for a given namespace.",
"operationId": "RouteConvertPrometheusGetNamespace",
"parameters": [
{
"type": "string",
"name": "NamespaceTitle",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "PrometheusNamespace",
"schema": {
"$ref": "#/definitions/PrometheusNamespace"
}
},
"403": {
"description": "ForbiddenError",
"schema": {
"$ref": "#/definitions/ForbiddenError"
}
},
"404": {
"description": "NotFound",
"schema": {
"$ref": "#/definitions/NotFound"
}
}
}
},
"post": {
"consumes": [
"application/yaml"
],
"produces": [
"application/json"
],
"tags": [
"convert_prometheus"
],
"summary": "Creates or updates a rule group in Prometheus format.",
"operationId": "RouteConvertPrometheusPostRuleGroup",
"parameters": [
{
"type": "string",
"name": "NamespaceTitle",
"in": "path",
"required": true
},
{
"type": "string",
"name": "x-datasource-uid",
"in": "header"
},
{
"type": "boolean",
"name": "x-recording-rules-paused",
"in": "header"
},
{
"type": "boolean",
"name": "x-alert-rules-paused",
"in": "header"
},
{
"name": "Body",
"in": "body",
"schema": {
"$ref": "#/definitions/PrometheusRuleGroup"
}
}
],
"responses": {
"202": {
"description": "ConvertPrometheusResponse",
"schema": {
"$ref": "#/definitions/ConvertPrometheusResponse"
}
},
"403": {
"description": "ForbiddenError",
"schema": {
"$ref": "#/definitions/ForbiddenError"
}
}
},
"x-raw-request": "true"
},
"delete": {
"produces": [
"application/json"
],
"tags": [
"convert_prometheus"
],
"summary": "Deletes all rule groups in the given namespace.",
"operationId": "RouteConvertPrometheusDeleteNamespace",
"parameters": [
{
"type": "string",
"name": "NamespaceTitle",
"in": "path",
"required": true
}
],
"responses": {
"202": {
"description": "ConvertPrometheusResponse",
"schema": {
"$ref": "#/definitions/ConvertPrometheusResponse"
}
},
"403": {
"description": "ForbiddenError",
"schema": {
"$ref": "#/definitions/ForbiddenError"
}
}
}
}
},
"/convert/prometheus/config/v1/rules/{NamespaceTitle}/{Group}": {
"get": {
"produces": [
"application/json"
],
"tags": [
"convert_prometheus"
],
"summary": "Gets a rule group in Prometheus format.",
"operationId": "RouteConvertPrometheusGetRuleGroup",
"parameters": [
{
"type": "string",
"name": "NamespaceTitle",
"in": "path",
"required": true
},
{
"type": "string",
"name": "Group",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "PrometheusRuleGroup",
"schema": {
"$ref": "#/definitions/PrometheusRuleGroup"
}
},
"403": {
"description": "ForbiddenError",
"schema": {
"$ref": "#/definitions/ForbiddenError"
}
},
"404": {
"description": "NotFound",
"schema": {
"$ref": "#/definitions/NotFound"
}
}
}
},
"delete": {
"produces": [
"application/json"
],
"tags": [
"convert_prometheus"
],
"summary": "Deletes a rule group in Prometheus format.",
"operationId": "RouteConvertPrometheusDeleteRuleGroup",
"parameters": [
{
"type": "string",
"name": "NamespaceTitle",
"in": "path",
"required": true
},
{
"type": "string",
"name": "Group",
"in": "path",
"required": true
}
],
"responses": {
"202": {
"description": "ConvertPrometheusResponse",
"schema": {
"$ref": "#/definitions/ConvertPrometheusResponse"
}
},
"403": {
"description": "ForbiddenError",
"schema": {
"$ref": "#/definitions/ForbiddenError"
}
}
}
}
},
"/prometheus/grafana/api/v1/alerts": {
"get": {
"description": "gets the current alerts",
@@ -1633,6 +1879,12 @@
"schema": {
"$ref": "#/definitions/ForbiddenError"
}
},
"404": {
"description": "NotFound",
"schema": {
"$ref": "#/definitions/NotFound"
}
}
}
},
@@ -4420,6 +4672,20 @@
"$ref": "#/definitions/EmbeddedContactPoint"
}
},
"ConvertPrometheusResponse": {
"type": "object",
"properties": {
"error": {
"type": "string"
},
"errorType": {
"type": "string"
},
"status": {
"type": "string"
}
}
},
"CounterResetHint": {
"description": "or alternatively that we are dealing with a gauge histogram, where counter resets do not apply.",
"type": "integer",
@@ -6628,6 +6894,70 @@
}
}
},
"PrometheusNamespace": {
"type": "object",
"properties": {
"Body": {
"description": "in: body",
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"$ref": "#/definitions/PrometheusRuleGroup"
}
}
}
}
},
"PrometheusRule": {
"type": "object",
"properties": {
"Alert": {
"type": "string"
},
"Annotations": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"Expr": {
"type": "string"
},
"For": {
"type": "string"
},
"KeepFiringFor": {
"type": "string"
},
"Labels": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"Record": {
"type": "string"
}
}
},
"PrometheusRuleGroup": {
"type": "object",
"properties": {
"Interval": {
"$ref": "#/definitions/Duration"
},
"Name": {
"type": "string"
},
"Rules": {
"type": "array",
"items": {
"$ref": "#/definitions/PrometheusRule"
}
}
}
},
"Provenance": {
"type": "string"
},
@@ -8542,7 +8872,6 @@
}
},
"gettableAlerts": {
"description": "GettableAlerts gettable alerts",
"type": "array",
"items": {
"type": "object",
@@ -8667,7 +8996,6 @@
}
},
"gettableSilences": {
"description": "GettableSilences gettable silences",
"type": "array",
"items": {
"type": "object",