2

I have a Spring boot microservice and I use @LoadBalanced with Ribbon and works like a charm.

But now I'm searching if there is a way to collect stats or metrics from Ribbon.

There is a way to get this information programmatically?

When the application start I can see the stats like this:

INFO 13720 --- [main] cnlDynamicServerListLoadBalancer: DynamicServerListLoadBalancer for client client-one initialized: DynamicServerListLoadBalancer: {NFLoadBalancer: name = client-one, current list of Servers = [localhost: 9030, Localhost: 9050, localhost: 9040], Load balancer stats = Zone stats: {defaultzone = [Zone: defaultzone; Instance count: 3; Active connections count: 0; Circuit breaker tripped count: 0; Active connections per server: 0.0;]
}, Server stats: [[Server: localhost: 9030; Zone: defaultZone; Total Requests: 0; Successive connection failure: 0; Total blackout seconds: 0; Last connection made: Wed Dec 31 21:00:00 BRT 1969; First connection made: Wed Dec 31 21:00:00 BRT 1969; Active Connections: 0; Total failure count in last (1000) msecs: 0; Average resp time: 0.0; 90 percentile resp time: 0.0; 95 percentile resp time: 0.0; Min resp time: 0.0; Max resp time: 0.0; Stddev resp time: 0.0]
, [Server: localhost: 9050; Zone: defaultZone; Total Requests: 0; Successive connection failure: 0; Total blackout seconds: 0; Last connection made: Wed Dec 31 21:00:00 BRT 1969; First connection made: Wed Dec 31 21:00:00 BRT 1969; Active Connections: 0; Total failure count in last (1000) msecs: 0; Average resp time: 0.0; 90 percentile resp time: 0.0; 95 percentile resp time: 0.0; Min resp time: 0.0; Max resp time: 0.0; Stddev resp time: 0.0]
, [Server: localhost: 9040; Zone: defaultZone; Total Requests: 0; Successive connection failure: 0; Total blackout seconds: 0; Last connection made: Wed Dec 31 21:00:00 BRT 1969; First connection made: Wed Dec 31 21:00:00 BRT 1969; Active Connections: 0; Total failure count in last (1000) msecs: 0; Average resp time: 0.0; 90 percentile resp time: 0.0; 95 percentile resp time: 0.0; Min resp time: 0.0; Max resp time: 0.0; Stddev resp time: 0.0]
Maicon Luz
  • 51
  • 1
  • 5

1 Answers1

1

You can do something like this.

((BaseLoadBalancer) loadBalancer).getLoadBalancerStats()

On

ILoadBalancer loadBalancer
loadBalancer = LoadBalancerBuilder.newBuilder().buildFixedServerListLoadBalancer(servers);

P.S : you might not be looking for it anymore, but may help someone else.

Manish
  • 1,452
  • 15
  • 25