{"record":{"id":"6940492054052807","repo":"prometheus/node_exporter","slug":"device-exclude-device-include-are-mutually-exclu","errorCode":null,"errorMessage":"device-exclude & device-include are mutually exclusive","messagePattern":"device-exclude & device-include are mutually exclusive","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/diskstats_common.go","lineNumber":104,"sourceCode":"\t\tprometheus.BuildFQName(namespace, diskSubsystem, \"write_time_seconds_total\"),\n\t\t\"This is the total number of seconds spent by all writes.\",\n\t\tdiskLabelNames,\n\t\tnil,\n\t)\n)\n\nfunc newDiskstatsDeviceFilter(logger *slog.Logger) (deviceFilter, error) {\n\tif *oldDiskstatsDeviceExclude != \"\" {\n\t\tif !diskstatsDeviceExcludeSet {\n\t\t\tlogger.Warn(\"--collector.diskstats.ignored-devices is DEPRECATED and will be removed in 2.0.0, use --collector.diskstats.device-exclude\")\n\t\t\t*diskstatsDeviceExclude = *oldDiskstatsDeviceExclude\n\t\t} else {\n\t\t\treturn deviceFilter{}, errors.New(\"--collector.diskstats.ignored-devices and --collector.diskstats.device-exclude are mutually exclusive\")\n\t\t}\n\t}\n\tif *diskstatsDeviceInclude != \"\" {\n\t\tif diskstatsDeviceExcludeSet && *diskstatsDeviceExclude != \"\" {\n\t\t\treturn deviceFilter{}, errors.New(\"device-exclude & device-include are mutually exclusive\")\n\t\t}\n\t\t*diskstatsDeviceExclude = \"\"\n\t}\n\n\tif *diskstatsDeviceExclude != \"\" {\n\t\tlogger.Info(\"Parsed flag --collector.diskstats.device-exclude\", \"flag\", *diskstatsDeviceExclude)\n\t}\n\n\tif *diskstatsDeviceInclude != \"\" {\n\t\tlogger.Info(\"Parsed Flag --collector.diskstats.device-include\", \"flag\", *diskstatsDeviceInclude)\n\t}\n\n\treturn newDeviceFilter(*diskstatsDeviceExclude, *diskstatsDeviceInclude), nil\n}\n","sourceCodeStart":86,"sourceCodeEnd":119,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/diskstats_common.go#L86-L119","documentation":"newDiskstatsDeviceFilter (diskstats_common.go) rejects configurations where both --collector.diskstats.device-exclude and --collector.diskstats.device-include are set to non-empty values, since a device cannot simultaneously be filtered in and out. The filter intentionally clears the exclude value when only an include is given, but errors if both were explicitly configured.","triggerScenarios":"diskstatsDeviceInclude != \"\" AND diskstatsDeviceExcludeSet AND *diskstatsDeviceExclude != \"\" — i.e. both --collector.diskstats.device-include and --collector.diskstats.device-exclude supplied with non-empty values on the command line.","commonSituations":"Operators migrating between allowlist and denylist styles who forgot to delete the other flag; copy-pasting example command lines that contain both flags; layered config management assigning each flag at a different scope.","solutions":["Pick one filtering style: keep --collector.diskstats.device-include alone (excludes are cleared) or keep --collector.diskstats.device-exclude and remove the include flag","Combine the patterns into a single regex for the flag you keep","Audit config management templates so only one of the two flags is ever rendered"],"exampleFix":"// before\nnode_exporter --collector.diskstats.device-include='^(sd|nvme)' --collector.diskstats.device-exclude='^(loop|ram)'\n// after\nnode_exporter --collector.diskstats.device-include='^(sd|nvme)'","handlingStrategy":"validation","validationCode":"# pre-flight: device-include and device-exclude must never both be set\nif echo \"$NODE_EXPORTER_ARGS\" | grep -q 'diskstats.device-include=' && echo \"$NODE_EXPORTER_ARGS\" | grep -q 'diskstats.device-exclude='; then\n  echo \"conflict: keep only one of device-include / device-exclude\"\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Decide per host between allowlist (include) and denylist (exclude) filtering, never both","Render flags from a single config-management source so layers cannot add conflicting flags","Merge patterns into one regex instead of splitting across include/exclude","Test exporter startup in CI with the exact flag set used in production"],"tags":["cli-flags","configuration","diskstats","include-exclude"],"backgroundTag":"mutually-exclusive-flags","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"}