inlet/metadata: prefer ifAlias over ifDescr for interface description
Some checks failed
CI / 🤖 Check dependabot status (push) Has been cancelled
CI / ⚖️ Check licenses (push) Has been cancelled
CI / 🐧 Build and test on Linux (push) Has been cancelled
CI / 🍏 Build and test on macOS (push) Has been cancelled
CI / 🔍 Upload code coverage (push) Has been cancelled
CI / 🔭 Build Go backend (1.23) (push) Has been cancelled
CI / 🔭 Build Go backend (1.24) (push) Has been cancelled
CI / 🔭 Build JS frontend (18) (push) Has been cancelled
CI / 🔭 Build JS frontend (20) (push) Has been cancelled
CI / 🔭 Build JS frontend (22) (push) Has been cancelled
CI / 🐋 Build Docker images (push) Has been cancelled
CI / 🚀 Publish release (push) Has been cancelled
Update Nix dependencies / Update Nix lockfile (asn2org) (push) Has been cancelled
Update Nix dependencies / Update Nix lockfile (nixpkgs) (push) Has been cancelled
Update Nix dependencies / Update dependency hashes (push) Has been cancelled

ifDescr is more likely to contain the interface name for compatibility
with ancien stuff (part of the original ifTable). The heuristics about
it being different than ifName is not 100% correct as some IOS XE device
may use the short name for ifDescr and the long name for ifName.

ifAlias contains the description for IOS XR and JunOS.
This commit is contained in:
Vincent Bernat
2025-02-21 14:28:27 +01:00
parent 708889d558
commit 798702b4c0
3 changed files with 5 additions and 4 deletions

View File

@@ -13,6 +13,7 @@ identified with a specific icon:
## Unreleased
- 💥 *inlet*: in SNMP metadata provider, prefer ifAlias over ifDescr for interface description
- 🌱 *build*: minimal Go version to build is now 1.23
- 🌱 *orchestrator*: ability to override ClickHouse or Kafka configuration in some components

View File

@@ -211,10 +211,10 @@ func (p *Provider) Poll(ctx context.Context, exporter, agent netip.Addr, port ui
// If we have ifName, use ifDescr if it is different and ifAlias
// is not. Otherwise, keep description empty.
name = ifNameVal
if okDescr && ifDescrVal != ifNameVal {
description = ifDescrVal
} else if okAlias {
if okAlias && ifAliasVal != ifNameVal {
description = ifAliasVal
} else if okDescr && ifDescrVal != ifNameVal {
description = ifDescrVal
}
} else {
// Don't handle the other case yet. It would be unexpected to

View File

@@ -241,7 +241,7 @@ func TestPoller(t *testing.T) {
OID: "1.3.6.1.2.1.31.1.1.1.18.645",
Type: gosnmp.OctetString,
OnGet: func() (interface{}, error) {
return "GigabitEthernet-something", nil
return "Gi0/0/0/5", nil
},
},
},