thanos-io/thanos · error
Address is duplicated for --query flag.
Error message
Address %s is duplicated for --query flag.
What it means
The rule command requires each store API address given via --query to be unique. During Setup it builds a lookup map of conf.query.addrs and raises errors.Errorf when a duplicate address is seen. This is a configuration sanity check before constructing the store set.
Solutions
- Deduplicate the --query address list so each endpoint appears exactly once.
- Fix templating that appends extra addrs without dedup (use unique/sprig functions in Helm).
- Use --query.sd-files or a query config file with deduped endpoints if the list is large.
- Restart after correcting; note comparison is on the raw string, so ensure exact duplicates are removed.
Example fix
// before thanos rule --query=qa:10901 --query=qb:10901 --query=qa:10901 // after thanos rule --query=qa:10901 --query=qb:10901
Defensive patterns
Strategy: validation
Validate before calling
def check_no_duplicate_queries(addrs):
dupes = {a for a in addrs if addrs.count(a) > 1}
if dupes:
raise SystemExit(f"duplicate --query addresses: {sorted(dupes)}")
return addrs Type guard
def is_unique(seq):
return len(seq) == len(set(seq)) Prevention
- Run uniq on the rendered query address list in deployment templates.
- In Helm, use sprig 'uniq' when concatenating static and extra addresses.
- Keep endpoint lists in one place (config file) to avoid drift across flags.
- Add a preflight script that echoes and checks the final command line.
When it happens
Trigger: The same endpoint string appears twice in the --query flag list (or via repeated flags), e.g. --query=qa.example.com:9091 --query=qa.example.com:9091 (identical strings after normalization).
Common situations: Helm/Kustomize templates concatenating static and extra query addresses that overlap; copy-pasting the same address; service discovery config and static flags listing the same endpoint string.
Understand the failure class
Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.
Related errors
- unsupported format for label
- --auto-gomemlimit.ratio must be greater than 0 and less…
- error validating the config
- 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/fdb51aed43e13897.
Report an issue: GitHub.
Appendix: source
Thrown at cmd/thanos/rule.go:216
tsdbOpts := &tsdb.Options{
MinBlockDuration: int64(time.Duration(*tsdbBlockDuration) / time.Millisecond),
MaxBlockDuration: int64(time.Duration(*tsdbBlockDuration) / time.Millisecond),
RetentionDuration: int64(time.Duration(*tsdbRetention) / time.Millisecond),
NoLockfile: *noLockFile,
WALCompression: compressutil.ParseCompressionType(*walCompression, compression.Snappy),
}
agentOpts := &agent.Options{
WALCompression: compressutil.ParseCompressionType(*walCompression, compression.Snappy),
NoLockfile: *noLockFile,
}
// 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.View on GitHub (pinned to 35b8b99117)