{"record":{"id":"5db9b2f84c5ca136","repo":"prometheus/node_exporter","slug":"sysctl-s-has-only-one-value-but-expected-v","errorCode":null,"errorMessage":"sysctl %s has only one value, but expected %v","messagePattern":"sysctl (.+?) has only one value, but expected (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/sysctl_linux.go","lineNumber":113,"sourceCode":"\t\tvalues, err = c.fs.SysctlInts(s.name)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error obtaining sysctl info: %w\", err)\n\t\t}\n\t\tlength = len(values.([]int))\n\t} else {\n\t\tvalues, err = c.fs.SysctlStrings(s.name)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error obtaining sysctl info: %w\", err)\n\t\t}\n\t\tlength = len(values.([]string))\n\t}\n\n\tswitch length {\n\tcase 0:\n\t\treturn nil, fmt.Errorf(\"sysctl %s has no values\", s.name)\n\tcase 1:\n\t\tif len(s.keys) > 0 {\n\t\t\treturn nil, fmt.Errorf(\"sysctl %s has only one value, but expected %v\", s.name, s.keys)\n\t\t}\n\t\treturn []prometheus.Metric{s.newConstMetric(values)}, nil\n\n\tdefault:\n\n\t\tif len(s.keys) == 0 {\n\t\t\treturn s.newIndexedMetrics(values), nil\n\t\t}\n\n\t\tif length != len(s.keys) {\n\t\t\treturn nil, fmt.Errorf(\"sysctl %s has %d keys but only %d defined in f lag\", s.name, length, len(s.keys))\n\t\t}\n\n\t\treturn s.newMappedMetrics(values)\n\t}\n}\n\ntype sysctl struct {","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/sysctl_linux.go#L95-L131","documentation":"A scalar sysctl (exactly one value) was configured as if it were a multi-value/mapped sysctl: keys were supplied via the flags, but the value has no components to map them onto. newMetrics rejects this combination.","triggerScenarios":"Running node_exporter with --collector.sysctl.include='name:key1,key2' (or with key definitions) against a sysctl that returns a single value.","commonSituations":"Copy-pasting a multi-key config entry for a scalar tunable like net.ipv4.ip_forward; confusing comma-separated key syntax with value lists.","solutions":["Remove the ':key1,key2' suffix so the sysctl is exported as a single scalar metric","Or target a genuinely multi-value sysctl that matches the number of keys","Check `cat /proc/sys/<name>`: one token means no keys allowed"],"exampleFix":"// before\n--collector.sysctl.include='net.ipv4.ip_forward:enabled,disabled'\n// after\n--collector.sysctl.include='net.ipv4.ip_forward'","handlingStrategy":"validation","validationCode":"n := len(strings.Fields(string(data))) // data from /proc/sys/<name>\nif n != 1 && len(keys) > 0 { return errors.New(\"scalar sysctl cannot have keys\") }","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"has only one value\") { /* fix flag config and restart */ }","preventionTips":["Only append ':k1,k2' when `cat` shows multiple tokens","Validate flag syntax before rollout (staged config review)","Document per-sysctl scalar vs multi-value in your config repo"],"tags":["linux","sysctl","configuration","cli-flags"],"backgroundTag":"invalid-argument-value","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"}