{"record":{"id":"78da8b6300dc72f5","repo":"crowdsecurity/crowdsec","slug":"w-s-78da8b","errorCode":null,"errorMessage":"%w: %s","messagePattern":"%w: %s","errorType":"validation","errorClass":"ErrInvalidMetricsLevel","httpStatus":null,"severity":"error","filePath":"pkg/metrics/metrics.go","lineNumber":53,"sourceCode":"\tcase MetricsLevelAggregated:\n\t\tprometheus.MustRegister(GlobalParserHits, GlobalParserHitsOk, GlobalParserHitsKo,\n\t\t\tGlobalCsInfo, GlobalParsingHistogram, GlobalPourHistogram,\n\t\t\tBucketsUnderflow, BucketsCanceled, BucketsInstantiation, BucketsOverflow,\n\t\t\tLapiRouteHits,\n\t\t\tBucketsCurrentCount,\n\t\t\tCacheMetrics, RegexpCacheMetrics, NodesWlHitsOk, NodesWlHits,\n\t\t\tPapiOrdersReceived, PapiInvalidOrdersReceived, PapiLastPullTimestamp, PapiPollErrors)\n\tcase MetricsLevelFull:\n\t\tprometheus.MustRegister(GlobalParserHits, GlobalParserHitsOk, GlobalParserHitsKo,\n\t\t\tNodesHits, NodesHitsOk, NodesHitsKo,\n\t\t\tGlobalCsInfo, GlobalParsingHistogram, GlobalPourHistogram,\n\t\t\tLapiRouteHits, LapiMachineHits, LapiBouncerHits, LapiNilDecisions, LapiNonNilDecisions, LapiResponseTime,\n\t\t\tBucketsPour, BucketsUnderflow, BucketsCanceled, BucketsInstantiation, BucketsOverflow, BucketsCurrentCount,\n\t\t\tGlobalActiveDecisions, GlobalAlerts, GlobalMachinesLastHeartbeatTimestamp, NodesWlHitsOk, NodesWlHits,\n\t\t\tCacheMetrics, RegexpCacheMetrics,\n\t\t\tPapiOrdersReceived, PapiInvalidOrdersReceived, PapiLastPullTimestamp, PapiPollErrors)\n\tdefault:\n\t\treturn fmt.Errorf(\"%w: %s\", ErrInvalidMetricsLevel, metricsLevel)\n\t}\n\treturn nil\n}\n","sourceCodeStart":35,"sourceCodeEnd":57,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/metrics/metrics.go#L35-L57","documentation":"RegisterMetrics maps a user-supplied metrics level string (e.g. full, standard, none) to a set of Prometheus collectors via a switch. An unrecognized level string falls through to default and returns this error wrapped around ErrInvalidMetricsLevel, aborting metrics registration.","triggerScenarios":"registerPrometheus calls RegisterMetrics with a prometheus_level config value that matches none of the switch cases (typo, wrong case, or unsupported level).","commonSituations":"config.yaml has prometheus: level: verbose instead of full/standard/none; upgrading crowdsec where a level name was renamed; hand-edited config with trailing whitespace or wrong casing.","solutions":["Set prometheus.level in the config to one of the supported values: none, standard, or full.","Check for typos, trailing whitespace, and correct casing in the config value.","Consult the current version's documentation, as the accepted level names may have changed between releases."],"exampleFix":"// before (config.yaml)\nprometheus:\n  level: verbose\n// after\nprometheus:\n  level: full","handlingStrategy":"validation","validationCode":"var validLevels = map[string]bool{\"none\": true, \"standard\": true, \"full\": true}\nlevel := strings.TrimSpace(cfg.Prometheus.Level)\nif !validLevels[level] {\n    return fmt.Errorf(\"prometheus.level %q must be one of: none, standard, full\", level)\n}","typeGuard":null,"tryCatchPattern":"if err := metrics.RegisterMetrics(level); err != nil {\n    if errors.Is(err, metrics.ErrInvalidMetricsLevel) {\n        logger.Fatalf(\"unsupported prometheus level %q: use none|standard|full\", level)\n    }\n    return err\n}","preventionTips":["Only set prometheus.level from the documented set (none/standard/full).","Trim whitespace and use lowercase in config values.","Re-check accepted values after crowdsec upgrades."],"tags":["prometheus","metrics","config","crowdsec"],"backgroundTag":"invalid-enum-value","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}