Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[corechecks/snmp] Add id and source_type to Topology Links data #15184

Merged
merged 4 commits into from
Jan 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions pkg/collector/corechecks/snmp/internal/metadata/payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ type TopologyLinkSide struct {

// TopologyLinkMetadata contains topology interface to interface links metadata
type TopologyLinkMetadata struct {
Local *TopologyLinkSide `json:"local,omitempty"`
Remote *TopologyLinkSide `json:"remote,omitempty"`
ID string `json:"id"`
SourceType string `json:"source_type"`
Local *TopologyLinkSide `json:"local"`
Remote *TopologyLinkSide `json:"remote"`
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
)

const interfaceStatusMetric = "snmp.interface.status"
const topologyLinkSourceTypeLLDP = "lldp"

// ReportNetworkDeviceMetadata reports device metadata
func (ms *MetricSender) ReportNetworkDeviceMetadata(config *checkconfig.CheckConfig, store *valuestore.ResultValueStore, origTags []string, collectTime time.Time, deviceStatus metadata.DeviceStatus) {
Expand Down Expand Up @@ -306,7 +307,13 @@ func buildNetworkTopologyMetadata(deviceID string, store *metadata.Store, interf

localInterfaceIDType, localInterfaceID = resolveLocalInterface(deviceID, interfaceIndexByIDType, localInterfaceIDType, localInterfaceID)

// remEntryUniqueID: The combination of localPortNum and lldpRemIndex is expected to be unique for each entry in
// lldpRemTable. We don't include lldpRemTimeMark (used for filtering only recent data) since it can change often.
remEntryUniqueID := localPortNum + "." + lldpRemIndex

newLink := metadata.TopologyLinkMetadata{
ID: deviceID + ":" + remEntryUniqueID,
SourceType: topologyLinkSourceTypeLLDP,
Remote: &metadata.TopologyLinkSide{
Device: &metadata.TopologyLinkDevice{
Name: store.GetColumnAsString("lldp_remote.device_name", strIndex),
Expand Down
4 changes: 4 additions & 0 deletions pkg/collector/corechecks/snmp/profile_metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,8 @@ profiles:
],
"links": [
{
"id": "profile-metadata:1.2.3.4:101.1",
"source_type": "lldp",
"local": {
"device": {
"id": "profile-metadata:1.2.3.4",
Expand All @@ -590,6 +592,8 @@ profiles:
}
},
{
"id": "profile-metadata:1.2.3.4:102.2",
"source_type": "lldp",
"local": {
"device": {
"id": "profile-metadata:1.2.3.4",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Each section from every release note are combined when the
# CHANGELOG.rst is rendered. So the text needs to be worded so that
# it does not depend on any information only available in another
# section. This may mean repeating some details, but each section
# must be readable independently of the other.
#
# Each section note must be formatted as reStructuredText.
---
enhancements:
- |
[corechecks/snmp] Add `id` and `source_type` to NDM Topology Links