Skip to content

Add mpls ldp support#150

Open
AndreyQuantum wants to merge 8 commits intotynany:masterfrom
AndreyQuantum:add-mpls-ldp-support
Open

Add mpls ldp support#150
AndreyQuantum wants to merge 8 commits intotynany:masterfrom
AndreyQuantum:add-mpls-ldp-support

Conversation

@AndreyQuantum
Copy link

@AndreyQuantum AndreyQuantum commented Feb 7, 2026

Summary

Implementation of the mpls_ldp collector to provide monitoring for MPLS Label Distribution Protocol via FRR. This addition allows for tracking LDP sessions, interface states, and label bindings.

Changes

New Collector: mpls_ldp

  • Integrated a new collector that leverages FRR JSON commands to fetch LDP state data.
  • Added support for standard LDP metrics including interface parameters, neighbor states, and IGP synchronization.

Configuration & Flags

Two new flags have been introduced to control the collector's behavior:

  • --collector.mpls_ldp: Main toggle for the collector (default: disabled).
  • --collector.mpls_ldp.binding-in-use: Enables the frr_mpls_ldp_binding_in_use metric (default: disabled).
  • Warning: This metric is opted-out by default as it can result in high cardinality in environments with large label databases.

Metrics Implemented

  • Interfaces: frr_mpls_ldp_interface_* (State, hello interval, holdtime, adjacency count).
  • Neighbors: frr_mpls_ldp_neighbor_* (State, uptime).
  • Discovery: frr_mpls_ldp_discovery_adjacency_count.
  • Bindings: frr_mpls_ldp_binding_* (Counts and usage).
  • Sync: frr_mpls_ldp_igp_sync_state.

Development & Documentation

  • README.md: Updated with documentation for the new collector and its respective flags.
  • Makefile: Updated dev/Makefile to include show-mpls-ldp commands and ensured the collector is active in the development environment for testing.

}

// Helper to parse uptime string "HH:MM:SS"
func parseUptime(uptime string) (float64, error) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better to reuse parseHMS from collector/pim.go as it performs the same function. Can you please reuse it, but also move parseHMS to collector/collector.go?


counts := make(map[string]float64)
for _, d := range data.Adjacencies {
key := strings.Join([]string{d.AddressFamily, d.NeighborID, d.Interface, d.Type}, "|")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using strings.Join with "|" as separator and then strings.Split to recover part seems risky. Could we use a structured instead? e.g.

type discoveryKey struct {
    AF, Neighbor, Iface, Type string
}

return nil
}

func processBindings(ch chan<- prometheus.Metric, output []byte, descs map[string]*prometheus.Desc) error {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update this function to something like processMPLSLDPBindings so there is no conflict with other collectors?

} `json:"bindings"`
}

func (c *mplsLDPCollector) collectBindings(ch chan<- prometheus.Metric) error {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update this function to something like collectMPLSLDPBindings so there is no conflict with other collectors?

return nil
}

func processIGPSync(ch chan<- prometheus.Metric, output []byte, descs map[string]*prometheus.Desc) error {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update this function to something like processMPLSLDPIGMPSync so there is no conflict with other collectors?

Neighbors []mplsLdpNeighbor `json:"neighbors"`
}

func (c *mplsLDPCollector) collectNeighbor(ch chan<- prometheus.Metric) error {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update this function to something like collectMPLSLDPNeighbor so there is no conflict with other collectors?


type mplsLdpInterfaceOutput map[string]mplsLdpInterface

func (c *mplsLDPCollector) collectInterface(ch chan<- prometheus.Metric) error {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update this function to something like collectMPLSLDPInterface so there is no conflict with other collectors?

return nil
}

func processNeighbor(ch chan<- prometheus.Metric, output []byte, descs map[string]*prometheus.Desc) error {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update this function to something like processMPLSLDPNeighbor so there is no conflict with other collectors?

Adjacencies []mplsLdpDiscovery `json:"adjacencies"`
}

func (c *mplsLDPCollector) collectDiscovery(ch chan<- prometheus.Metric) error {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update this function to something like collectMPLSLDPDiscovery so there is no conflict with other collectors?

return nil
}

func processDiscovery(ch chan<- prometheus.Metric, output []byte, descs map[string]*prometheus.Desc) error {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update this function to something like processMPLSLDPDiscovery so there is no conflict with other collectors?

@tynany
Copy link
Owner

tynany commented Mar 7, 2026

Thank you so much for contributing! I've made a few inline comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants