Skip to content

Commit

Permalink
fix breaking changes
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 4250d0b commit 1f43751
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
15 changes: 12 additions & 3 deletions pkg/alertmanager/alertmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"crypto/md5"
"encoding/binary"
"fmt"
"github.com/prometheus/alertmanager/featurecontrol"
"net/http"
"net/url"
"path"
Expand Down Expand Up @@ -86,6 +87,8 @@ type Config struct {
PersisterConfig PersisterConfig
APIConcurrency int
GCInterval time.Duration

FeatureFlags string
}

// An Alertmanager manages the alerts for one user.
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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,
)
Expand Down Expand Up @@ -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))
}
)

Expand Down
4 changes: 4 additions & 0 deletions pkg/alertmanager/multitenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"flag"
"fmt"
"github.com/prometheus/alertmanager/featurecontrol"
"net/http"
"net/url"
"os"
Expand Down Expand Up @@ -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"`
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 1f43751

Please sign in to comment.