Alerting: remove feature toggle for provisioning API (#50167)

* Alerting: remove feature toggle for provisioning API

* remove missed code parts

* remove unused import

* remove empty line

* mark routes as stable
pull/50216/head
Jean-Philippe Quéméner 3 years ago committed by GitHub
parent 4cc8c6f745
commit 4b8a4449ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      packages/grafana-data/src/types/featureToggles.gen.ts
  2. 5
      pkg/services/featuremgmt/registry.go
  3. 4
      pkg/services/featuremgmt/toggles_gen.go
  4. 3
      pkg/services/ngalert/api/api.go
  5. 4
      pkg/services/ngalert/api/api_alertmanager_test.go
  6. 10
      pkg/services/ngalert/api/tooling/definitions/provisioning_alert_rules.go
  7. 8
      pkg/services/ngalert/api/tooling/definitions/provisioning_contactpoints.go
  8. 12
      pkg/services/ngalert/api/tooling/definitions/provisioning_mute_timings.go
  9. 4
      pkg/services/ngalert/api/tooling/definitions/provisioning_policies.go
  10. 8
      pkg/services/ngalert/api/tooling/definitions/provisioning_templates.go
  11. 42
      pkg/services/ngalert/api/tooling/post.json
  12. 88
      pkg/services/ngalert/api/tooling/spec.json
  13. 3
      pkg/services/ngalert/notifier/alertmanager_config.go
  14. 5
      pkg/services/ngalert/tests/util.go
  15. 2
      pkg/tests/api/alerting/api_provisioning_test.go

@ -42,7 +42,6 @@ export interface FeatureToggles {
annotationComments?: boolean; annotationComments?: boolean;
migrationLocking?: boolean; migrationLocking?: boolean;
storage?: boolean; storage?: boolean;
alertProvisioning?: boolean;
export?: boolean; export?: boolean;
storageLocalUpload?: boolean; storageLocalUpload?: boolean;
azureMonitorResourcePickerForMetrics?: boolean; azureMonitorResourcePickerForMetrics?: boolean;

@ -147,11 +147,6 @@ var (
Description: "Configurable storage for dashboards, datasources, and resources", Description: "Configurable storage for dashboards, datasources, and resources",
State: FeatureStateAlpha, State: FeatureStateAlpha,
}, },
{
Name: "alertProvisioning",
Description: "Provisioning-friendly routes for alerting",
State: FeatureStateAlpha,
},
{ {
Name: "export", Name: "export",
Description: "Export grafana instance (to git, etc)", Description: "Export grafana instance (to git, etc)",

@ -111,10 +111,6 @@ const (
// Configurable storage for dashboards, datasources, and resources // Configurable storage for dashboards, datasources, and resources
FlagStorage = "storage" FlagStorage = "storage"
// FlagAlertProvisioning
// Provisioning-friendly routes for alerting
FlagAlertProvisioning = "alertProvisioning"
// FlagExport // FlagExport
// Export grafana instance (to git, etc) // Export grafana instance (to git, etc)
FlagExport = "export" FlagExport = "export"

@ -11,7 +11,6 @@ import (
"github.com/grafana/grafana/pkg/services/accesscontrol" "github.com/grafana/grafana/pkg/services/accesscontrol"
"github.com/grafana/grafana/pkg/services/datasourceproxy" "github.com/grafana/grafana/pkg/services/datasourceproxy"
"github.com/grafana/grafana/pkg/services/datasources" "github.com/grafana/grafana/pkg/services/datasources"
"github.com/grafana/grafana/pkg/services/featuremgmt"
apimodels "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions" apimodels "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
"github.com/grafana/grafana/pkg/services/ngalert/eval" "github.com/grafana/grafana/pkg/services/ngalert/eval"
"github.com/grafana/grafana/pkg/services/ngalert/metrics" "github.com/grafana/grafana/pkg/services/ngalert/metrics"
@ -136,7 +135,6 @@ func (api *API) RegisterAPIEndpoints(m *metrics.API) {
}, },
), m) ), m)
if api.Cfg.IsFeatureToggleEnabled(featuremgmt.FlagAlertProvisioning) {
api.RegisterProvisioningApiEndpoints(NewForkedProvisioningApi(&ProvisioningSrv{ api.RegisterProvisioningApiEndpoints(NewForkedProvisioningApi(&ProvisioningSrv{
log: logger, log: logger,
policies: api.Policies, policies: api.Policies,
@ -145,5 +143,4 @@ func (api *API) RegisterAPIEndpoints(m *metrics.API) {
muteTimings: api.MuteTimings, muteTimings: api.MuteTimings,
alertRules: api.AlertRules, alertRules: api.AlertRules,
}), m) }), m)
}
} }

