From 1f43751cc6766874e7c4dea3ddfa99b2bdfebe08 Mon Sep 17 00:00:00 2001 From: alanprot Date: Tue, 2 Apr 2024 09:28:39 -0700 Subject: [PATCH] fix breaking changes Signed-off-by: alanprot --- pkg/alertmanager/alertmanager.go | 15 ++++++++++++--- pkg/alertmanager/multitenant.go | 4 ++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/pkg/alertmanager/alertmanager.go b/pkg/alertmanager/alertmanager.go index b9c0b35f283..971fe3a20ae 100644 --- a/pkg/alertmanager/alertmanager.go +++ b/pkg/alertmanager/alertmanager.go @@ -5,6 +5,7 @@ import ( "crypto/md5" "encoding/binary" "fmt" + "github.com/prometheus/alertmanager/featurecontrol" "net/http" "net/url" "path" @@ -86,6 +87,8 @@ type Config struct { PersisterConfig PersisterConfig APIConcurrency int GCInterval time.Duration + + FeatureFlags string } // An Alertmanager manages the alerts for one user. @@ -243,7 +246,13 @@ func New(cfg *Config, reg *prometheus.Registry) (*Alertmanager, error) { } } - am.pipelineBuilder = notify.NewPipelineBuilder(am.registry) + featureConfig, err := featurecontrol.NewFlags(am.logger, cfg.FeatureFlags) + if err != nil { + level.Error(am.logger).Log("msg", "error parsing the feature flag list", "err", err) + return nil, errors.Wrap(err, "error parsing the feature flag list") + } + + am.pipelineBuilder = notify.NewPipelineBuilder(am.registry, featureConfig) am.wg.Add(1) go func() { @@ -390,7 +399,7 @@ func (am *Alertmanager) ApplyConfig(userID string, conf *config.Config, rawCfg s waitFunc, am.inhibitor, silence.NewSilencer(am.silences, am.marker, am.logger), - timeIntervals, + timeinterval.NewIntervener(timeIntervals), am.nflog, am.state, ) @@ -495,7 +504,7 @@ func buildReceiverIntegrations(nc config.Receiver, tmpl *template.Template, fire return } n = wrapper(name, n) - integrations = append(integrations, notify.NewIntegration(n, rs, name, i)) + integrations = append(integrations, notify.NewIntegration(n, rs, name, i, nc.Name)) } ) diff --git a/pkg/alertmanager/multitenant.go b/pkg/alertmanager/multitenant.go index 49a3e401ad2..5cce933dd6d 100644 --- a/pkg/alertmanager/multitenant.go +++ b/pkg/alertmanager/multitenant.go @@ -4,6 +4,7 @@ import ( "context" "flag" "fmt" + "github.com/prometheus/alertmanager/featurecontrol" "net/http" "net/url" "os" @@ -68,6 +69,7 @@ type MultitenantAlertmanagerConfig struct { ExternalURL flagext.URLValue `yaml:"external_url"` PollInterval time.Duration `yaml:"poll_interval"` MaxRecvMsgSize int64 `yaml:"max_recv_msg_size"` + FeatureFlags string `yaml:"feature_flags"` // Enable sharding for the Alertmanager ShardingEnabled bool `yaml:"sharding_enabled"` @@ -124,6 +126,7 @@ func (cfg *MultitenantAlertmanagerConfig) RegisterFlags(f *flag.FlagSet) { f.BoolVar(&cfg.ShardingEnabled, "alertmanager.sharding-enabled", false, "Shard tenants across multiple alertmanager instances.") f.Var(&cfg.EnabledTenants, "alertmanager.enabled-tenants", "Comma separated list of tenants whose alerts this alertmanager can process. If specified, only these tenants will be handled by alertmanager, otherwise this alertmanager can process alerts from all tenants.") f.Var(&cfg.DisabledTenants, "alertmanager.disabled-tenants", "Comma separated list of tenants whose alerts this alertmanager cannot process. If specified, a alertmanager that would normally pick the specified tenant(s) for processing will ignore them instead.") + f.StringVar(&cfg.FeatureFlags, "alertmanager.enable-feature", "", fmt.Sprintf("Prometheus AlertManager experimental features to enable. The flag can be repeated to enable multiple features. Valid options: %s", strings.Join(featurecontrol.AllowedFlags, ", "))) cfg.AlertmanagerClient.RegisterFlagsWithPrefix("alertmanager.alertmanager-client", f) cfg.Persister.RegisterFlagsWithPrefix("alertmanager", f) @@ -977,6 +980,7 @@ func (am *MultitenantAlertmanager) newAlertmanager(userID string, amConfig *amco Limits: am.limits, APIConcurrency: am.cfg.APIConcurrency, GCInterval: am.cfg.GCInterval, + FeatureFlags: am.cfg.FeatureFlags, }, reg) if err != nil { return nil, fmt.Errorf("unable to start Alertmanager for user %v: %v", userID, err)