{"record":{"id":"b9a72f2b38b92a1d","repo":"thanos-io/thanos","slug":"no-query-configuration-parameter-was-given","errorCode":null,"errorMessage":"no query configuration parameter was given","messagePattern":"no query configuration parameter was given","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/rule.go","lineNumber":228,"sourceCode":"\t\t}\n\n\t\t// Parse and check query configuration.\n\t\tlookupQueries := map[string]struct{}{}\n\t\tfor _, q := range conf.query.addrs {\n\t\t\tif _, ok := lookupQueries[q]; ok {\n\t\t\t\treturn errors.Errorf(\"Address %s is duplicated for --query flag.\", q)\n\t\t\t}\n\n\t\t\tlookupQueries[q] = struct{}{}\n\t\t}\n\n\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}","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/rule.go#L210-L246","documentation":"The rule component needs at least one source of Query API endpoints: --query.sd-files, --query, --query.config (file/inline), or --grpc-query-endpoint. errors.New raises this when all four are empty, aborting startup because a rule Ruler without stores cannot evaluate queries.","triggerScenarios":"The Setup hook checks len(conf.query.sdFiles)==0 && len(conf.query.addrs)==0 && len(conf.queryConfigYAML)==0 && len(conf.grpcQueryEndpoints)==0 and returns this error when every source is unset.","commonSituations":"Deploying thanos rule with only store endpoints configured instead of query endpoints; forgetting the --query flag in a systemd unit; Helm values dropping the query address list; the query config file path given but file empty so Content() yields zero bytes.","solutions":["Pass at least one query endpoint, e.g. --query=thanos-query-frontend:9090 or --grpc-query-endpoint.","Provide a --query.config file listing endpoints if you need advanced settings.","Check the query config file actually contains endpoints (it may be empty or wrong file).","Fix the deployment template so the query address list is rendered into the rule args."],"exampleFix":"// before\nthanos rule --data-dir=/data --rule=...   # no query source\n// after\nthanos rule --data-dir=/data --rule=... --query=thanos-query:9090","handlingStrategy":"validation","validationCode":"def check_query_source(args):\n    has_static = any(a.startswith((\"--query=\", \"--query.sd-files=\", \"--grpc-query-endpoint=\")) for a in args)\n    has_file = any(a.startswith((\"--query.config=\", \"--query.config-file=\")) for a in args)\n    if not has_static and not has_file:\n        raise SystemExit(\"thanos rule requires --query, --query.sd-files, --query.config*, or --grpc-query-endpoint\")","typeGuard":"def has_query_source(arg_list):\n    prefixes = (\"--query\", \"--query.sd-files\", \"--grpc-query-endpoint\", \"--query.config\")\n    return any(a.split(\"=\")[0] in prefixes for a in arg_list)","tryCatchPattern":null,"preventionTips":["Always pass at least --query=<query-service>:9090 in rule deployments.","Verify rendered args with a dry-run/helm template before apply.","Keep the query config file non-empty and validated in CI.","Document required flags in your runbook/systemd unit template."],"tags":["cli","config","missing-argument","startup"],"backgroundTag":"missing-required-flag","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"}