Alerting: send alerts to external, internal, or both alertmanagers (#40341)
* (WIP) send alerts to external, internal, or both alertmanagers * Modify admin configuration endpoint, update swagger docs * Integration test for admin config updated * Code review changes * Fix alertmanagers choice not changing bug, add unit test * Add AlertmanagersChoice as enum in swagger, code review changes * Fix API and tests errors * Change enum from int to string, use 'SendAlertsTo' instead of 'AlertmanagerChoice' where necessary * Fix tests to reflect last changes * Keep senders running when alerts are handled just internally * Check if any external AM has been discovered before sending alerts, update tests * remove duplicate data from logs * update comment * represent alertmanagers choice as an int instead of a string * default alertmanagers choice to all alertmanagers, test cases * update definitions and generate spec
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package definitions
|
||||
|
||||
import v1 "github.com/prometheus/client_golang/api/prometheus/v1"
|
||||
import (
|
||||
v1 "github.com/prometheus/client_golang/api/prometheus/v1"
|
||||
)
|
||||
|
||||
// swagger:route GET /api/v1/ngalert/alertmanagers configuration RouteGetAlertmanagers
|
||||
//
|
||||
@@ -26,7 +28,7 @@ import v1 "github.com/prometheus/client_golang/api/prometheus/v1"
|
||||
|
||||
// swagger:route POST /api/v1/ngalert/admin_config configuration RoutePostNGalertConfig
|
||||
//
|
||||
// Creates or updates the NGalert configuration of the user's organization.
|
||||
// Creates or updates the NGalert configuration of the user's organization. If no value is sent for alertmanagersChoice, it defaults to "all".
|
||||
//
|
||||
// Consumes:
|
||||
// - application/json
|
||||
@@ -52,14 +54,25 @@ type NGalertConfig struct {
|
||||
Body PostableNGalertConfig
|
||||
}
|
||||
|
||||
// swagger:enum AlertmanagersChoice
|
||||
type AlertmanagersChoice string
|
||||
|
||||
const (
|
||||
AllAlertmanagers AlertmanagersChoice = "all"
|
||||
InternalAlertmanager AlertmanagersChoice = "internal"
|
||||
ExternalAlertmanagers AlertmanagersChoice = "external"
|
||||
)
|
||||
|
||||
// swagger:model
|
||||
type PostableNGalertConfig struct {
|
||||
Alertmanagers []string `json:"alertmanagers"`
|
||||
Alertmanagers []string `json:"alertmanagers"`
|
||||
AlertmanagersChoice AlertmanagersChoice `json:"alertmanagersChoice"`
|
||||
}
|
||||
|
||||
// swagger:model
|
||||
type GettableNGalertConfig struct {
|
||||
Alertmanagers []string `json:"alertmanagers"`
|
||||
Alertmanagers []string `json:"alertmanagers"`
|
||||
AlertmanagersChoice AlertmanagersChoice `json:"alertmanagersChoice"`
|
||||
}
|
||||
|
||||
// swagger:model
|
||||
|
||||
Reference in New Issue
Block a user