From eb6ae2a8bc2906181a8b8130d9c225f7def7bfa8 Mon Sep 17 00:00:00 2001 From: Date Huang Date: Thu, 16 Jul 2026 19:46:02 +0800 Subject: T9073: frr-exporter: add CLI support for optional collectors and collector options frr_exporter v1.5.0 enables the bgp, ospf, bfd and route collectors by default, while bgpl2vpn, pim and vrrp must be enabled explicitly. Expose bgpl2vpn (CLI: bgp-l2-vpn) and pim under "service monitoring prometheus frr-exporter collector", following the same CLI style as the node-exporter collectors node. The vrrp collector is not exposed since VyOS implements VRRP with keepalived and FRR's vrrpd is never started. Also expose the collector options available in v1.5.0: - collector bgp accept-filtered-prefixes - collector bgp advertised-prefixes - collector bgp peer-description - collector bgp peer-group - collector bgp peer-hostname - collector bgp peer-type - collector ospf-instance - collector detailed-routes The bgp.* options are shared by the bgp, bgp6 and bgpl2vpn collectors upstream. The bgp6 collector remains unconditionally enabled, hence existing configurations render the same ExecStart and no migration is required. Includes code generated by Claude Code --- src/conf_mode/service_monitoring_prometheus.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src') diff --git a/src/conf_mode/service_monitoring_prometheus.py b/src/conf_mode/service_monitoring_prometheus.py index b02f9f154..2aa699c3c 100755 --- a/src/conf_mode/service_monitoring_prometheus.py +++ b/src/conf_mode/service_monitoring_prometheus.py @@ -65,6 +65,22 @@ def get_config(config=None): with_recursive_defaults=True, ) + if 'frr_exporter' in monitoring: + # Optional collectors to enable, translated from the CLI node name + # to the upstream frr_exporter collector flag + collector_flags = {'bgp_l2_vpn': 'bgpl2vpn', 'pim': 'pim'} + collector = monitoring['frr_exporter'].get('collector', {}) + monitoring['frr_exporter']['optional_collectors'] = [ + flag for node, flag in collector_flags.items() if node in collector + ] + # peer-description carries a default value (json) which is merged into + # the config dict by with_recursive_defaults - the BGP peer description + # collector option is opt-in, so drop the default if it was never set + if not conf.exists( + base + ['frr-exporter', 'collector', 'bgp', 'peer-description'] + ): + collector.get('bgp', {}).pop('peer_description', None) + tmp = is_node_changed(conf, base + ['node-exporter', 'vrf']) if tmp: monitoring.update({'node_exporter_restart_required': {}}) -- cgit v1.2.3