{"record":{"id":"e857dad43b1134a6","repo":"thanos-io/thanos","slug":"validate-relabel-config","errorCode":null,"errorMessage":"validate relabel config","messagePattern":"validate relabel config","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/alert/config.go","lineNumber":151,"sourceCode":"\t\tEndpointsConfig: clientconfig.HTTPEndpointsConfig{\n\t\t\tPathPrefix:      parsed.Path,\n\t\t\tScheme:          scheme,\n\t\t\tStaticAddresses: []string{host},\n\t\t},\n\t\tTimeout:    model.Duration(timeout),\n\t\tAPIVersion: APIv2,\n\t}, nil\n}\n\n// LoadRelabelConfigs loads a list of relabel.Config from YAML data.\nfunc LoadRelabelConfigs(confYaml []byte) ([]*relabel.Config, error) {\n\tvar cfg []*relabel.Config\n\tif err := yaml.UnmarshalStrict(confYaml, &cfg); err != nil {\n\t\treturn nil, err\n\t}\n\tfor _, c := range cfg {\n\t\tif err := c.Validate(model.UTF8Validation); err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"validate relabel config\")\n\t\t}\n\t}\n\treturn cfg, nil\n}\n","sourceCodeStart":133,"sourceCodeEnd":156,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/alert/config.go#L133-L156","documentation":"LoadRelabelConfigs strictly unmarshals the relabel_configs YAML into []*relabel.Config and then calls Validate(model.UTF8Validation) on each; any relabel rule failing Prometheus relabel validation (bad regex, unknown action, missing fields) is wrapped with 'validate relabel config'.","triggerScenarios":"runRule loads alerting relabel configs; a rule has an invalid regex (bad RE2 pattern), an unsupported action name, a missing required field (e.g. source_labels/target_label), or duplicate labels in invalid UTF-8.","commonSituations":"Typo in action: keep/match instead of keep/match; invalid regex like '.*(' for the drop action; copying scrape relabel configs that use actions unsupported in this context.","solutions":["Read the wrapped underlying error to see which relabel config and field failed; fix the regex/action/field in that rule.","Validate the relabel YAML locally with a Prometheus relabel.Config strict unmarshal before deploying.","Cross-check actions against relabel.Config supported actions for this Prometheus version."],"exampleFix":"// before\n- action: regex\n  regex: '.*('\n// after\n- action: drop\n  regex: '.*debug.*'","handlingStrategy":"validation","validationCode":"var cfgs []*relabel.Config\nif err := yaml.UnmarshalStrict(relabelYaml, &cfgs); err != nil { return err }\nfor _, c := range cfgs {\n    if err := c.Validate(model.UTF8Validation); err != nil {\n        return fmt.Errorf(\"relabel config invalid: %w\", err)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pre-validate relabel YAML with the same relabel.Config Validate call before deploy","Use only documented relabel actions for the pinned Prometheus version","Test regexes with the RE2 engine (e.g. via promtool) before committing"],"tags":["config","relabel","validation","prometheus"],"backgroundTag":"schema-validation-failed","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"}