{"record":{"id":"c317208ae8627dc6","repo":"prometheus/node_exporter","slug":"mapped-sysctl-string-values-not-supported","errorCode":null,"errorMessage":"mapped sysctl string values not supported","messagePattern":"mapped sysctl string values not supported","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/sysctl_linux.go","lineNumber":214,"sourceCode":"}\n\nfunc (s *sysctl) newMappedMetrics(v any) ([]prometheus.Metric, error) {\n\tswitch values := v.(type) {\n\tcase []int:\n\t\tmetrics := make([]prometheus.Metric, len(values))\n\t\tfor i, n := range values {\n\t\t\tkey := s.keys[i]\n\t\t\tdesc := prometheus.NewDesc(\n\t\t\t\tprometheus.BuildFQName(namespace, \"sysctl\", s.metricName()+\"_\"+key),\n\t\t\t\tfmt.Sprintf(\"sysctl %s, field %d\", s.name, i),\n\t\t\t\tnil,\n\t\t\t\tnil,\n\t\t\t)\n\t\t\tmetrics[i] = prometheus.MustNewConstMetric(desc, prometheus.UntypedValue, float64(n))\n\t\t}\n\t\treturn metrics, nil\n\tcase []string:\n\t\treturn nil, fmt.Errorf(\"mapped sysctl string values not supported\")\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unexpected type %T\", values)\n\t}\n}\n","sourceCodeStart":196,"sourceCodeEnd":219,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/sysctl_linux.go#L196-L219","documentation":"newMappedMetrics supports mapping only numeric ([]int) values to user-defined keys; when the value type is []string, mapping is explicitly unsupported and this error is returned. String sysctls must be exported unmapped.","triggerScenarios":"Configuring a string sysctl (one read via SysctlStrings) together with multiple keys in the include flag, routing it into the mapped-metrics path.","commonSituations":"Trying to attach named labels to a string-valued sysctl like kernel.domainname; assuming mapped metrics work for all types.","solutions":["Remove the key list so the string sysctl is handled by the scalar path","Drop the string sysctl from the include filter if labels are required","Contribute string mapping support upstream if truly needed"],"exampleFix":"// before\n--collector.sysctl.include='kernel.domainname:foo,bar'\n// after\n--collector.sysctl.include='kernel.domainname'","handlingStrategy":"validation","validationCode":"if strings.Contains(string(data), \" \") && !isNumeric(data) { /* string sysctl: do not configure keys */ }","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"mapped sysctl string values not supported\") { /* drop keys from this entry */ }","preventionTips":["Never configure keys for string-valued sysctls","Check the value type with `cat` before adding mapped entries","Track upstream feature requests for string mapping"],"tags":["linux","sysctl","unsupported-feature","configuration"],"backgroundTag":"unsupported-operation","analyzedSha":"17ddd77c59ba27e1508e9f7894b1e55b44d6aed3","analyzedAt":"2026-09-07T17:54:06.211Z","contentChangedAt":"2026-09-07T17:54:06.211Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}