node_exporter
node_exporter copied to clipboard
Add node_network_ipv4_address_info metric
I'm just wondering why not add IP addresses of network interfaces in node_network_up
or something else.
I can find the mac addresses of devices but can not find IP addresses in /metrics
This should be an own metric, probably on a disabled-by-default collector.
node_network_ipv4_address_info{device="tap1",addr="10.0.1.1",netmask="27",scope="global"} 1
Hi @roidelapluie, @discordianfish. I would like to help with this enhancement, but im not sure where is a right place for that metric. My best guess would be netclass collector, but it's linux only and enabled by default. But we don't really need parse /sys/class/net/*, all requested labels can be taken from go std library.
But creating own collector is to much either, so probably netclass collector is best place for it right now?
@binjip978 I think it's own collector is the right way, unless it fits better into any other collector. If we don't need to parse netclass for that, we shouldn't put it into the netclass collector.
created PR https://github.com/prometheus/node_exporter/pull/2105 but it's not clear how to test it, probably can test at least for something like localhost..., but it's not ideal either.
This is an output example:
# HELP node_node_network_address_entries node network address by interface
# TYPE node_node_network_address_entries gauge
node_node_network_address_entries{addr="100.102.49.114",interface="utun2",netmask="32",scope="global"} 1
node_node_network_address_entries{addr="127.0.0.1",interface="lo0",netmask="8",scope="link-local"} 1
node_node_network_address_entries{addr="192.168.2.21",interface="en7",netmask="24",scope="global"} 1
node_node_network_address_entries{addr="192.168.2.5",interface="en0",netmask="24",scope="global"} 1
node_node_network_address_entries{addr="::1",interface="lo0",netmask="128",scope="link-local"} 1
node_node_network_address_entries{addr="fd7a:115c:a1e0:ab12:4843:cd96:6266:3172",interface="utun2",netmask="48",scope="global"} 1
node_node_network_address_entries{addr="fe80::1",interface="lo0",netmask="64",scope="link-local"} 1
node_node_network_address_entries{addr="fe80::1073:774b:6802:8cd3",interface="en0",netmask="64",scope="link-local"} 1
node_node_network_address_entries{addr="fe80::181c:e0c3:996e:9f19",interface="en7",netmask="64",scope="link-local"} 1
node_node_network_address_entries{addr="fe80::6a2e:7b5f:3cbd:b126",interface="utun1",netmask="64",scope="link-local"} 1
node_node_network_address_entries{addr="fe80::9c97:ddff:fee0:4bf9",interface="awdl0",netmask="64",scope="link-local"} 1
node_node_network_address_entries{addr="fe80::9c97:ddff:fee0:4bf9",interface="llw0",netmask="64",scope="link-local"} 1
node_node_network_address_entries{addr="fe80::aede:48ff:fe00:1122",interface="en5",netmask="64",scope="link-local"} 1
node_node_network_address_entries{addr="fe80::aede:48ff:fe00:1122",interface="utun2",netmask="64",scope="link-local"} 1
node_node_network_address_entries{addr="fe80::b038:3e71:af95:b8ae",interface="utun0",netmask="64",scope="link-local"} 1
@discordianfish I kinda feel like this should live in the netdev collector. No need add yet another network-related collector.
How would you deal with cardinality issues then? This might create a lot of metrics.
A collector-specific boolean flag would work. We could have it off by default. --collector.netdev.address-info
Yes that looks great :)
@SuperQ Why should it be in netdev? It's not doing any net/dev parsing. But if @roidelapluie also prefers having it in netdev with a flag, fine with me.
Netdev, netclass, netstat, etc are are artifacts of Linux. BSDs use syscalls instead of parsing /proc/net/dev, but they're still in the netdev collector.
This is all about network device level metrics. So, keeping it in the netdev collector makes sense to me.
If we were to implement this metric for BSDs, we can keep this consistency.
Ok that makes sense. Maybe we should consider renaming the collectors in 2.0. @binjip978 Can you update your PR and move it to netdev and add a flag to enable it? Sorry about the back and forth!
@discordianfish sure, I will move it to netdev collector
Note: The go implementation for this uses syscalls too on linux.
I noticed the comment with sample output has node_node_
as its prefix. Shouldn't this be just node_
?
I also noticed that the IP address is labeled as addr
, but it seems to me that address
(unabbreviated) works better. It's the same label that is used by MAC addresses in network_info, and seems more consistent with the naming style for other labels. Is there a standard way of naming labels?
@nathansgreen Best to comment on #2105 - but I agree, address is better.
This can be closed, can it not? The PR was merged and AFAICT it satisfies the requirements.
Yeah I think so, closing
For anyone else like me looking for when this feature became available, it was bundled up into the v1.3.0 release (and is enabled with the --collector.netdev.address-info
cmdline flag), so you'll need at least that version for this to be available. See also https://github.com/prometheus/node_exporter/releases/tag/v1.3.0