Skip to content

Commit d1a2139

Browse files
committed
Deprecate ruler.alertmanager-use-v2 flag
Signed-off-by: alanprot <alanprot@gmail.com>
1 parent ce643d0 commit d1a2139

File tree

4 files changed

+5
-11
lines changed

4 files changed

+5
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* [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
1010
* [CHANGE] Main: Mark `mem-ballast-size-bytes` flag as deprecated. #5816
1111
* [CHANGE] Querier: Mark `-querier.ingester-streaming` flag as deprecated. Now query ingester streaming is always enabled. #5817
12-
* [CHANGE] AlertManager API: Removal of all api/v1/ endpoints following [2970](https://github.com/prometheus/alertmanager/pull/2970). [5841]
12+
* [CHANGE] AlertManager API: Removal of all api/v1/ endpoints following [2970](https://github.com/prometheus/alertmanager/pull/2970). [5841]
1313
* [FEATURE] Ingester: Add per-tenant new metric `cortex_ingester_tsdb_data_replay_duration_seconds`. #5477
1414
* [FEATURE] Query Frontend/Scheduler: Add query priority support. #5605
1515
* [FEATURE] Tracing: Add `kuberesolver` to resolve endpoints address with `kubernetes://` prefix as Kubernetes service. #5731

integration/e2ecortex/client.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,8 @@ func (c *Client) CreateSilence(ctx context.Context, silence types.Silence) (stri
805805
return "", fmt.Errorf("error creating request: %v", err)
806806
}
807807

808+
req.Header.Set("Content-Type", "application/json")
809+
808810
resp, body, err := c.alertmanagerClient.Do(ctx, req)
809811
if err != nil {
810812
return "", err

pkg/ruler/notifier.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,9 @@ func buildNotifierConfig(rulerConfig *Config) (*config.Config, error) {
117117
if len(validURLs) == 0 {
118118
return &config.Config{}, nil
119119
}
120-
121-
apiVersion := config.AlertmanagerAPIVersionV1
122-
if rulerConfig.AlertmanangerEnableV2API {
123-
apiVersion = config.AlertmanagerAPIVersionV2
124-
}
125-
126120
amConfigs := make([]*config.AlertmanagerConfig, 0, len(validURLs))
127121
for _, url := range validURLs {
128-
amConfigs = append(amConfigs, amConfigFromURL(rulerConfig, url, apiVersion))
122+
amConfigs = append(amConfigs, amConfigFromURL(rulerConfig, url, config.AlertmanagerAPIVersionV2))
129123
}
130124

131125
promConfig := &config.Config{

pkg/ruler/ruler.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,6 @@ type Config struct {
103103
AlertmanagerDiscovery bool `yaml:"enable_alertmanager_discovery"`
104104
// How long to wait between refreshing the list of Alertmanager based on DNS service discovery.
105105
AlertmanagerRefreshInterval time.Duration `yaml:"alertmanager_refresh_interval"`
106-
// Enables the ruler notifier to use the Alertmananger V2 API.
107-
AlertmanangerEnableV2API bool `yaml:"enable_alertmanager_v2"`
108106
// Capacity of the queue for notifications to be sent to the Alertmanager.
109107
NotificationQueueCapacity int `yaml:"notification_queue_capacity"`
110108
// HTTP timeout duration when sending notifications to the Alertmanager.
@@ -177,6 +175,7 @@ func (cfg *Config) RegisterFlags(f *flag.FlagSet) {
177175
flagext.DeprecatedFlag(f, "ruler.group-timeout", "This flag is no longer functional.", util_log.Logger)
178176
//lint:ignore faillint Need to pass the global logger like this for warning on deprecated methods
179177
flagext.DeprecatedFlag(f, "ruler.num-workers", "This flag is no longer functional. For increased concurrency horizontal sharding is recommended", util_log.Logger)
178+
flagext.DeprecatedFlag(f, "ruler.alertmanager-use-v2", "This flag is no longer functional. V1 API is deprecated and removed", util_log.Logger)
180179

181180
cfg.ExternalURL.URL, _ = url.Parse("") // Must be non-nil
182181
f.Var(&cfg.ExternalURL, "ruler.external.url", "URL of alerts return path.")
@@ -186,7 +185,6 @@ func (cfg *Config) RegisterFlags(f *flag.FlagSet) {
186185
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.")
187186
f.BoolVar(&cfg.AlertmanagerDiscovery, "ruler.alertmanager-discovery", false, "Use DNS SRV records to discover Alertmanager hosts.")
188187
f.DurationVar(&cfg.AlertmanagerRefreshInterval, "ruler.alertmanager-refresh-interval", 1*time.Minute, "How long to wait between refreshing DNS resolutions of Alertmanager hosts.")
189-
f.BoolVar(&cfg.AlertmanangerEnableV2API, "ruler.alertmanager-use-v2", false, "If enabled requests to Alertmanager will utilize the V2 API.")
190188
f.IntVar(&cfg.NotificationQueueCapacity, "ruler.notification-queue-capacity", 10000, "Capacity of the queue for notifications to be sent to the Alertmanager.")
191189
f.DurationVar(&cfg.NotificationTimeout, "ruler.notification-timeout", 10*time.Second, "HTTP timeout duration when sending notifications to the Alertmanager.")
192190

0 commit comments

Comments
 (0)