Alerting: Split grafana and lotex routes (#44742)

* split Lotex and Grafana routes
* update template to use authorize function for every route
This commit is contained in:
Yuriy Tseretyan
2022-02-04 12:42:04 -05:00
committed by GitHub
parent 126ed461b1
commit ddfe2dce74
21 changed files with 2257 additions and 214 deletions
+773 -45
View File
@@ -17,6 +17,454 @@
},
"basePath": "/api/v1",
"paths": {
"/api/alertmanager/grafana/api/v2/alerts": {
"get": {
"description": "get alertmanager alerts",
"tags": [
"alertmanager"
],
"operationId": "RouteGetGrafanaAMAlerts",
"parameters": [
{
"type": "boolean",
"default": true,
"x-go-name": "Active",
"description": "Show active alerts",
"name": "active",
"in": "query"
},
{
"type": "boolean",
"default": true,
"x-go-name": "Silenced",
"description": "Show silenced alerts",
"name": "silenced",
"in": "query"
},
{
"type": "boolean",
"default": true,
"x-go-name": "Inhibited",
"description": "Show inhibited alerts",
"name": "inhibited",
"in": "query"
},
{
"type": "array",
"items": {
"type": "string"
},
"x-go-name": "Matchers",
"description": "A list of matchers to filter alerts by",
"name": "filter",
"in": "query"
},
{
"type": "string",
"x-go-name": "Receivers",
"description": "A regex matching receivers to filter alerts by",
"name": "receiver",
"in": "query"
}
],
"responses": {
"200": {
"description": "gettableAlerts",
"schema": {
"$ref": "#/definitions/gettableAlerts"
}
},
"400": {
"description": "ValidationError",
"schema": {
"$ref": "#/definitions/ValidationError"
}
}
}
},
"post": {
"description": "create alertmanager alerts",
"tags": [
"alertmanager"
],
"operationId": "RoutePostGrafanaAMAlerts",
"parameters": [
{
"name": "PostableAlerts",
"in": "body",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/postableAlert"
}
}
}
],
"responses": {
"200": {
"description": "Ack",
"schema": {
"$ref": "#/definitions/Ack"
}
},
"400": {
"description": "ValidationError",
"schema": {
"$ref": "#/definitions/ValidationError"
}
}
}
}
},
"/api/alertmanager/grafana/api/v2/alerts/groups": {
"get": {
"description": "get alertmanager alerts",
"tags": [
"alertmanager"
],
"operationId": "RouteGetGrafanaAMAlertGroups",
"parameters": [
{
"type": "boolean",
"default": true,
"x-go-name": "Active",
"description": "Show active alerts",
"name": "active",
"in": "query"
},
{
"type": "boolean",
"default": true,
"x-go-name": "Silenced",
"description": "Show silenced alerts",
"name": "silenced",
"in": "query"
},
{
"type": "boolean",
"default": true,
"x-go-name": "Inhibited",
"description": "Show inhibited alerts",
"name": "inhibited",
"in": "query"
},
{
"type": "array",
"items": {
"type": "string"
},
"x-go-name": "Matchers",
"description": "A list of matchers to filter alerts by",
"name": "filter",
"in": "query"
},
{
"type": "string",
"x-go-name": "Receivers",
"description": "A regex matching receivers to filter alerts by",
"name": "receiver",
"in": "query"
}
],
"responses": {
"200": {
"description": "alertGroups",
"schema": {
"$ref": "#/definitions/alertGroups"
}
},
"400": {
"description": "ValidationError",
"schema": {
"$ref": "#/definitions/ValidationError"
}
}
}
}
},
"/api/alertmanager/grafana/api/v2/silence/{SilenceId}": {
"get": {
"description": "get silence",
"tags": [
"alertmanager"
],
"operationId": "RouteGetGrafanaSilence",
"parameters": [
{
"type": "string",
"name": "SilenceId",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "gettableSilence",
"schema": {
"$ref": "#/definitions/gettableSilence"
}
},
"400": {
"description": "ValidationError",
"schema": {
"$ref": "#/definitions/ValidationError"
}
}
}
},
"delete": {
"description": "delete silence",
"tags": [
"alertmanager"
],
"operationId": "RouteDeleteGrafanaSilence",
"parameters": [
{
"type": "string",
"name": "SilenceId",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "Ack",
"schema": {
"$ref": "#/definitions/Ack"
}
},
"400": {
"description": "ValidationError",
"schema": {
"$ref": "#/definitions/ValidationError"
}
}
}
}
},
"/api/alertmanager/grafana/api/v2/silences": {
"get": {
"description": "get silences",
"tags": [
"alertmanager"
],
"operationId": "RouteGetGrafanaSilences",
"parameters": [
{
"type": "array",
"items": {
"type": "string"
},
"x-go-name": "Filter",
"name": "filter",
"in": "query"
}
],
"responses": {
"200": {
"description": "gettableSilences",
"schema": {
"$ref": "#/definitions/gettableSilences"
}
},
"400": {
"description": "ValidationError",
"schema": {
"$ref": "#/definitions/ValidationError"
}
}
}
},
"post": {
"description": "create silence",
"tags": [
"alertmanager"
],
"operationId": "RouteCreateGrafanaSilence",
"parameters": [
{
"name": "Silence",
"in": "body",
"schema": {
"$ref": "#/definitions/postableSilence"
}
}
],
"responses": {
"201": {
"description": "gettableSilence",
"schema": {
"$ref": "#/definitions/gettableSilence"
}
},
"400": {
"description": "ValidationError",
"schema": {
"$ref": "#/definitions/ValidationError"
}
}
}
}
},
"/api/alertmanager/grafana/api/v2/status": {
"get": {
"description": "get alertmanager status and configuration",
"tags": [
"alertmanager"
],
"operationId": "RouteGetGrafanaAMStatus",
"responses": {
"200": {
"description": "GettableStatus",
"schema": {
"$ref": "#/definitions/GettableStatus"
}
},
"400": {
"description": "ValidationError",
"schema": {
"$ref": "#/definitions/ValidationError"
}
}
}
}
},
"/api/alertmanager/grafana/config/api/v1/alerts": {
"get": {
"description": "gets an Alerting config",
"tags": [
"alertmanager"
],
"operationId": "RouteGetGrafanaAlertingConfig",
"responses": {
"200": {
"description": "GettableUserConfig",
"schema": {
"$ref": "#/definitions/GettableUserConfig"
}
},
"400": {
"description": "ValidationError",
"schema": {
"$ref": "#/definitions/ValidationError"
}
}
}
},
"post": {
"description": "sets an Alerting config",
"tags": [
"alertmanager"
],
"operationId": "RoutePostGrafanaAlertingConfig",
"parameters": [
{
"name": "Body",
"in": "body",
"schema": {
"$ref": "#/definitions/PostableUserConfig"
}
}
],
"responses": {
"201": {
"description": "Ack",
"schema": {
"$ref": "#/definitions/Ack"
}
},
"400": {
"description": "ValidationError",
"schema": {
"$ref": "#/definitions/ValidationError"
}
}
}
},
"delete": {
"description": "deletes the Alerting config for a tenant",
"tags": [
"alertmanager"
],
"operationId": "RouteDeleteGrafanaAlertingConfig",
"responses": {
"200": {
"description": "Ack",
"schema": {
"$ref": "#/definitions/Ack"
}
},
"400": {
"description": "ValidationError",
"schema": {
"$ref": "#/definitions/ValidationError"
}
}
}
}
},
"/api/alertmanager/grafana/config/api/v1/receivers/test": {
"post": {
"tags": [
"alertmanager"
],
"summary": "Test Grafana managed receivers without saving them.",
"operationId": "RoutePostTestGrafanaReceivers",
"parameters": [
{
"name": "Body",
"in": "body",
"schema": {
"$ref": "#/definitions/TestReceiversConfigBodyParams"
}
}
],
"responses": {
"200": {
"description": "Ack",
"schema": {
"$ref": "#/definitions/Ack"
}
},
"207": {
"description": "MultiStatus",
"schema": {
"$ref": "#/definitions/MultiStatus"
}
},
"400": {
"description": "ValidationError",
"schema": {
"$ref": "#/definitions/ValidationError"
}
},
"403": {
"description": "PermissionDenied",
"schema": {
"$ref": "#/definitions/PermissionDenied"
}
},
"404": {
"description": "AlertManagerNotFound",
"schema": {
"$ref": "#/definitions/AlertManagerNotFound"
}
},
"408": {
"description": "Failure",
"schema": {
"$ref": "#/definitions/Failure"
}
},
"409": {
"description": "AlertManagerNotReady",
"schema": {
"$ref": "#/definitions/AlertManagerNotReady"
}
}
}
}
},
"/api/alertmanager/{Recipient}/api/v2/alerts": {
"get": {
"description": "get alertmanager alerts",
@@ -67,8 +515,9 @@
"in": "query"
},
{
"type": "string",
"description": "Recipient should be \"grafana\" for requests to be handled by grafana\nand the numeric datasource id for requests to be forwarded to a datasource",
"type": "integer",
"format": "int64",
"description": "Recipient should be the numeric datasource id",
"name": "Recipient",
"in": "path",
"required": true
@@ -107,8 +556,9 @@
}
},
{
"type": "string",
"description": "Recipient should be \"grafana\" for requests to be handled by grafana\nand the numeric datasource id for requests to be forwarded to a datasource",
"type": "integer",
"format": "int64",
"description": "Recipient should be the numeric datasource id",
"name": "Recipient",
"in": "path",
"required": true
@@ -180,8 +630,9 @@
"in": "query"
},
{
"type": "string",
"description": "Recipient should be \"grafana\" for requests to be handled by grafana\nand the numeric datasource id for requests to be forwarded to a datasource",
"type": "integer",
"format": "int64",
"description": "Recipient should be the numeric datasource id",
"name": "Recipient",
"in": "path",
"required": true
@@ -218,8 +669,9 @@
"required": true
},
{
"type": "string",
"description": "Recipient should be \"grafana\" for requests to be handled by grafana\nand the numeric datasource id for requests to be forwarded to a datasource",
"type": "integer",
"format": "int64",
"description": "Recipient should be the numeric datasource id",
"name": "Recipient",
"in": "path",
"required": true
@@ -254,8 +706,9 @@
"required": true
},
{
"type": "string",
"description": "Recipient should be \"grafana\" for requests to be handled by grafana\nand the numeric datasource id for requests to be forwarded to a datasource",
"type": "integer",
"format": "int64",
"description": "Recipient should be the numeric datasource id",
"name": "Recipient",
"in": "path",
"required": true
@@ -295,8 +748,9 @@
"in": "query"
},
{
"type": "string",
"description": "Recipient should be \"grafana\" for requests to be handled by grafana\nand the numeric datasource id for requests to be forwarded to a datasource",
"type": "integer",
"format": "int64",
"description": "Recipient should be the numeric datasource id",
"name": "Recipient",
"in": "path",
"required": true
@@ -332,8 +786,9 @@
}
},
{
"type": "string",
"description": "Recipient should be \"grafana\" for requests to be handled by grafana\nand the numeric datasource id for requests to be forwarded to a datasource",
"type": "integer",
"format": "int64",
"description": "Recipient should be the numeric datasource id",
"name": "Recipient",
"in": "path",
"required": true
@@ -364,8 +819,9 @@
"operationId": "RouteGetAMStatus",
"parameters": [
{
"type": "string",
"description": "Recipient should be \"grafana\" for requests to be handled by grafana\nand the numeric datasource id for requests to be forwarded to a datasource",
"type": "integer",
"format": "int64",
"description": "Recipient should be the numeric datasource id",
"name": "Recipient",
"in": "path",
"required": true
@@ -396,8 +852,9 @@
"operationId": "RouteGetAlertingConfig",
"parameters": [
{
"type": "string",
"description": "Recipient should be \"grafana\" for requests to be handled by grafana\nand the numeric datasource id for requests to be forwarded to a datasource",
"type": "integer",
"format": "int64",
"description": "Recipient should be the numeric datasource id",
"name": "Recipient",
"in": "path",
"required": true
@@ -433,8 +890,9 @@
}
},
{
"type": "string",
"description": "Recipient should be \"grafana\" for requests to be handled by grafana\nand the numeric datasource id for requests to be forwarded to a datasource",
"type": "integer",
"format": "int64",
"description": "Recipient should be the numeric datasource id",
"name": "Recipient",
"in": "path",
"required": true
@@ -463,8 +921,9 @@
"operationId": "RouteDeleteAlertingConfig",
"parameters": [
{
"type": "string",
"description": "Recipient should be \"grafana\" for requests to be handled by grafana\nand the numeric datasource id for requests to be forwarded to a datasource",
"type": "integer",
"format": "int64",
"description": "Recipient should be the numeric datasource id",
"name": "Recipient",
"in": "path",
"required": true
@@ -502,8 +961,9 @@
}
},
{
"type": "string",
"description": "Recipient should be \"grafana\" for requests to be handled by grafana\nand the numeric datasource id for requests to be forwarded to a datasource",
"type": "integer",
"format": "int64",
"description": "Recipient should be the numeric datasource id",
"name": "Recipient",
"in": "path",
"required": true
@@ -555,6 +1015,53 @@
}
}
},
"/api/prometheus/grafana/api/v1/alerts": {
"get": {
"description": "gets the current alerts",
"tags": [
"prometheus"
],
"operationId": "RouteGetGrafanaAlertStatuses",
"responses": {
"200": {
"description": "AlertResponse",
"schema": {
"$ref": "#/definitions/AlertResponse"
}
}
}
}
},
"/api/prometheus/grafana/api/v1/rules": {
"get": {
"description": "gets the evaluation statuses of all rules",
"tags": [
"prometheus"
],
"operationId": "RouteGetGrafanaRuleStatuses",
"parameters": [
{
"type": "string",
"name": "DashboardUID",
"in": "query"
},
{
"type": "integer",
"format": "int64",
"name": "PanelID",
"in": "query"
}
],
"responses": {
"200": {
"description": "RuleResponse",
"schema": {
"$ref": "#/definitions/RuleResponse"
}
}
}
}
},
"/api/prometheus/{Recipient}/api/v1/alerts": {
"get": {
"description": "gets the current alerts",
@@ -564,8 +1071,9 @@
"operationId": "RouteGetAlertStatuses",
"parameters": [
{
"type": "string",
"description": "Recipient should be \"grafana\" for requests to be handled by grafana\nand the numeric datasource id for requests to be forwarded to a datasource",
"type": "integer",
"format": "int64",
"description": "Recipient should be the numeric datasource id",
"name": "Recipient",
"in": "path",
"required": true
@@ -601,8 +1109,9 @@
"in": "query"
},
{
"type": "string",
"description": "Recipient should be \"grafana\" for requests to be handled by grafana\nand the numeric datasource id for requests to be forwarded to a datasource",
"type": "integer",
"format": "int64",
"description": "Recipient should be the numeric datasource id",
"name": "Recipient",
"in": "path",
"required": true
@@ -618,6 +1127,187 @@
}
}
},
"/api/ruler/grafana/api/v1/rules": {
"get": {
"description": "List rule groups",
"produces": [
"application/json"
],
"tags": [
"ruler"
],
"operationId": "RouteGetGrafanaRulesConfig",
"parameters": [
{
"type": "string",
"name": "DashboardUID",
"in": "query"
},
{
"type": "integer",
"format": "int64",
"name": "PanelID",
"in": "query"
}
],
"responses": {
"202": {
"description": "NamespaceConfigResponse",
"schema": {
"$ref": "#/definitions/NamespaceConfigResponse"
}
}
}
}
},
"/api/ruler/grafana/api/v1/rules/{Namespace}": {
"get": {
"description": "Get rule groups by namespace",
"produces": [
"application/json"
],
"tags": [
"ruler"
],
"operationId": "RouteGetNamespaceGrafanaRulesConfig",
"parameters": [
{
"type": "string",
"name": "Namespace",
"in": "path",
"required": true
}
],
"responses": {
"202": {
"description": "NamespaceConfigResponse",
"schema": {
"$ref": "#/definitions/NamespaceConfigResponse"
}
}
}
},
"post": {
"description": "Creates or updates a rule group",
"consumes": [
"application/json",
"application/yaml"
],
"tags": [
"ruler"
],
"operationId": "RoutePostNameGrafanaRulesConfig",
"parameters": [
{
"type": "string",
"name": "Namespace",
"in": "path",
"required": true
},
{
"name": "Body",
"in": "body",
"schema": {
"$ref": "#/definitions/PostableRuleGroupConfig"
}
}
],
"responses": {
"202": {
"description": "Ack",
"schema": {
"$ref": "#/definitions/Ack"
}
}
}
},
"delete": {
"description": "Delete namespace",
"tags": [
"ruler"
],
"operationId": "RouteDeleteNamespaceGrafanaRulesConfig",
"parameters": [
{
"type": "string",
"name": "Namespace",
"in": "path",
"required": true
}
],
"responses": {
"202": {
"description": "Ack",
"schema": {
"$ref": "#/definitions/Ack"
}
}
}
}
},
"/api/ruler/grafana/api/v1/rules/{Namespace}/{Groupname}": {
"get": {
"description": "Get rule group",
"produces": [
"application/json"
],
"tags": [
"ruler"
],
"operationId": "RouteGetGrafanaRuleGroupConfig",
"parameters": [
{
"type": "string",
"name": "Namespace",
"in": "path",
"required": true
},
{
"type": "string",
"name": "Groupname",
"in": "path",
"required": true
}
],
"responses": {
"202": {
"description": "RuleGroupConfigResponse",
"schema": {
"$ref": "#/definitions/RuleGroupConfigResponse"
}
}
}
},
"delete": {
"description": "Delete rule group",
"tags": [
"ruler"
],
"operationId": "RouteDeleteGrafanaRuleGroupConfig",
"parameters": [
{
"type": "string",
"name": "Namespace",
"in": "path",
"required": true
},
{
"type": "string",
"name": "Groupname",
"in": "path",
"required": true
}
],
"responses": {
"202": {
"description": "Ack",
"schema": {
"$ref": "#/definitions/Ack"
}
}
}
}
},
"/api/ruler/{Recipient}/api/v1/rules": {
"get": {
"description": "List rule groups",
@@ -630,8 +1320,9 @@
"operationId": "RouteGetRulesConfig",
"parameters": [
{
"type": "string",
"description": "Recipient should be \"grafana\" for requests to be handled by grafana\nand the numeric datasource id for requests to be forwarded to a datasource",
"type": "integer",
"format": "int64",
"description": "Recipient should be the numeric datasource id",
"name": "Recipient",
"in": "path",
"required": true
@@ -670,8 +1361,9 @@
"operationId": "RouteGetNamespaceRulesConfig",
"parameters": [
{
"type": "string",
"description": "Recipient should be \"grafana\" for requests to be handled by grafana\nand the numeric datasource id for requests to be forwarded to a datasource",
"type": "integer",
"format": "int64",
"description": "Recipient should be the numeric datasource id",
"name": "Recipient",
"in": "path",
"required": true
@@ -704,8 +1396,9 @@
"operationId": "RoutePostNameRulesConfig",
"parameters": [
{
"type": "string",
"description": "Recipient should be \"grafana\" for requests to be handled by grafana\nand the numeric datasource id for requests to be forwarded to a datasource",
"type": "integer",
"format": "int64",
"description": "Recipient should be the numeric datasource id",
"name": "Recipient",
"in": "path",
"required": true
@@ -741,8 +1434,9 @@
"operationId": "RouteDeleteNamespaceRulesConfig",
"parameters": [
{
"type": "string",
"description": "Recipient should be \"grafana\" for requests to be handled by grafana\nand the numeric datasource id for requests to be forwarded to a datasource",
"type": "integer",
"format": "int64",
"description": "Recipient should be the numeric datasource id",
"name": "Recipient",
"in": "path",
"required": true
@@ -776,8 +1470,9 @@
"operationId": "RouteGetRulegGroupConfig",
"parameters": [
{
"type": "string",
"description": "Recipient should be \"grafana\" for requests to be handled by grafana\nand the numeric datasource id for requests to be forwarded to a datasource",
"type": "integer",
"format": "int64",
"description": "Recipient should be the numeric datasource id",
"name": "Recipient",
"in": "path",
"required": true
@@ -812,8 +1507,9 @@
"operationId": "RouteDeleteRuleGroupConfig",
"parameters": [
{
"type": "string",
"description": "Recipient should be \"grafana\" for requests to be handled by grafana\nand the numeric datasource id for requests to be forwarded to a datasource",
"type": "integer",
"format": "int64",
"description": "Recipient should be the numeric datasource id",
"name": "Recipient",
"in": "path",
"required": true
@@ -982,9 +1678,41 @@
}
}
},
"/api/v1/rule/test/grafana": {
"post": {
"description": "Test a rule against Grafana ruler",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"testing"
],
"operationId": "RouteTestRuleGrafanaConfig",
"parameters": [
{
"name": "Body",
"in": "body",
"schema": {
"$ref": "#/definitions/TestRulePayload"
}
}
],
"responses": {
"200": {
"description": "TestRuleResponse",
"schema": {
"$ref": "#/definitions/TestRuleResponse"
}
}
}
}
},
"/api/v1/rule/test/{Recipient}": {
"post": {
"description": "Test rule",
"description": "Test a rule against external data source ruler",
"consumes": [
"application/json"
],
@@ -997,8 +1725,9 @@
"operationId": "RouteTestRuleConfig",
"parameters": [
{
"type": "string",
"description": "Recipient should be \"grafana\" for requests to be handled by grafana\nand the numeric datasource id for requests to be forwarded to a datasource",
"type": "integer",
"format": "int64",
"description": "Recipient should be the numeric datasource id",
"name": "Recipient",
"in": "path",
"required": true
@@ -3957,12 +4686,11 @@
"$ref": "#/definitions/alertGroup"
},
"alertGroups": {
"description": "AlertGroups alert groups",
"type": "array",
"items": {
"$ref": "#/definitions/alertGroup"
},
"x-go-name": "AlertGroups",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models",
"$ref": "#/definitions/alertGroups"
},
"alertStatus": {