thanos-io/thanos · error
no query configuration parameter was given
Error message
no query configuration parameter was given
What it means
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.
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.
Example fix
// before thanos rule --data-dir=/data --rule=... # no query source // after thanos rule --data-dir=/data --rule=... --query=thanos-query:9090
Defensive patterns
Strategy: validation
Validate before calling
def check_query_source(args):
has_static = any(a.startswith(("--query=", "--query.sd-files=", "--grpc-query-endpoint=")) for a in args)
has_file = any(a.startswith(("--query.config=", "--query.config-file=")) for a in args)
if not has_static and not has_file:
raise SystemExit("thanos rule requires --query, --query.sd-files, --query.config*, or --grpc-query-endpoint") Type guard
def has_query_source(arg_list):
prefixes = ("--query", "--query.sd-files", "--grpc-query-endpoint", "--query.config")
return any(a.split("=")[0] in prefixes for a in arg_list) Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "--flag is required" and "must specify" CLI errors: how missing-required-flag validation works and how to fix it — this error's family across 20 libraries.
Related errors
- parse labels
- parse alert query url
- --query/--query.sd-files/--grpc-query-endpoint and…
- level is bigger then default set of
- unknown sync strategy
AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07).
Data as JSON: /api/errors/b9a72f2b38b92a1d.
Report an issue: GitHub.
Appendix: source
Thrown at cmd/thanos/rule.go:228
}
// Parse and check query configuration.
lookupQueries := map[string]struct{}{}
for _, q := range conf.query.addrs {
if _, ok := lookupQueries[q]; ok {
return errors.Errorf("Address %s is duplicated for --query flag.", q)
}
lookupQueries[q] = struct{}{}
}
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
}View on GitHub (pinned to 35b8b99117)