Skip to content

Redis Health Indicator

Permite verificar el estado de un servidor Redis.

Registrar en el contenedor de IoC

Para registrar el HealthIndicator solo deberemos pasar como parámetro la cadena de conexión.

    public void Configure(IWebHostBuilder builder)
    {
      builder.ConfigureServices((ctx, c) =>
      {
      c.AddSingleton<IHealthIndicator, RedisHealthIndicator>(s =>
        new RedisHealthIndicator("10.20.7.43,password=************")
        );
      });
    }

Una vez que llamemos al /health endpoint, podremos visualizar lo siguiente:

{
    "status": {
        "code": "UP",
        "description": ""
    },
    "details": {
        "redisHealthIndicator": {
            "status": {
                "code": "UP",
                "description": ""
            },
            "details": {
                "serverStatus": "10.20.7.43:6379: Standalone v3.2.3, master; 16 databases; keep-alive: 00:01:00; int: ConnectedEstablished; sub: ConnectedEstablished, 1 active\r\n10.20.7.43:6379: int ops=13, qu=0, qs=0, qc=0, wr=0, sync=11, async=2, socks=1; sub ops=4, qu=0, qs=0, qc=0, wr=0, subs=1, sync=4, socks=1\r\nCircular op-count snapshot; int: 0+13=13 (1,30 ops/s; spans 10s); sub: 0+4=4 (0,40 ops/s; spans 10s)\r\nSync timeouts: 0; fire and forget: 0; last heartbeat: 0s ago\r\n"
            }
        }
    }
}