thanos-io/thanos · error
groupname: is repeated in the same file
Error message
groupname: %q is repeated in the same file
What it means
validate also enforces that group names are not repeated within the same rule file. Because groups are addressed by name, duplicates would make rule references ambiguous, so the second occurrence produces this error.
Solutions
- Rename one of the duplicated groups so names are unique per file
- Split duplicated groups into separate files if identical config is needed per tenant
- Run promtool check rules to detect duplicates before deployment
- Audit generated rule output for templating that collapses distinct names
Example fix
// before
groups:
- name: app-rules
rules: [...]
- name: app-rules
rules: [...]
// after
groups:
- name: app-rules-alerts
rules: [...]
- name: app-rules-recording
rules: [...] Defensive patterns
Strategy: validation
Validate before calling
seen := map[string]int{}
for _, g := range cfg.Groups {
if prev, dup := seen[g.Name]; dup {
return fmt.Errorf("group %q duplicated at groups[%d] and groups[%d]", g.Name, prev, idx)
}
seen[g.Name] = idx
} Try / catch
if errs := group.validate(); len(errs) > 0 {
for _, e := range errs {
var dupErr *fmt.Errorf
if strings.Contains(e.Error(), "is repeated") {
// fail fast with file/line context
}
}
} Prevention
- Enforce unique group names when concatenating rule files in CI
- Give generated groups tenant/namespace-scoped names
- Run promtool check rules as a pre-commit or pipeline gate
When it happens
Trigger: A single rules YAML file declares two groups with the identical name value; validate walks groups and detects the name already seen in its set.
Common situations: Merging rule files by concatenation without renaming groups; copy-pasting a group block and editing only its rules; templated generation reusing the same group name.
Related errors
- Address is duplicated for --query flag.
- retrieving rule files failed. Ignoring file. pattern
- reloading rules failed
- Groupname should not be empty
- unsupported format for label
AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07).
Data as JSON: /api/errors/ba4fc90d9588d1c4.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/rules/manager.go:259
func (g configRuleAdapter) MarshalYAML() (any, error) {
return struct {
RuleGroup map[string]any `yaml:",inline"`
}{
RuleGroup: g.nativeRuleGroup,
}, nil
}
// TODO(bwplotka): Replace this with upstream implementation after https://github.com/prometheus/prometheus/issues/7128 is fixed.
func (g configRuleAdapter) validate() (errs []error) {
set := map[string]struct{}{}
if g.group.Name == "" {
errs = append(errs, errors.New("Groupname should not be empty"))
}
if _, ok := set[g.group.Name]; ok {
errs = append(
errs,
fmt.Errorf("groupname: %q is repeated in the same file", g.group.Name),
)
}
set[g.group.Name] = struct{}{}
for i, r := range g.group.Rules {
for _, node := range r.Validate(rulefmt.RuleNode{}, model.UTF8Validation) {
var ruleName string
if r.Alert != "" {
ruleName = r.Alert
} else {
ruleName = r.Record
}
errs = append(errs, &rulefmt.Error{
Group: g.group.Name,
Rule: i,
RuleName: ruleName,
Err: node,View on GitHub (pinned to 35b8b99117)