From d1a2139f9f6bd40275404f8376c2fbdcbb8dfe9c Mon Sep 17 00:00:00 2001 From: alanprot Date: Tue, 2 Apr 2024 11:07:28 -0700 Subject: [PATCH] Deprecate ruler.alertmanager-use-v2 flag Signed-off-by: alanprot --- CHANGELOG.md | 2 +- integration/e2ecortex/client.go | 2 ++ pkg/ruler/notifier.go | 8 +------- pkg/ruler/ruler.go | 4 +--- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4760ed4991..0ee8f3a290 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ * [CHANGE] Ruler: Remove `cortex_ruler_write_requests_total`, `cortex_ruler_write_requests_failed_total`, `cortex_ruler_queries_total`, `cortex_ruler_queries_failed_total`, and `cortex_ruler_query_seconds_total` metrics for the tenant when the ruler deletes the manager for the tenant. #5772 * [CHANGE] Main: Mark `mem-ballast-size-bytes` flag as deprecated. #5816 * [CHANGE] Querier: Mark `-querier.ingester-streaming` flag as deprecated. Now query ingester streaming is always enabled. #5817 -* [CHANGE] AlertManager API: Removal of all api/v1/ endpoints following [2970](https://github.com/prometheus/alertmanager/pull/2970). [5841] +* [CHANGE] AlertManager API: Removal of all api/v1/ endpoints following [2970](https://github.com/prometheus/alertmanager/pull/2970). [5841] * [FEATURE] Ingester: Add per-tenant new metric `cortex_ingester_tsdb_data_replay_duration_seconds`. #5477 * [FEATURE] Query Frontend/Scheduler: Add query priority support. #5605 * [FEATURE] Tracing: Add `kuberesolver` to resolve endpoints address with `kubernetes://` prefix as Kubernetes service. #5731 diff --git a/integration/e2ecortex/client.go b/integration/e2ecortex/client.go index 9eb471e476..54104110f1 100644 --- a/integration/e2ecortex/client.go +++ b/integration/e2ecortex/client.go @@ -805,6 +805,8 @@ func (c *Client) CreateSilence(ctx context.Context, silence types.Silence) (stri return "", fmt.Errorf("error creating request: %v", err) } + req.Header.Set("Content-Type", "application/json") + resp, body, err := c.alertmanagerClient.Do(ctx, req) if err != nil { return "", err diff --git a/pkg/ruler/notifier.go b/pkg/ruler/notifier.go index 8f8b87f754..2665411ab3 100644 --- a/pkg/ruler/notifier.go +++ b/pkg/ruler/notifier.go @@ -117,15 +117,9 @@ func buildNotifierConfig(rulerConfig *Config) (*config.Config, error) { if len(validURLs) == 0 { return &config.Config{}, nil } - - apiVersion := config.AlertmanagerAPIVersionV1 - if rulerConfig.AlertmanangerEnableV2API { - apiVersion = config.AlertmanagerAPIVersionV2 - } - amConfigs := make([]*config.AlertmanagerConfig, 0, len(validURLs)) for _, url := range validURLs { - amConfigs = append(amConfigs, amConfigFromURL(rulerConfig, url, apiVersion)) + amConfigs = append(amConfigs, amConfigFromURL(rulerConfig, url, config.AlertmanagerAPIVersionV2)) } promConfig := &config.Config{ diff --git a/pkg/ruler/ruler.go b/pkg/ruler/ruler.go index b0c46cb694..22063c6250 100644 --- a/pkg/ruler/ruler.go +++ b/pkg/ruler/ruler.go @@ -103,8 +103,6 @@ type Config struct { AlertmanagerDiscovery bool `yaml:"enable_alertmanager_discovery"` // How long to wait between refreshing the list of Alertmanager based on DNS service discovery. AlertmanagerRefreshInterval time.Duration `yaml:"alertmanager_refresh_interval"` - // Enables the ruler notifier to use the Alertmananger V2 API. - AlertmanangerEnableV2API bool `yaml:"enable_alertmanager_v2"` // Capacity of the queue for notifications to be sent to the Alertmanager. NotificationQueueCapacity int `yaml:"notification_queue_capacity"` // HTTP timeout duration when sending notifications to the Alertmanager. @@ -177,6 +175,7 @@ func (cfg *Config) RegisterFlags(f *flag.FlagSet) { flagext.DeprecatedFlag(f, "ruler.group-timeout", "This flag is no longer functional.", util_log.Logger) //lint:ignore faillint Need to pass the global logger like this for warning on deprecated methods flagext.DeprecatedFlag(f, "ruler.num-workers", "This flag is no longer functional. For increased concurrency horizontal sharding is recommended", util_log.Logger) + flagext.DeprecatedFlag(f, "ruler.alertmanager-use-v2", "This flag is no longer functional. V1 API is deprecated and removed", util_log.Logger) cfg.ExternalURL.URL, _ = url.Parse("") // Must be non-nil f.Var(&cfg.ExternalURL, "ruler.external.url", "URL of alerts return path.") @@ -186,7 +185,6 @@ func (cfg *Config) RegisterFlags(f *flag.FlagSet) { f.StringVar(&cfg.AlertmanagerURL, "ruler.alertmanager-url", "", "Comma-separated list of URL(s) of the Alertmanager(s) to send notifications to. Each Alertmanager URL is treated as a separate group in the configuration. Multiple Alertmanagers in HA per group can be supported by using DNS resolution via -ruler.alertmanager-discovery.") f.BoolVar(&cfg.AlertmanagerDiscovery, "ruler.alertmanager-discovery", false, "Use DNS SRV records to discover Alertmanager hosts.") f.DurationVar(&cfg.AlertmanagerRefreshInterval, "ruler.alertmanager-refresh-interval", 1*time.Minute, "How long to wait between refreshing DNS resolutions of Alertmanager hosts.") - f.BoolVar(&cfg.AlertmanangerEnableV2API, "ruler.alertmanager-use-v2", false, "If enabled requests to Alertmanager will utilize the V2 API.") f.IntVar(&cfg.NotificationQueueCapacity, "ruler.notification-queue-capacity", 10000, "Capacity of the queue for notifications to be sent to the Alertmanager.") f.DurationVar(&cfg.NotificationTimeout, "ruler.notification-timeout", 10*time.Second, "HTTP timeout duration when sending notifications to the Alertmanager.")