summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDate Huang <tjjh89017@hotmail.com>2026-07-16 19:46:02 +0800
committerDate Huang <tjjh89017@hotmail.com>2026-07-16 19:46:02 +0800
commiteb6ae2a8bc2906181a8b8130d9c225f7def7bfa8 (patch)
treecd10543a780ec6241c96a89cd60f5ef5381877e1 /src
parent80e1764619b2aa11df69d351a8f149e6784cce10 (diff)
downloadvyos-1x-eb6ae2a8bc2906181a8b8130d9c225f7def7bfa8.tar.gz
vyos-1x-eb6ae2a8bc2906181a8b8130d9c225f7def7bfa8.zip
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 <json|plain-text> - collector bgp peer-group - collector bgp peer-hostname - collector bgp peer-type - collector ospf-instance <id> - 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
Diffstat (limited to 'src')
-rwxr-xr-xsrc/conf_mode/service_monitoring_prometheus.py16
1 files changed, 16 insertions, 0 deletions
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': {}})