node_exporter icon indicating copy to clipboard operation
node_exporter copied to clipboard

Add node_network_ipv4_address_info metric

Open tydra-wang opened this issue 4 years ago • 16 comments

I'm just wondering why not add IP addresses of network interfaces in node_network_upor something else. I can find the mac addresses of devices but can not find IP addresses in /metrics

tydra-wang avatar Sep 14 '20 11:09 tydra-wang

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

roidelapluie avatar Jun 22 '21 08:06 roidelapluie

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 avatar Jul 24 '21 03:07 binjip978

@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.

discordianfish avatar Jul 26 '21 10:07 discordianfish

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

binjip978 avatar Jul 30 '21 05:07 binjip978

@discordianfish I kinda feel like this should live in the netdev collector. No need add yet another network-related collector.

SuperQ avatar Jul 30 '21 07:07 SuperQ

How would you deal with cardinality issues then? This might create a lot of metrics.

roidelapluie avatar Jul 30 '21 08:07 roidelapluie

A collector-specific boolean flag would work. We could have it off by default. --collector.netdev.address-info

SuperQ avatar Jul 30 '21 08:07 SuperQ

Yes that looks great :)

roidelapluie avatar Jul 30 '21 08:07 roidelapluie

@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.

discordianfish avatar Jul 30 '21 10:07 discordianfish

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.

SuperQ avatar Jul 30 '21 11:07 SuperQ

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 avatar Aug 02 '21 12:08 discordianfish

@discordianfish sure, I will move it to netdev collector

binjip978 avatar Aug 02 '21 13:08 binjip978

Note: The go implementation for this uses syscalls too on linux.

roidelapluie avatar Aug 02 '21 14:08 roidelapluie

I noticed the comment with sample output has node_node_ as its prefix. Shouldn't this be just node_?

nathansgreen avatar Aug 23 '21 19:08 nathansgreen

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 avatar Aug 24 '21 16:08 nathansgreen

@nathansgreen Best to comment on #2105 - but I agree, address is better.

discordianfish avatar Aug 24 '21 16:08 discordianfish

This can be closed, can it not? The PR was merged and AFAICT it satisfies the requirements.

dswarbrick avatar Aug 03 '23 14:08 dswarbrick

Yeah I think so, closing

discordianfish avatar Aug 08 '23 12:08 discordianfish

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

nuclearpidgeon avatar Mar 27 '24 01:03 nuclearpidgeon