@Override
    protected void doHealthCheck(final Health.Builder builder) {
        builder.withDetail("name", getClass().getSimpleName());

        ticketRegistryProvider.ifAvailable(registryState -> {
            val sessionCount = registryState.sessionCount();
            val ticketCount = registryState.serviceTicketCount();

            if (sessionCount == Integer.MIN_VALUE || ticketCount == Integer.MIN_VALUE) {
                val msg = String.format("Ticket registry %s reports unknown session and/or ticket counts.",
                    this.ticketRegistryProvider.getClass().getName());
                buildHealthCheckStatus(builder.unknown(), sessionCount, ticketCount, msg);
                return;
            }

            if (this.sessionCountWarnThreshold > -1 && sessionCount > this.sessionCountWarnThreshold) {
                val msg = String.format("Session count (%s) is above threshold %s. ", sessionCount, this.sessionCountWarnThreshold);
                buildHealthCheckStatus(builder.status("WARN"), sessionCount, ticketCount, msg);
                return;
            }

            if (this.serviceTicketCountWarnThreshold > -1 && ticketCount > this.serviceTicketCountWarnThreshold) {
                val msg = String.format("Service ticket count (%s) is above threshold %s.", ticketCount, this.serviceTicketCountWarnThreshold);
                buildHealthCheckStatus(builder.status("WARN"), sessionCount, ticketCount, msg);
                return;
            }

            buildHealthCheckStatus(builder.up(), sessionCount, ticketCount, "OK");
        });
    }
Threshold above which warnings are issued for session count.
core/cas-server-core-monitor/src/main/java/org/apereo/cas/monitor/TicketRegistryHealthIndicator.java