Skip to main content

FastAPI Healthchecks

Project description

FastAPI health checks

Configurable health checks endpoints for FastAPI applications.

Quickstart

app = FastAPI()
app.include_router(
    HealthcheckRouter(
        Probe(
            name="readiness",
            checks=[
                PostgreSqlCheck(host="db.example.com", username=..., password=...),
                RedisCheck(host="redis.example.com", username=..., password=...),
            ],
        ),
        Probe(
            name="liveness",
            checks=[
                ...,
            ],
        ),
    ),
    prefix="/health",
)

The probes from this example will be available as GET /health/readiness and GET /health/liveness.

Bundled checks

  • PostgreSqlCheck – checks PostgreSQL server availability
  • RedisCheck – checks Redis server availability
  • RabbitMqCheck – checks RabbitMQ server availability
  • SettingsCheck – validates settings models based on pydantic BaseModel
  • HttpCheck – checks availability of specified URL
  • CephCheck – checks Ceph server availability

Custom checks

You can create your own checks by providing custom fastapi_healthchecks.checks.Check implementations. Like this:

class MaintenanceCheck(Check):
    async def __call__(self) -> CheckResult:
        if is_maintenance():
            return CheckResult(name="Maintenance", passed=False, details="Closed for maintenance")
        else:
            return CheckResult(name="Maintenance", passed=True)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi_healthchecks-1.1.0.tar.gz (6.5 kB view hashes)

Uploaded Source

Built Distribution

fastapi_healthchecks-1.1.0-py3-none-any.whl (9.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page