diff --git a/collector/netclass_rtnl_linux.go b/collector/netclass_rtnl_linux.go index 6df34756a0..57ed813dee 100644 --- a/collector/netclass_rtnl_linux.go +++ b/collector/netclass_rtnl_linux.go @@ -96,6 +96,12 @@ func (c *netClassCollector) netClassRTNLUpdate(ch chan<- prometheus.Metric) erro []string{"device", "address", "broadcast", "duplex", "operstate", "ifalias"}, nil, ) + altnameDesc := prometheus.NewDesc( + prometheus.BuildFQName(namespace, c.subsystem, "altnames_info"), + "Non-numeric data of altname, value is always 1.", + []string{"altname", "device"}, + nil, + ) infoValue := 1.0 var ifalias = "" @@ -113,6 +119,14 @@ func (c *netClassCollector) netClassRTNLUpdate(ch chan<- prometheus.Metric) erro ch <- prometheus.MustNewConstMetric(infoDesc, prometheus.GaugeValue, infoValue, msg.Attributes.Name, msg.Attributes.Address.String(), msg.Attributes.Broadcast.String(), duplex, operstateStr[int(msg.Attributes.OperationalState)], ifalias) + if len(msg.Attributes.AltNames) > 0 { + for _, altname := range msg.Attributes.AltNames { + if altname == "" { + continue + } + ch <- prometheus.MustNewConstMetric(altnameDesc, prometheus.GaugeValue, infoValue, altname, msg.Attributes.Name) + } + } pushMetric(ch, c.getFieldDesc("address_assign_type"), "address_assign_type", ifaceInfo.AddrAssignType, prometheus.GaugeValue, msg.Attributes.Name) pushMetric(ch, c.getFieldDesc("carrier"), "carrier", msg.Attributes.Carrier, prometheus.GaugeValue, msg.Attributes.Name) pushMetric(ch, c.getFieldDesc("carrier_changes_total"), "carrier_changes_total", msg.Attributes.CarrierChanges, prometheus.CounterValue, msg.Attributes.Name)