Skip to content

Commit

Permalink
Deprecate ruler.alertmanager-use-v2 flag
Browse files Browse the repository at this point in the history
Signed-off-by: alanprot <[email protected]>
  • Loading branch information
alanprot committed Apr 2, 2024
1 parent ce643d0 commit d1a2139
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 11 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions integration/e2ecortex/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 1 addition & 7 deletions pkg/ruler/notifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
4 changes: 1 addition & 3 deletions pkg/ruler/ruler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.")
Expand All @@ -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.")

Expand Down

0 comments on commit d1a2139

Please sign in to comment.