{"record":{"id":"95de960e88559396","repo":"prometheus/node_exporter","slug":"collector-systemd-unit-blacklist-and-collector","errorCode":null,"errorMessage":"--collector.systemd.unit-blacklist and --collector.systemd.unit-exclude are mutually exclusive","messagePattern":"--collector\\.systemd\\.unit-blacklist and --collector\\.systemd\\.unit-exclude are mutually exclusive","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/systemd_linux.go","lineNumber":144,"sourceCode":"\tsocketCurrentConnectionsDesc := prometheus.NewDesc(\n\t\tprometheus.BuildFQName(namespace, subsystem, \"socket_current_connections\"),\n\t\t\"Current number of socket connections\", []string{\"name\"}, nil)\n\tsocketRefusedConnectionsDesc := prometheus.NewDesc(\n\t\tprometheus.BuildFQName(namespace, subsystem, \"socket_refused_connections_total\"),\n\t\t\"Total number of refused socket connections\", []string{\"name\"}, nil)\n\tsystemdVersionDesc := prometheus.NewDesc(\n\t\tprometheus.BuildFQName(namespace, subsystem, \"version\"),\n\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,","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/systemd_linux.go#L126-L162","documentation":"NewSystemdCollector refuses to start when both the deprecated --collector.systemd.unit-blacklist and the new --collector.systemd.unit-exclude are explicitly set. Since the flags set the same underlying exclude value, only one may be given.","triggerScenarios":"Setting --collector.systemd.unit-blacklist to a non-empty value while --collector.systemd.unit-exclude was also explicitly provided (systemdUnitExcludeSet is true).","commonSituations":"Upgrading node_exporter while keeping old blacklist flags in unit files and adding the new exclude flags; automation tools layering new flags on top of legacy ones.","solutions":["Remove --collector.systemd.unit-blacklist and keep only --collector.systemd.unit-exclude with the same regex value.","If migration is staged, keep blacklist alone (it is translated with a deprecation warning) until the new flag is adopted.","Audit systemd unit files / service overrides for duplicate legacy+new flag pairs."],"exampleFix":"// before\nExecStart=... --collector.systemd.unit-blacklist='.+\\.scope' --collector.systemd.unit-exclude='.+\\.device'\n// after\nExecStart=... --collector.systemd.unit-exclude='+\\.scope|.+\\.device'","handlingStrategy":"validation","validationCode":"legacy := flags.ContainsKey(\"collector.systemd.unit-blacklist\")\nmodern := flags.ContainsKey(\"collector.systemd.unit-exclude\")\nif legacy && modern {\n    return errors.New(\"systemd: drop unit-blacklist, keep only unit-exclude\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["During migration, move values to the new flag and delete the old one in the same change.","Grep systemd units/ansible/container args for 'unit-blacklist'.","Treat deprecation warnings as migration TODOs."],"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"}