@ -18,7 +18,6 @@ import (
"github.com/grafana/grafana/pkg/models" "github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/accesscontrol" "github.com/grafana/grafana/pkg/services/accesscontrol"
acMock "github.com/grafana/grafana/pkg/services/accesscontrol/mock" acMock "github.com/grafana/grafana/pkg/services/accesscontrol/mock"
"github.com/grafana/grafana/pkg/services/featuremgmt"
apimodels "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions" apimodels "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
"github.com/grafana/grafana/pkg/services/ngalert/metrics" "github.com/grafana/grafana/pkg/services/ngalert/metrics"
ngmodels "github.com/grafana/grafana/pkg/services/ngalert/models" ngmodels "github.com/grafana/grafana/pkg/services/ngalert/models"
@ -531,9 +530,6 @@ func createMultiOrgAlertmanager(t *testing.T) *notifier.MultiOrgAlertmanager {
DefaultConfiguration: setting.GetAlertmanagerDefaultConfiguration(), DefaultConfiguration: setting.GetAlertmanagerDefaultConfiguration(),
DisabledOrgs: map[int64]struct{}{5: {}}, DisabledOrgs: map[int64]struct{}{5: {}},
}, // do not poll in tests. }, // do not poll in tests.
IsFeatureToggleEnabled: func(key string) bool {
return key == featuremgmt.FlagAlertProvisioning
},
} }
mam, err := notifier.NewMultiOrgAlertmanager(cfg, &configStore, &orgStore, kvStore, provStore, decryptFn, m.GetMultiOrgAlertmanagerMetrics(), nil, log.New("testlogger"), secretsService) mam, err := notifier.NewMultiOrgAlertmanager(cfg, &configStore, &orgStore, kvStore, provStore, decryptFn, m.GetMultiOrgAlertmanagerMetrics(), nil, log.New("testlogger"), secretsService)

@ -6,7 +6,7 @@ import (
"github.com/grafana/grafana/pkg/services/ngalert/models" "github.com/grafana/grafana/pkg/services/ngalert/models"
) )
// swagger:route GET /api/v1/provisioning/alert-rules/{UID} provisioning RouteGetAlertRule // swagger:route GET /api/v1/provisioning/alert-rules/{UID} provisioning stable RouteGetAlertRule
// //
// Get a specific alert rule by UID. // Get a specific alert rule by UID.
// //
@ -14,7 +14,7 @@ import (
// 200: AlertRule // 200: AlertRule
// 400: ValidationError // 400: ValidationError
// swagger:route POST /api/v1/provisioning/alert-rules provisioning RoutePostAlertRule // swagger:route POST /api/v1/provisioning/alert-rules provisioning stable RoutePostAlertRule
// //
// Create a new alert rule. // Create a new alert rule.
// //
@ -22,7 +22,7 @@ import (
// 201: AlertRule // 201: AlertRule
// 400: ValidationError // 400: ValidationError
// swagger:route PUT /api/v1/provisioning/alert-rules/{UID} provisioning RoutePutAlertRule // swagger:route PUT /api/v1/provisioning/alert-rules/{UID} provisioning stable RoutePutAlertRule
// //
// Update an existing alert rule. // Update an existing alert rule.
// //
@ -33,7 +33,7 @@ import (
// 200: AlertRule // 200: AlertRule
// 400: ValidationError // 400: ValidationError
// swagger:route DELETE /api/v1/provisioning/alert-rules/{UID} provisioning RouteDeleteAlertRule // swagger:route DELETE /api/v1/provisioning/alert-rules/{UID} provisioning stable RouteDeleteAlertRule
// //
// Delete a specific alert rule by UID. // Delete a specific alert rule by UID.
// //
@ -110,7 +110,7 @@ func NewAlertRule(rule models.AlertRule, provenance models.Provenance) AlertRule
} }
} }
// swagger:route PUT /api/v1/provisioning/folder/{FolderUID}/rule-groups/{Group} provisioning RoutePutAlertRuleGroup // swagger:route PUT /api/v1/provisioning/folder/{FolderUID}/rule-groups/{Group} provisioning stable RoutePutAlertRuleGroup
// //
// Update the interval of a rule group. // Update the interval of a rule group.
// //

