Skip to content

Healthcheck

ZhangYang edited this page Jul 12, 2019 · 1 revision

Health Check Config Readiness and liveness probes

Define health checkin endpoint

var healthCheckResponseWriterProvider = new HealthCheckerResponseProvider(env);
app.UseHealthChecks("/health/ready", new HealthCheckOptions
{
    Predicate = (check) => check.Tags.Contains("ready"),
    ResponseWriter = healthCheckResponseWriterProvider.Writer
});

app.UseHealthChecks("/health/live", new HealthCheckOptions
{
    Predicate = (_) => false,
    ResponseWriter = healthCheckResponseWriterProvider.Writer
});

Liveness probes

Liveness endpoint used for indicating application is startup.

Request /health/live

{
    message: "Hello, Welcome to RestAirline Api",
    environmentName: "Development",
    localDate: "2019-07-12T23:40:26.324795+08:00",
    utcDate: "2019-07-12T15:40:26.324795Z",
    status: "Healthy"
}

Readiness probes

Readiness endpoint used for indicating application is ready to start accepting traffic.

Request /health/ready

{
    message: "Hello, Welcome to RestAirline Api",
    environmentName: "Development",
    localDate: "2019-07-12T23:41:45.861611+08:00",
    utcDate: "2019-07-12T15:41:45.861611Z",
    status: "Healthy"
}

Clone this wiki locally