{"record":{"id":"dc444ccb76a378fd","repo":"thanos-io/thanos","slug":"alertmanagers-url-and-alertmanagers-config-pa","errorCode":null,"errorMessage":"--alertmanagers.url and --alertmanagers.config* parameters cannot be defined at the same time","messagePattern":"--alertmanagers\\.url and --alertmanagers\\.config\\* parameters cannot be defined at the same time","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/rule.go","lineNumber":240,"sourceCode":"\t\tconf.queryConfigYAML, err = conf.query.configPath.Content()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif len(conf.query.sdFiles) == 0 && len(conf.query.addrs) == 0 && len(conf.queryConfigYAML) == 0 && len(conf.grpcQueryEndpoints) == 0 {\n\t\t\treturn errors.New(\"no query configuration parameter was given\")\n\t\t}\n\t\tif (len(conf.query.sdFiles) != 0 || len(conf.query.addrs) != 0 || len(conf.grpcQueryEndpoints) != 0) && len(conf.queryConfigYAML) != 0 {\n\t\t\treturn errors.New(\"--query/--query.sd-files/--grpc-query-endpoint and --query.config* parameters cannot be defined at the same time\")\n\t\t}\n\n\t\t// Parse and check alerting configuration.\n\t\tconf.alertmgrsConfigYAML, err = conf.alertmgr.configPath.Content()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif len(conf.alertmgrsConfigYAML) != 0 && len(conf.alertmgr.alertmgrURLs) != 0 {\n\t\t\treturn errors.New(\"--alertmanagers.url and --alertmanagers.config* parameters cannot be defined at the same time\")\n\t\t}\n\n\t\tconf.alertRelabelConfigYAML, err = conf.alertmgr.alertRelabelConfigPath.Content()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\thttpLogOpts, err := logging.ParseHTTPOptions(reqLogConfig)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"error while parsing config for request logging\")\n\t\t}\n\n\t\tgrpcLogOpts, logFilterMethods, err := logging.ParsegRPCOptions(reqLogConfig)\n\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"error while parsing config for request logging\")\n\t\t}\n","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/rule.go#L222-L258","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nthanos rule --alertmanagers.url=http://am:9093 --alertmanagers.config-file=am.yaml\n// after\nthanos rule --alertmanagers.config-file=am.yaml   # URL moved into static_configs in am.yaml","handlingStrategy":"validation","validationCode":"def check_alertmanager_flags_mutually_exclusive(args):\n    has_url = any(a.split(\"=\")[0] == \"--alertmanagers.url\" for a in args)\n    has_cfg = any(a.split(\"=\")[0] in (\"--alertmanagers.config\", \"--alertmanagers.config-file\") for a in args)\n    if has_url and has_cfg:\n        raise SystemExit(\"use either --alertmanagers.url OR --alertmanagers.config*, not both\")","typeGuard":"def alertmanager_flags_valid(args):\n    has_url = any(a.split(\"=\")[0] == \"--alertmanagers.url\" for a in args)\n    has_cfg = any(a.split(\"=\")[0] in (\"--alertmanagers.config\", \"--alertmanagers.config-file\") for a in args)\n    return not (has_url and has_cfg)","tryCatchPattern":null,"preventionTips":["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."],"tags":["cli","config","conflicting-options","alertmanager"],"backgroundTag":"mutually-exclusive-flags","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}