Alerting: New API endpoint GET /api/v1/ngalert (#55134)

* declare new endpoint /api/v1/ngalert
* add authorization for new path
* add request handler for the new path
This commit is contained in:
Yuriy Tseretyan
2022-09-14 14:03:10 -04:00
committed by GitHub
parent ca2139e9ce
commit 8a62020211
9 changed files with 142 additions and 1 deletions
+13
View File
@@ -232,6 +232,19 @@
],
"type": "object"
},
"AlertingStatus": {
"properties": {
"alertmanagersChoice": {
"enum": [
"all",
"internal",
"external"
],
"type": "string"
}
},
"type": "object"
},
"ApiRuleNode": {
"properties": {
"alert": {
@@ -4,6 +4,16 @@ import (
v1 "github.com/prometheus/client_golang/api/prometheus/v1"
)
// swagger:route GET /api/v1/ngalert configuration RouteGetStatus
//
// Get the status of the alerting engine
//
// Produces:
// - application/json
//
// Responses:
// 200: AlertingStatus
// swagger:route GET /api/v1/ngalert/alertmanagers configuration RouteGetAlertmanagers
//
// Get the discovered and dropped Alertmanagers of the user's organization based on the specified configuration.
@@ -81,3 +91,8 @@ type GettableAlertmanagers struct {
Status string `json:"status"`
Data v1.AlertManagersResult `json:"data"`
}
// swagger:model
type AlertingStatus struct {
AlertmanagersChoice AlertmanagersChoice `json:"alertmanagersChoice"`
}
@@ -232,6 +232,19 @@
],
"type": "object"
},
"AlertingStatus": {
"properties": {
"alertmanagersChoice": {
"enum": [
"all",
"internal",
"external"
],
"type": "string"
}
},
"type": "object"
},
"ApiRuleNode": {
"properties": {
"alert": {
@@ -5558,6 +5571,26 @@
]
}
},
"/api/v1/ngalert": {
"get": {
"description": "Get the status of the alerting engine",
"operationId": "RouteGetStatus",
"produces": [
"application/json"
],
"responses": {
"200": {
"description": "AlertingStatus",
"schema": {
"$ref": "#/definitions/AlertingStatus"
}
}
},
"tags": [
"configuration"
]
}
},
"/api/v1/provisioning/alert-rules": {
"post": {
"consumes": [
@@ -1757,6 +1757,26 @@
}
}
},
"/api/v1/ngalert": {
"get": {
"description": "Get the status of the alerting engine",
"produces": [
"application/json"
],
"tags": [
"configuration"
],
"operationId": "RouteGetStatus",
"responses": {
"200": {
"description": "AlertingStatus",
"schema": {
"$ref": "#/definitions/AlertingStatus"
}
}
}
}
},
"/api/v1/provisioning/alert-rules": {
"post": {
"consumes": [
@@ -2733,6 +2753,19 @@
}
}
},
"AlertingStatus": {
"type": "object",
"properties": {
"alertmanagersChoice": {
"type": "string",
"enum": [
"all",
"internal",
"external"
]
}
}
},
"ApiRuleNode": {
"type": "object",
"properties": {