In backends.py there are custom health checks for backend, like database health check, that checks whether the connection to the database is OK.
-
Install the requirements
INSTALLED_APPS = [ 'health_check', # requirement "custom_health_checks", # this app ]
-
Register the custom health check to the
health_checkfrom apps.pyclass CustomHealthChecksAppConfig(AppConfig): name = 'custom_health_checks' def ready(self): from .backends import DatabaseHealthCheck plugin_dir.register(DatabaseHealthCheck)
-
Map the
health_check.urlsin the project'surls.py.If you want to have the default
health_checkview, 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'), ]