Back to Metallb

Prometheus Metrics

website/content/prometheus-metrics/_index.md

0.16.06.7 KB
Original Source

MetalLB exposes different Prometheus metrics that are listed below.

MetalLB Allocator Addresses metrics

NameDescription
metallb_allocator_addresses_in_use_totalNumber of IP addresses in use, per pool
metallb_allocator_addresses_totalNumber of usable IP addresses, per pool

MetalLB K8S client metrics

NameDescription
metallb_k8s_client_updates_totalNumber of k8s object updates that have been processed
metallb_k8s_client_update_errors_totalNumber of k8s object updates that failed for some reason
metallb_k8s_client_config_loaded_bool1 if the MetalLB configuration was successfully loaded at least once
metallb_k8s_client_config_stale_bool1 if running on a stale configuration, because the latest config failed to load

MetalLB BGP metrics

These metrics are emitted with the metallb_bgp_ prefix in both native BGP mode (by the speaker) and the deprecated FRR mode (by the FRR metrics sidecar). In the default FRR-K8s mode, the equivalent metrics use the frrk8s_ prefix instead (see FRR-K8s BGP metrics below).

NameDescription
metallb_bgp_session_upBGP session state (1 is up, 0 is down)
metallb_bgp_updates_totalNumber of BGP UPDATE messages sent
metallb_bgp_announced_prefixes_totalNumber of prefixes currently being advertised on the BGP session

FRR-K8s BGP and BFD metrics

When running in the default [FRR-K8s mode]({{% relref "concepts/bgp.md" %}}#frr-k8s-mode), additional BGP and BFD metrics are exposed by the FRR-K8s pods. These metrics use the frrk8s_ prefix and the peer label contains only the peer IP address (without port).

For example:

bash
# HELP frrk8s_bgp_updates_total Number of BGP UPDATE messages sent
# TYPE frrk8s_bgp_updates_total counter
frrk8s_bgp_updates_total{peer="172.23.0.5"} 1
frrk8s_bgp_updates_total{peer="172.23.0.6"} 1
frrk8s_bgp_updates_total{peer="172.30.0.2"} 1
frrk8s_bgp_updates_total{peer="172.30.0.3"} 1

When using BGP with a VRF, an additional label with the name of the VRF is added:

bash
frrk8s_bgp_updates_total{peer="172.23.0.5"} 1
frrk8s_bgp_updates_total{peer="172.23.0.5",vrf="red"} 1

FRR-K8s BGP metrics

NameDescription
frrk8s_bgp_session_upBGP session state (1 is up, 0 is down)
frrk8s_bgp_announced_prefixes_totalNumber of prefixes currently being advertised on the BGP session
frrk8s_bgp_received_prefixes_totalNumber of prefixes currently being received on the BGP session
frrk8s_bgp_opens_sentNumber of BGP open messages sent
frrk8s_bgp_opens_receivedNumber of BGP open messages received
frrk8s_bgp_notifications_sentNumber of BGP notification messages sent
frrk8s_bgp_updates_totalNumber of BGP UPDATE messages sent
frrk8s_bgp_updates_total_receivedNumber of BGP UPDATE messages received
frrk8s_bgp_keepalives_sentNumber of BGP keepalive messages sent
frrk8s_bgp_keepalives_receivedNumber of BGP keepalive messages received
frrk8s_bgp_route_refresh_sentNumber of BGP route refresh messages sent
frrk8s_bgp_total_sentNumber of total BGP messages sent
frrk8s_bgp_total_receivedNumber of total BGP messages received

FRR-K8s BFD metrics

NameDescription
frrk8s_bfd_session_upBFD session state (1 is up, 0 is down)
frrk8s_bfd_control_packet_inputNumber of received BFD control packets
frrk8s_bfd_control_packet_outputNumber of sent BFD control packets
frrk8s_bfd_echo_packet_inputNumber of received BFD echo packets
frrk8s_bfd_echo_packet_outputNumber of sent BFD echo packets
frrk8s_bfd_session_up_eventsNumber of BFD session up events
frrk8s_bfd_session_down_eventsNumber of BFD session down events
frrk8s_bfd_zebra_notificationsNumber of BFD zebra notifications

Backward-compatible metric relabeling

In previous versions of MetalLB, the FRR-based BGP and BFD metrics were exposed with the metallb_ prefix (e.g. metallb_bgp_session_up) and the BGP peer label included the port (e.g. peer="172.23.0.5:179").

If you are migrating from the deprecated FRR mode and need to preserve the metallb_ prefix for compatibility with existing dashboards or alerts, you can configure Prometheus metric relabeling on the FRR-K8s ServiceMonitor to rename the metrics at ingestion time:

yaml
metricRelabelings:
- sourceLabels: [__name__]
  regex: "frrk8s_bgp_(.*)"
  targetLabel: "__name__"
  replacement: "metallb_bgp_$1"
- sourceLabels: [__name__]
  regex: "frrk8s_bfd_(.*)"
  targetLabel: "__name__"
  replacement: "metallb_bfd_$1"

When deploying via Helm, this can be configured on the FRR-K8s subchart's ServiceMonitor (see the commented example in values.yaml). When deploying via kustomize, the config/prometheus-frr-k8s overlay includes these relabeling rules.

{{% notice note %}} Note that the peer label format difference (IP vs IP:port) cannot be addressed via metric relabeling. If your queries filter on peer with a port suffix, they will need to be updated. {{% /notice %}}