@ -7,7 +7,7 @@ import (
"github.com/grafana/grafana/pkg/services/ngalert/notifier/channels" "github.com/grafana/grafana/pkg/services/ngalert/notifier/channels"
) )
// swagger:route GET /api/v1/provisioning/contact-points provisioning RouteGetContactpoints // swagger:route GET /api/v1/provisioning/contact-points provisioning stable RouteGetContactpoints
// //
// Get all the contact points. // Get all the contact points.
// //
@ -15,7 +15,7 @@ import (
// 200: Route // 200: Route
// 400: ValidationError // 400: ValidationError
// swagger:route POST /api/v1/provisioning/contact-points provisioning RoutePostContactpoints // swagger:route POST /api/v1/provisioning/contact-points provisioning stable RoutePostContactpoints
// //
// Create a contact point. // Create a contact point.
// //
@ -26,7 +26,7 @@ import (
// 202: Ack // 202: Ack
// 400: ValidationError // 400: ValidationError
// swagger:route PUT /api/v1/provisioning/contact-points/{UID} provisioning RoutePutContactpoint // swagger:route PUT /api/v1/provisioning/contact-points/{UID} provisioning stable RoutePutContactpoint
// //
// Update an existing contact point. // Update an existing contact point.
// //
@ -37,7 +37,7 @@ import (
// 202: Ack // 202: Ack
// 400: ValidationError // 400: ValidationError
// swagger:route DELETE /api/v1/provisioning/contact-points/{UID} provisioning RouteDeleteContactpoints // swagger:route DELETE /api/v1/provisioning/contact-points/{UID} provisioning stable RouteDeleteContactpoints
// //
// Delete a contact point. // Delete a contact point.
// //

@ -5,7 +5,7 @@ import (
"github.com/prometheus/alertmanager/config" "github.com/prometheus/alertmanager/config"
) )
// swagger:route GET /api/v1/provisioning/mute-timings provisioning RouteGetMuteTimings // swagger:route GET /api/v1/provisioning/mute-timings provisioning stable RouteGetMuteTimings
// //
// Get all the mute timings. // Get all the mute timings.
// //
@ -13,7 +13,7 @@ import (
// 200: MuteTimings // 200: MuteTimings
// 400: ValidationError // 400: ValidationError
// swagger:route GET /api/v1/provisioning/mute-timings/{name} provisioning RouteGetMuteTiming // swagger:route GET /api/v1/provisioning/mute-timings/{name} provisioning stable RouteGetMuteTiming
// //
// Get a mute timing. // Get a mute timing.
// //
@ -21,7 +21,7 @@ import (
// 200: MuteTimeInterval // 200: MuteTimeInterval
// 400: ValidationError // 400: ValidationError
// swagger:route POST /api/v1/provisioning/mute-timings provisioning RoutePostMuteTiming // swagger:route POST /api/v1/provisioning/mute-timings provisioning stable RoutePostMuteTiming
// //
// Create a new mute timing. // Create a new mute timing.
// //
@ -32,7 +32,7 @@ import (
// 201: MuteTimeInterval // 201: MuteTimeInterval
// 400: ValidationError // 400: ValidationError
// swagger:route PUT /api/v1/provisioning/mute-timings/{name} provisioning RoutePutMuteTiming // swagger:route PUT /api/v1/provisioning/mute-timings/{name} provisioning stable RoutePutMuteTiming
// //
// Replace an existing mute timing. // Replace an existing mute timing.
// //
@ -43,7 +43,7 @@ import (
// 200: MuteTimeInterval // 200: MuteTimeInterval
// 400: ValidationError // 400: ValidationError
// swagger:route DELETE /api/v1/provisioning/mute-timings/{name} provisioning RouteDeleteMuteTiming // swagger:route DELETE /api/v1/provisioning/mute-timings/{name} provisioning stable RouteDeleteMuteTiming
// //
// Delete a mute timing. // Delete a mute timing.
// //
@ -55,7 +55,7 @@ import (
// swagger:model // swagger:model
type MuteTimings []MuteTimeInterval type MuteTimings []MuteTimeInterval
// swagger:parameters RouteGetTemplate RouteGetMuteTiming RoutePutMuteTiming RouteDeleteMuteTiming // swagger:parameters RouteGetTemplate RouteGetMuteTiming RoutePutMuteTiming stable RouteDeleteMuteTiming
type RouteGetMuteTimingParam struct { type RouteGetMuteTimingParam struct {
// Template Name // Template Name
// in:path // in:path

@ -1,6 +1,6 @@
package definitions package definitions
// swagger:route GET /api/v1/provisioning/policies provisioning RouteGetPolicyTree // swagger:route GET /api/v1/provisioning/policies provisioning stable RouteGetPolicyTree
// //
// Get the notification policy tree. // Get the notification policy tree.
// //
@ -8,7 +8,7 @@ package definitions
// 200: Route // 200: Route
// 400: ValidationError // 400: ValidationError
// swagger:route PUT /api/v1/provisioning/policies provisioning RoutePutPolicyTree // swagger:route PUT /api/v1/provisioning/policies provisioning stable RoutePutPolicyTree
// //
// Sets the notification policy tree. // Sets the notification policy tree.
// //

@ -4,7 +4,7 @@ import (
"github.com/grafana/grafana/pkg/services/ngalert/models" "github.com/grafana/grafana/pkg/services/ngalert/models"
) )
// swagger:route GET /api/v1/provisioning/templates provisioning RouteGetTemplates // swagger:route GET /api/v1/provisioning/templates provisioning stable RouteGetTemplates
// //
// Get all message templates. // Get all message templates.
// //
@ -12,7 +12,7 @@ import (
// 200: MessageTemplate // 200: MessageTemplate
// 400: ValidationError // 400: ValidationError
// swagger:route GET /api/v1/provisioning/templates/{name} provisioning RouteGetTemplate // swagger:route GET /api/v1/provisioning/templates/{name} provisioning stable RouteGetTemplate
// //
// Get a message template. // Get a message template.
// //
@ -20,7 +20,7 @@ import (
// 200: MessageTemplate // 200: MessageTemplate
// 404: NotFound // 404: NotFound
// swagger:route PUT /api/v1/provisioning/templates/{name} provisioning RoutePutTemplate // swagger:route PUT /api/v1/provisioning/templates/{name} provisioning stable RoutePutTemplate
// //
// Updates an existing template. // Updates an existing template.
// //
@ -31,7 +31,7 @@ import (
// 202: Ack // 202: Ack
// 400: ValidationError // 400: ValidationError
// swagger:route DELETE /api/v1/provisioning/templates/{name} provisioning RouteDeleteTemplate // swagger:route DELETE /api/v1/provisioning/templates/{name} provisioning stable RouteDeleteTemplate
// //
// Delete a template. // Delete a template.
// //

@ -813,6 +813,13 @@
"type": "array", "type": "array",
"x-go-name": "InhibitRules" "x-go-name": "InhibitRules"
}, },
"muteTimeProvenances": {
"additionalProperties": {
"$ref": "#/definitions/Provenance"
},
"type": "object",
"x-go-name": "MuteTimeProvenances"
},
"mute_time_intervals": { "mute_time_intervals": {
"items": { "items": {
"$ref": "#/definitions/MuteTimeInterval" "$ref": "#/definitions/MuteTimeInterval"
@ -3248,6 +3255,7 @@
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models" "x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
}, },
"alertGroup": { "alertGroup": {
"description": "AlertGroup alert group",
"properties": { "properties": {
"alerts": { "alerts": {
"description": "alerts", "description": "alerts",
@ -3269,9 +3277,7 @@
"labels", "labels",
"receiver" "receiver"
], ],
"type": "object", "type": "object"
"x-go-name": "AlertGroup",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
}, },
"alertGroups": { "alertGroups": {
"description": "AlertGroups alert groups", "description": "AlertGroups alert groups",
@ -3398,7 +3404,6 @@
"$ref": "#/definitions/Duration" "$ref": "#/definitions/Duration"
}, },
"gettableAlert": { "gettableAlert": {
"description": "GettableAlert gettable alert",
"properties": { "properties": {
"annotations": { "annotations": {
"$ref": "#/definitions/labelSet" "$ref": "#/definitions/labelSet"
@ -3457,18 +3462,18 @@
"status", "status",
"updatedAt" "updatedAt"
], ],
"type": "object" "type": "object",
"x-go-name": "GettableAlert",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
}, },
"gettableAlerts": { "gettableAlerts": {
"description": "GettableAlerts gettable alerts",
"items": { "items": {
"$ref": "#/definitions/gettableAlert" "$ref": "#/definitions/gettableAlert"
}, },
"type": "array", "type": "array"
"x-go-name": "GettableAlerts",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
}, },
"gettableSilence": { "gettableSilence": {
"description": "GettableSilence gettable silence",
"properties": { "properties": {
"comment": { "comment": {
"description": "comment", "description": "comment",
@ -3520,14 +3525,17 @@
"status", "status",
"updatedAt" "updatedAt"
], ],
"type": "object" "type": "object",
"x-go-name": "GettableSilence",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
}, },
"gettableSilences": { "gettableSilences": {
"description": "GettableSilences gettable silences",
"items": { "items": {
"$ref": "#/definitions/gettableSilence" "$ref": "#/definitions/gettableSilence"
}, },
"type": "array" "type": "array",
"x-go-name": "GettableSilences",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
}, },
"labelSet": { "labelSet": {
"additionalProperties": { "additionalProperties": {
@ -3656,7 +3664,6 @@
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models" "x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
}, },
"postableSilence": { "postableSilence": {
"description": "PostableSilence postable silence",
"properties": { "properties": {
"comment": { "comment": {
"description": "comment", "description": "comment",
@ -3696,10 +3703,11 @@
"matchers", "matchers",
"startsAt" "startsAt"
], ],
"type": "object" "type": "object",
"x-go-name": "PostableSilence",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
}, },
"receiver": { "receiver": {
"description": "Receiver receiver",
"properties": { "properties": {
"name": { "name": {
"description": "name", "description": "name",
@ -3710,7 +3718,9 @@
"required": [ "required": [
"name" "name"
], ],
"type": "object" "type": "object",
"x-go-name": "Receiver",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
}, },
"silence": { "silence": {
"description": "Silence silence", "description": "Silence silence",

@ -1670,7 +1670,8 @@
"/api/v1/provisioning/alert-rules": { "/api/v1/provisioning/alert-rules": {
"post": { "post": {
"tags": [ "tags": [
"provisioning" "provisioning",
"stable"
], ],
"summary": "Create a new alert rule.", "summary": "Create a new alert rule.",
"operationId": "RoutePostAlertRule", "operationId": "RoutePostAlertRule",
@ -1702,7 +1703,8 @@
"/api/v1/provisioning/alert-rules/{UID}": { "/api/v1/provisioning/alert-rules/{UID}": {
"get": { "get": {
"tags": [ "tags": [
"provisioning" "provisioning",
"stable"
], ],
"summary": "Get a specific alert rule by UID.", "summary": "Get a specific alert rule by UID.",
"operationId": "RouteGetAlertRule", "operationId": "RouteGetAlertRule",
@ -1734,7 +1736,8 @@
"application/json" "application/json"
], ],
"tags": [ "tags": [
"provisioning" "provisioning",
"stable"
], ],
"summary": "Update an existing alert rule.", "summary": "Update an existing alert rule.",
"operationId": "RoutePutAlertRule", "operationId": "RoutePutAlertRule",
@ -1770,7 +1773,8 @@
}, },
"delete": { "delete": {
"tags": [ "tags": [
"provisioning" "provisioning",
"stable"
], ],
"summary": "Delete a specific alert rule by UID.", "summary": "Delete a specific alert rule by UID.",
"operationId": "RouteDeleteAlertRule", "operationId": "RouteDeleteAlertRule",
@ -1798,7 +1802,8 @@
"/api/v1/provisioning/contact-points": { "/api/v1/provisioning/contact-points": {
"get": { "get": {
"tags": [ "tags": [
"provisioning" "provisioning",
"stable"
], ],
"summary": "Get all the contact points.", "summary": "Get all the contact points.",
"operationId": "RouteGetContactpoints", "operationId": "RouteGetContactpoints",
@ -1822,7 +1827,8 @@
"application/json" "application/json"
], ],
"tags": [ "tags": [
"provisioning" "provisioning",
"stable"
], ],
"summary": "Create a contact point.", "summary": "Create a contact point.",
"operationId": "RoutePostContactpoints", "operationId": "RoutePostContactpoints",
@ -1857,7 +1863,8 @@
"application/json" "application/json"
], ],
"tags": [ "tags": [
"provisioning" "provisioning",
"stable"
], ],
"summary": "Update an existing contact point.", "summary": "Update an existing contact point.",
"operationId": "RoutePutContactpoint", "operationId": "RoutePutContactpoint",
@ -1897,7 +1904,8 @@
"application/json" "application/json"
], ],
"tags": [ "tags": [
"provisioning" "provisioning",
"stable"
], ],
"summary": "Delete a contact point.", "summary": "Delete a contact point.",
"operationId": "RouteDeleteContactpoints", "operationId": "RouteDeleteContactpoints",
@ -1932,7 +1940,8 @@
"application/json" "application/json"
], ],
"tags": [ "tags": [
"provisioning" "provisioning",
"stable"
], ],
"summary": "Update the interval of a rule group.", "summary": "Update the interval of a rule group.",
"operationId": "RoutePutAlertRuleGroup", "operationId": "RoutePutAlertRuleGroup",
@ -1976,7 +1985,8 @@
"/api/v1/provisioning/mute-timings": { "/api/v1/provisioning/mute-timings": {
"get": { "get": {
"tags": [ "tags": [
"provisioning" "provisioning",
"stable"
], ],
"summary": "Get all the mute timings.", "summary": "Get all the mute timings.",
"operationId": "RouteGetMuteTimings", "operationId": "RouteGetMuteTimings",
@ -2000,7 +2010,8 @@
"application/json" "application/json"
], ],
"tags": [ "tags": [
"provisioning" "provisioning",
"stable"
], ],
"summary": "Create a new mute timing.", "summary": "Create a new mute timing.",
"operationId": "RoutePostMuteTiming", "operationId": "RoutePostMuteTiming",
@ -2032,7 +2043,8 @@
"/api/v1/provisioning/mute-timings/{name}": { "/api/v1/provisioning/mute-timings/{name}": {
"get": { "get": {
"tags": [ "tags": [
"provisioning" "provisioning",
"stable"
], ],
"summary": "Get a mute timing.", "summary": "Get a mute timing.",
"operationId": "RouteGetMuteTiming", "operationId": "RouteGetMuteTiming",
@ -2066,7 +2078,8 @@
"application/json" "application/json"
], ],
"tags": [ "tags": [
"provisioning" "provisioning",
"stable"
], ],
"summary": "Replace an existing mute timing.", "summary": "Replace an existing mute timing.",
"operationId": "RoutePutMuteTiming", "operationId": "RoutePutMuteTiming",
@ -2104,7 +2117,8 @@
}, },
"delete": { "delete": {
"tags": [ "tags": [
"provisioning" "provisioning",
"stable"
], ],
"summary": "Delete a mute timing.", "summary": "Delete a mute timing.",
"operationId": "RouteDeleteMuteTiming", "operationId": "RouteDeleteMuteTiming",
@ -2131,7 +2145,8 @@
"/api/v1/provisioning/policies": { "/api/v1/provisioning/policies": {
"get": { "get": {
"tags": [ "tags": [
"provisioning" "provisioning",
"stable"
], ],
"summary": "Get the notification policy tree.", "summary": "Get the notification policy tree.",
"operationId": "RouteGetPolicyTree", "operationId": "RouteGetPolicyTree",
@ -2155,7 +2170,8 @@
"application/json" "application/json"
], ],
"tags": [ "tags": [
"provisioning" "provisioning",
"stable"
], ],
"summary": "Sets the notification policy tree.", "summary": "Sets the notification policy tree.",
"operationId": "RoutePutPolicyTree", "operationId": "RoutePutPolicyTree",
@ -2187,7 +2203,8 @@
"/api/v1/provisioning/templates": { "/api/v1/provisioning/templates": {
"get": { "get": {
"tags": [ "tags": [
"provisioning" "provisioning",
"stable"
], ],
"summary": "Get all message templates.", "summary": "Get all message templates.",
"operationId": "RouteGetTemplates", "operationId": "RouteGetTemplates",
@ -2210,7 +2227,8 @@
"/api/v1/provisioning/templates/{name}": { "/api/v1/provisioning/templates/{name}": {
"get": { "get": {
"tags": [ "tags": [
"provisioning" "provisioning",
"stable"
], ],
"summary": "Get a message template.", "summary": "Get a message template.",
"operationId": "RouteGetTemplate", "operationId": "RouteGetTemplate",
@ -2244,7 +2262,8 @@
"application/json" "application/json"
], ],
"tags": [ "tags": [
"provisioning" "provisioning",
"stable"
], ],
"summary": "Updates an existing template.", "summary": "Updates an existing template.",
"operationId": "RoutePutTemplate", "operationId": "RoutePutTemplate",
@ -2282,7 +2301,8 @@
}, },
"delete": { "delete": {
"tags": [ "tags": [
"provisioning" "provisioning",
"stable"
], ],
"summary": "Delete a template.", "summary": "Delete a template.",
"operationId": "RouteDeleteTemplate", "operationId": "RouteDeleteTemplate",
@ -3192,6 +3212,13 @@
}, },
"x-go-name": "InhibitRules" "x-go-name": "InhibitRules"
}, },
"muteTimeProvenances": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/Provenance"
},
"x-go-name": "MuteTimeProvenances"
},
"mute_time_intervals": { "mute_time_intervals": {
"type": "array", "type": "array",
"items": { "items": {
@ -5627,6 +5654,7 @@
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models" "x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
}, },
"alertGroup": { "alertGroup": {
"description": "AlertGroup alert group",
"type": "object", "type": "object",
"required": [ "required": [
"alerts", "alerts",
@ -5649,8 +5677,6 @@
"$ref": "#/definitions/receiver" "$ref": "#/definitions/receiver"
} }
}, },
"x-go-name": "AlertGroup",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models",
"$ref": "#/definitions/alertGroup" "$ref": "#/definitions/alertGroup"
}, },
"alertGroups": { "alertGroups": {
@ -5779,7 +5805,6 @@
"$ref": "#/definitions/Duration" "$ref": "#/definitions/Duration"
}, },
"gettableAlert": { "gettableAlert": {
"description": "GettableAlert gettable alert",
"type": "object", "type": "object",
"required": [ "required": [
"labels", "labels",
@ -5839,19 +5864,19 @@
"x-go-name": "UpdatedAt" "x-go-name": "UpdatedAt"
} }
}, },
"x-go-name": "GettableAlert",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models",
"$ref": "#/definitions/gettableAlert" "$ref": "#/definitions/gettableAlert"
}, },
"gettableAlerts": { "gettableAlerts": {
"description": "GettableAlerts gettable alerts",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/definitions/gettableAlert" "$ref": "#/definitions/gettableAlert"
}, },
"x-go-name": "GettableAlerts",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models",
"$ref": "#/definitions/gettableAlerts" "$ref": "#/definitions/gettableAlerts"
}, },
"gettableSilence": { "gettableSilence": {
"description": "GettableSilence gettable silence",
"type": "object", "type": "object",
"required": [ "required": [
"comment", "comment",
@ -5904,14 +5929,17 @@
"x-go-name": "UpdatedAt" "x-go-name": "UpdatedAt"
} }
}, },
"x-go-name": "GettableSilence",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models",
"$ref": "#/definitions/gettableSilence" "$ref": "#/definitions/gettableSilence"
}, },
"gettableSilences": { "gettableSilences": {
"description": "GettableSilences gettable silences",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/definitions/gettableSilence" "$ref": "#/definitions/gettableSilence"
}, },
"x-go-name": "GettableSilences",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models",
"$ref": "#/definitions/gettableSilences" "$ref": "#/definitions/gettableSilences"
}, },
"labelSet": { "labelSet": {
@ -6041,7 +6069,6 @@
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models" "x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
}, },
"postableSilence": { "postableSilence": {
"description": "PostableSilence postable silence",
"type": "object", "type": "object",
"required": [ "required": [
"comment", "comment",
@ -6082,10 +6109,11 @@
"x-go-name": "StartsAt" "x-go-name": "StartsAt"
} }
}, },
"x-go-name": "PostableSilence",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models",
"$ref": "#/definitions/postableSilence" "$ref": "#/definitions/postableSilence"
}, },
"receiver": { "receiver": {
"description": "Receiver receiver",
"type": "object", "type": "object",
"required": [ "required": [
"name" "name"
@ -6097,6 +6125,8 @@
"x-go-name": "Name" "x-go-name": "Name"
} }
}, },
"x-go-name": "Receiver",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models",
"$ref": "#/definitions/receiver" "$ref": "#/definitions/receiver"
}, },
"silence": { "silence": {

@ -5,7 +5,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"github.com/grafana/grafana/pkg/services/featuremgmt"
"github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions" "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
"github.com/grafana/grafana/pkg/services/ngalert/models" "github.com/grafana/grafana/pkg/services/ngalert/models"
"github.com/grafana/grafana/pkg/services/ngalert/store" "github.com/grafana/grafana/pkg/services/ngalert/store"
@ -82,12 +81,10 @@ func (moa *MultiOrgAlertmanager) GetAlertmanagerConfiguration(ctx context.Contex
result.AlertmanagerConfig.Receivers = append(result.AlertmanagerConfig.Receivers, &gettableApiReceiver) result.AlertmanagerConfig.Receivers = append(result.AlertmanagerConfig.Receivers, &gettableApiReceiver)
} }
if moa.settings.IsFeatureToggleEnabled(featuremgmt.FlagAlertProvisioning) {
result, err = moa.mergeProvenance(ctx, result, org) result, err = moa.mergeProvenance(ctx, result, org)
if err != nil { if err != nil {
return definitions.GettableUserConfig{}, err return definitions.GettableUserConfig{}, err
} }
}
return result, nil return result, nil
} }

@ -40,11 +40,6 @@ func SetupTestEnv(t *testing.T, baseInterval time.Duration) (*ngalert.AlertNG, *
cfg.UnifiedAlerting.Enabled = new(bool) cfg.UnifiedAlerting.Enabled = new(bool)
*cfg.UnifiedAlerting.Enabled = true *cfg.UnifiedAlerting.Enabled = true
cfg.IsFeatureToggleEnabled = func(key string) bool {
// Enable alert provisioning FF when running tests.
return key == featuremgmt.FlagAlertProvisioning
}
m := metrics.NewNGAlert(prometheus.NewRegistry()) m := metrics.NewNGAlert(prometheus.NewRegistry())
sqlStore := sqlstore.InitTestDB(t) sqlStore := sqlstore.InitTestDB(t)
secretsService := secretsManager.SetupTestService(t, database.ProvideSecretsStore(sqlStore)) secretsService := secretsManager.SetupTestService(t, database.ProvideSecretsStore(sqlStore))

@ -9,7 +9,6 @@ import (
"github.com/grafana/grafana/pkg/infra/tracing" "github.com/grafana/grafana/pkg/infra/tracing"
"github.com/grafana/grafana/pkg/models" "github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/featuremgmt"
"github.com/grafana/grafana/pkg/tests/testinfra" "github.com/grafana/grafana/pkg/tests/testinfra"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
@ -23,7 +22,6 @@ func TestProvisioning(t *testing.T) {
EnableUnifiedAlerting: true, EnableUnifiedAlerting: true,
DisableAnonymous: true, DisableAnonymous: true,
AppModeProduction: true, AppModeProduction: true,
EnableFeatureToggles: []string{featuremgmt.FlagAlertProvisioning},
}) })
grafanaListedAddr, store := testinfra.StartGrafana(t, dir, path) grafanaListedAddr, store := testinfra.StartGrafana(t, dir, path)

Loading…
Cancel
Save