{"record":{"id":"fbe5e14c400d4f74","repo":"prometheus/node_exporter","slug":"collector-systemd-unit-whitelist-and-collector","errorCode":null,"errorMessage":"--collector.systemd.unit-whitelist and --collector.systemd.unit-include are mutually exclusive","messagePattern":"--collector\\.systemd\\.unit-whitelist and --collector\\.systemd\\.unit-include are mutually exclusive","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/systemd_linux.go","lineNumber":152,"sourceCode":"\t\t\"Detected systemd version\", []string{\"version\"}, nil)\n\tvirtualizationDesc := prometheus.NewDesc(\n\t\tprometheus.BuildFQName(namespace, subsystem, \"virtualization_info\"),\n\t\t\"Detected virtualization technology\", []string{\"virtualization_type\"}, nil)\n\n\tif *oldSystemdUnitExclude != \"\" {\n\t\tif !systemdUnitExcludeSet {\n\t\t\tlogger.Warn(\"--collector.systemd.unit-blacklist is DEPRECATED and will be removed in 2.0.0, use --collector.systemd.unit-exclude\")\n\t\t\t*systemdUnitExclude = *oldSystemdUnitExclude\n\t\t} else {\n\t\t\treturn nil, errors.New(\"--collector.systemd.unit-blacklist and --collector.systemd.unit-exclude are mutually exclusive\")\n\t\t}\n\t}\n\tif *oldSystemdUnitInclude != \"\" {\n\t\tif !systemdUnitIncludeSet {\n\t\t\tlogger.Warn(\"--collector.systemd.unit-whitelist is DEPRECATED and will be removed in 2.0.0, use --collector.systemd.unit-include\")\n\t\t\t*systemdUnitInclude = *oldSystemdUnitInclude\n\t\t} else {\n\t\t\treturn nil, errors.New(\"--collector.systemd.unit-whitelist and --collector.systemd.unit-include are mutually exclusive\")\n\t\t}\n\t}\n\tlogger.Info(\"Parsed flag --collector.systemd.unit-include\", \"flag\", *systemdUnitInclude)\n\tsystemdUnitIncludePattern := regexp.MustCompile(fmt.Sprintf(\"^(?:%s)$\", *systemdUnitInclude))\n\tlogger.Info(\"Parsed flag --collector.systemd.unit-exclude\", \"flag\", *systemdUnitExclude)\n\tsystemdUnitExcludePattern := regexp.MustCompile(fmt.Sprintf(\"^(?:%s)$\", *systemdUnitExclude))\n\n\treturn &systemdCollector{\n\t\tunitDesc:                      unitDesc,\n\t\tunitStartTimeDesc:             unitStartTimeDesc,\n\t\tunitTasksCurrentDesc:          unitTasksCurrentDesc,\n\t\tunitTasksMaxDesc:              unitTasksMaxDesc,\n\t\tsystemRunningDesc:             systemRunningDesc,\n\t\tsummaryDesc:                   summaryDesc,\n\t\tnRestartsDesc:                 nRestartsDesc,\n\t\ttimerLastTriggerDesc:          timerLastTriggerDesc,\n\t\tsocketAcceptedConnectionsDesc: socketAcceptedConnectionsDesc,\n\t\tsocketCurrentConnectionsDesc:  socketCurrentConnectionsDesc,","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/systemd_linux.go#L134-L170","documentation":"NewSystemdCollector rejects combining the deprecated --collector.systemd.unit-whitelist with the new --collector.systemd.unit-include. Both write the same include value, so specifying both explicitly is treated as a configuration conflict.","triggerScenarios":"Setting --collector.systemd.unit-whitelist non-empty while --collector.systemd.unit-include was also explicitly set (systemdUnitIncludeSet is true) when constructing the systemd collector.","commonSituations":"Post-upgrade configs where old whitelist flags remain and new include flags were added by tooling; copy-pasted example command lines mixing old and new syntax.","solutions":["Delete --collector.systemd.unit-whitelist and use --collector.systemd.unit-include only.","Temporarily keep whitelist alone (deprecated path logs a warning and maps it to include).","Search deployment configs (units, containers, ansible) for both spellings and consolidate."],"exampleFix":"// before\n--collector.systemd.unit-whitelist='^(ssh|nginx)' --collector.systemd.unit-include='^(sshd)' \n// after\n--collector.systemd.unit-include='^(ssh|nginx|sshd)'","handlingStrategy":"validation","validationCode":"legacy := flags.ContainsKey(\"collector.systemd.unit-whitelist\")\nmodern := flags.ContainsKey(\"collector.systemd.unit-include\")\nif legacy && modern {\n    return errors.New(\"systemd: drop unit-whitelist, keep only unit-include\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Standardize on unit-include/unit-exclude across all hosts.","Search IaC repos for 'unit-whitelist' and replace.","Centralize exporter flag definitions in one template."],"tags":["go","flags","systemd","deprecation"],"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"}