Skip to content

Commit 456f4e0

Browse files
committed
fix(netdev): respect deviceFilter for node_network_address_info metric
Signed-off-by: RockWolf <[email protected]>
1 parent 7e801c9 commit 456f4e0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

collector/netdev_common.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func (c *netDevCollector) Update(ch chan<- prometheus.Metric) error {
148148
"info"), "node network address by device",
149149
[]string{"device", "address", "netmask", "scope"}, nil)
150150

151-
for _, addr := range getAddrsInfo(interfaces) {
151+
for _, addr := range getAddrsInfo(interfaces, &c.deviceFilter, c.logger) {
152152
ch <- prometheus.MustNewConstMetric(desc, prometheus.GaugeValue, 1,
153153
addr.device, addr.addr, addr.netmask, addr.scope)
154154
}
@@ -180,10 +180,14 @@ func scope(ip net.IP) string {
180180
}
181181

182182
// getAddrsInfo returns interface name, address, scope and netmask for all interfaces.
183-
func getAddrsInfo(interfaces []net.Interface) []addrInfo {
183+
func getAddrsInfo(interfaces []net.Interface, filter *deviceFilter, logger *slog.Logger) []addrInfo {
184184
var res []addrInfo
185185

186186
for _, ifs := range interfaces {
187+
if filter.ignored(ifs.Name) {
188+
logger.Debug("Ignoring device", "device", ifs.Name)
189+
continue
190+
}
187191
addrs, _ := ifs.Addrs()
188192
for _, addr := range addrs {
189193
ip, ipNet, err := net.ParseCIDR(addr.String())

0 commit comments

Comments
 (0)