cilium icon indicating copy to clipboard operation
cilium copied to clipboard

Add metric to provide visibility into capacity of loadbalancer ServiceID space

Open ajmmm opened this issue 4 months ago • 2 comments

Is your proposed feature related to a problem?

Currently, the loadbalancer.ServiceID type is mapped to uint16 and the LB CP can run out of available ServiceIDs in high-scale environments. However you cannot proactively monitor the capacity of available ServiceIDs at present.

Describe the feature you'd like

Provide a metric that can report on capacity of available/used loadbalancer.ServiceID values.

Notify relevant community channels

No response

(Optional) Describe your proposed solution

No response

ajmmm avatar Aug 04 '26 10:08 ajmmm

I think there can be two gauges: cilium_loadbalancer_service_id_capacity (constant 65535, the uint16 bound) and cilium_loadbalancer_service_id_used (currently allocated count). Exposing the absolute used value is more actionable for alerting than a ratio and like the headroom between 60000 and 65535 is what operators care about + reporting capacity explicitly keeps dashboards self-describing if the bound ever changes. This mirrors the existing ipam_capacity precedent. we can scope it to ServiceID only, since BackendID is uint32 and exhaustion isn't realistic. The allocator in pkg/loadbalancer/reconciler/id_allocator.go only mutates on reconcile, so updating the gauges inline at those sites is cheaper and more accurate than a polling job.

@ajmmm i would love to hear your opinions on this.

Demiserular avatar Aug 04 '26 13:08 Demiserular

Hey! :)

I'm actually of the view the LB should probably express more metrics than it does right now. The only metrics that I suspect are present are those via pkg/loadbalancer/maps and any from the StateDB tables that LB gets out of the box.

I had intended to create something akin to reconcilerMetrics{} which can encapsulate the necessary fields. As you say, the idAllocator can set values inline mapped to the relevant gauge/counter.

I personally lean more towards abstraction, so I'd personally prefer the idAllocator didn't care if it's ServiceID or BackendID.

I personally think it would be good to also capture allocation failures as a counter, so there's probably three per idAllocator.

Finally, during restore there can be ID state pending. So there's probably another set of counters outside of the idAllocator that account for mappings waiting to be restored.

ajmmm avatar Aug 04 '26 15:08 ajmmm