Skip to content

Latest commit

 

History

History
64 lines (45 loc) · 1.46 KB

File metadata and controls

64 lines (45 loc) · 1.46 KB

Custom health checks

Table of Contents

Requirements

What it does

In backends.py there are custom health checks for backend, like database health check, that checks whether the connection to the database is OK.

Installation

  1. Install the requirements

    INSTALLED_APPS = [
        'health_check', # requirement
        "custom_health_checks", # this app
    ]
  2. Register the custom health check to the health_check from apps.py

    class CustomHealthChecksAppConfig(AppConfig):
    name = 'custom_health_checks'
    
    def ready(self):
        from .backends import DatabaseHealthCheck
        plugin_dir.register(DatabaseHealthCheck)
  3. Map the health_check.urls in the project's urls.py.

    If you want to have the default health_check view, map it like this:

    urlpatterns = [
        # ...
        path("healthz/", include('health_check.urls'))
    ]

    If you want to have a custom, e.g. a JSON only view, map it like this:

    import views
    urlpatterns = [
        # ...
        path(r'healthz', views.HealthCheckCustomView.as_view(), name='healthz'),
    ]