From 06ac7020e25bb3e9f9791a99d60cc05d2afaf9af Mon Sep 17 00:00:00 2001 From: Mustafa Abdelrahman Date: Mon, 22 Apr 2024 16:47:05 +0200 Subject: [PATCH] add a counter for endpoints that opted out before loadbalancing Signed-off-by: Mustafa Abdelrahman --- docs/operation/operation.md | 6 ++++++ proxy/healthy_endpoints.go | 4 +++- proxy/proxy.go | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/operation/operation.md b/docs/operation/operation.md index b530f1f339..6239a6e47b 100644 --- a/docs/operation/operation.md +++ b/docs/operation/operation.md @@ -921,6 +921,12 @@ The parameters of `-passive-health-check` option are: + `max-drop-probabilty=` - the maximum possible probability of unhealthy endpoint being not considered while choosing the endpoint for the given request +### Metrics + +A set of metrics will be exposed to track passive health checks: + +* `routing.endpoint.drop.loadbalancer`: Number of endpoints dropped before load balancing the requests + ## Memory consumption While Skipper is generally not memory bound, some features may require diff --git a/proxy/healthy_endpoints.go b/proxy/healthy_endpoints.go index b79a132769..c902a2949d 100644 --- a/proxy/healthy_endpoints.go +++ b/proxy/healthy_endpoints.go @@ -3,6 +3,7 @@ package proxy import ( "math/rand" + "github.com/zalando/skipper/metrics" "github.com/zalando/skipper/routing" ) @@ -11,7 +12,7 @@ type healthyEndpoints struct { endpointRegistry *routing.EndpointRegistry } -func (h *healthyEndpoints) filterHealthyEndpoints(endpoints []routing.LBEndpoint, rt *routing.Route) []routing.LBEndpoint { +func (h *healthyEndpoints) filterHealthyEndpoints(endpoints []routing.LBEndpoint, metrics metrics.Metrics) []routing.LBEndpoint { if h == nil { return endpoints } @@ -22,6 +23,7 @@ func (h *healthyEndpoints) filterHealthyEndpoints(endpoints []routing.LBEndpoint for _, e := range endpoints { if p < e.Metrics.HealthCheckDropProbability() { /* drop */ + metrics.IncCounter("routing.endpoint.drop.loadbalancer") } else { filtered = append(filtered, e) } diff --git a/proxy/proxy.go b/proxy/proxy.go index 6e0616530b..a7f309f49d 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -540,7 +540,7 @@ func (p *Proxy) selectEndpoint(ctx *context) *routing.LBEndpoint { rt := ctx.route endpoints := rt.LBEndpoints endpoints = p.fadein.filterFadeIn(endpoints, rt) - endpoints = p.heathlyEndpoints.filterHealthyEndpoints(endpoints, rt) + endpoints = p.heathlyEndpoints.filterHealthyEndpoints(endpoints, p.metrics) lbctx := &routing.LBContext{ Request: ctx.request,