thanos-io/thanos · error
--alertmanagers.url and --alertmanagers.config* parameters…
Error message
--alertmanagers.url and --alertmanagers.config* parameters cannot be defined at the same time
What it means
Similarly to query config, the alertmanager discovery flags are mutually exclusive: static --alertmanagers.url vs file-based --alertmanagers.config/--alertmanagers.config-file. errors.New raises this when both a non-empty alertmanager config content and at least one URL are provided, aborting startup.
Solutions
- Delete the --alertmanagers.url flags and rely solely on --alertmanagers.config-file (or vice versa).
- Convert the static URLs into the alertmanagers_config YAML (static_configs) if you want file-based config.
- Grep the unit/Helm values for --alertmanagers.url when introducing the config file.
- Restart and verify only one alertmanager configuration mechanism is active.
Example fix
// before thanos rule --alertmanagers.url=http://am:9093 --alertmanagers.config-file=am.yaml // after thanos rule --alertmanagers.config-file=am.yaml # URL moved into static_configs in am.yaml
Defensive patterns
Strategy: validation
Validate before calling
def check_alertmanager_flags_mutually_exclusive(args):
has_url = any(a.split("=")[0] == "--alertmanagers.url" for a in args)
has_cfg = any(a.split("=")[0] in ("--alertmanagers.config", "--alertmanagers.config-file") for a in args)
if has_url and has_cfg:
raise SystemExit("use either --alertmanagers.url OR --alertmanagers.config*, not both") Type guard
def alertmanager_flags_valid(args):
has_url = any(a.split("=")[0] == "--alertmanagers.url" for a in args)
has_cfg = any(a.split("=")[0] in ("--alertmanagers.config", "--alertmanagers.config-file") for a in args)
return not (has_url and has_cfg) Prevention
- Convert static URLs to static_configs in the alertmanager config file and drop --alertmanagers.url.
- Assert flag exclusivity in a prestart wrapper.
- Audit Helm extraArgs for both styles after chart upgrades.
- Keep a single source of truth for alertmanager discovery config.
When it happens
Trigger: Setup checks len(conf.alertmgrsConfigYAML)!=0 && len(conf.alertmgr.alertmgrURLs)!=0 after loading the config content, and aborts, e.g. --alertmanagers.url=http://am:9093 together with --alertmanagers.config-file=am.yaml.
Common situations: Switching to an alertmanager SD config file while the old --alertmanagers.url flag remains in the systemd unit or Helm values; charts that inject a default URL while users add a config file.
Understand the failure class
Background: "mutually exclusive" flag errors: what "can't supply both nx and xx", "--raw is not compatible with -i" and "cannot be used with" mean, and how to fix them — this error's family across 29 libraries.
Related errors
- --query/--query.sd-files/--grpc-query-endpoint and…
- level is bigger then default set of
- unknown sync strategy
- get compaction levels
- penalty based deduplication needs at least one replica…
AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07).
Data as JSON: /api/errors/dc444ccb76a378fd.
Report an issue: GitHub.
Appendix: source
Thrown at cmd/thanos/rule.go:240
conf.queryConfigYAML, err = conf.query.configPath.Content()
if err != nil {
return err
}
if len(conf.query.sdFiles) == 0 && len(conf.query.addrs) == 0 && len(conf.queryConfigYAML) == 0 && len(conf.grpcQueryEndpoints) == 0 {
return errors.New("no query configuration parameter was given")
}
if (len(conf.query.sdFiles) != 0 || len(conf.query.addrs) != 0 || len(conf.grpcQueryEndpoints) != 0) && len(conf.queryConfigYAML) != 0 {
return errors.New("--query/--query.sd-files/--grpc-query-endpoint and --query.config* parameters cannot be defined at the same time")
}
// Parse and check alerting configuration.
conf.alertmgrsConfigYAML, err = conf.alertmgr.configPath.Content()
if err != nil {
return err
}
if len(conf.alertmgrsConfigYAML) != 0 && len(conf.alertmgr.alertmgrURLs) != 0 {
return errors.New("--alertmanagers.url and --alertmanagers.config* parameters cannot be defined at the same time")
}
conf.alertRelabelConfigYAML, err = conf.alertmgr.alertRelabelConfigPath.Content()
if err != nil {
return err
}
httpLogOpts, err := logging.ParseHTTPOptions(reqLogConfig)
if err != nil {
return errors.Wrap(err, "error while parsing config for request logging")
}
grpcLogOpts, logFilterMethods, err := logging.ParsegRPCOptions(reqLogConfig)
if err != nil {
return errors.Wrap(err, "error while parsing config for request logging")
}
View on GitHub (pinned to 35b8b99117)