{"record":{"id":"d28f74bb982cc481","repo":"prometheus/node_exporter","slug":"device-exclude-device-include-are-mutually-exclu-d28f74","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/netdev_common.go","lineNumber":74,"sourceCode":"\t\tif *netdevDeviceInclude == \"\" {\n\t\t\tlogger.Warn(\"--collector.netdev.device-whitelist is DEPRECATED and will be removed in 2.0.0, use --collector.netdev.device-include\")\n\t\t\t*netdevDeviceInclude = *oldNetdevDeviceInclude\n\t\t} else {\n\t\t\treturn nil, errors.New(\"--collector.netdev.device-whitelist and --collector.netdev.device-include are mutually exclusive\")\n\t\t}\n\t}\n\n\tif *oldNetdevDeviceExclude != \"\" {\n\t\tif *netdevDeviceExclude == \"\" {\n\t\t\tlogger.Warn(\"--collector.netdev.device-blacklist is DEPRECATED and will be removed in 2.0.0, use --collector.netdev.device-exclude\")\n\t\t\t*netdevDeviceExclude = *oldNetdevDeviceExclude\n\t\t} else {\n\t\t\treturn nil, errors.New(\"--collector.netdev.device-blacklist and --collector.netdev.device-exclude are mutually exclusive\")\n\t\t}\n\t}\n\n\tif *netdevDeviceExclude != \"\" && *netdevDeviceInclude != \"\" {\n\t\treturn nil, errors.New(\"device-exclude & device-include are mutually exclusive\")\n\t}\n\n\tif *netdevDeviceExclude != \"\" {\n\t\tlogger.Info(\"Parsed flag --collector.netdev.device-exclude\", \"flag\", *netdevDeviceExclude)\n\t}\n\n\tif *netdevDeviceInclude != \"\" {\n\t\tlogger.Info(\"Parsed Flag --collector.netdev.device-include\", \"flag\", *netdevDeviceInclude)\n\t}\n\n\treturn &netDevCollector{\n\t\tsubsystem:    \"network\",\n\t\tdeviceFilter: newDeviceFilter(*netdevDeviceExclude, *netdevDeviceInclude),\n\t\tmetricDescs:  map[string]*prometheus.Desc{},\n\t\tlogger:       logger,\n\t}, nil\n}\n","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/netdev_common.go#L56-L92","documentation":"NewNetDevCollector rejects startup when both --collector.netdev.device-exclude and --collector.netdev.device-include are set. The two flags express opposite filter intents, so combining them is ambiguous and refused at construction time.","triggerScenarios":"Calling NewNetDevCollector (i.e., starting node_exporter) with non-empty values for both the netdev device-exclude flag and the netdev device-include flag.","commonSituations":"Operators migrating from an old config that had device-exclude and adding a new device-include without removing the old flag; copied command lines that accumulated both flags over time.","solutions":["Remove one of the two flags: keep device-include for allow-listing or device-exclude for deny-listing.","Merge the intent into a single regex, e.g. device-include='^(eth0|eth1)$' instead of exclude plus include.","Restart node_exporter with the corrected flag set and verify with --collector.netdev.device-include only."],"exampleFix":"// before\nnode_exporter --collector.netdev.device-exclude='^lo$' --collector.netdev.device-include='^eth0$'\n// after\nnode_exporter --collector.netdev.device-include='^eth0$'","handlingStrategy":"validation","validationCode":"if cfg.NetdevDeviceExclude != \"\" && cfg.NetdevDeviceInclude != \"\" {\n    return fmt.Errorf(\"netdev: set only one of device-exclude or device-include\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Templating flag sets: choose either include or exclude per collector, never both.","Lint deployment configs for paired legacy/new flag spellings.","Prefer include-lists for explicitness."],"tags":["go","flags","configuration","netdev"],"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"}