Skip to main content

a pluggable app that runs a full check on the deployment, using a number of plugins to check e.g. database, queue server, celery processes, etc.

Project description

version ci coverage health license

This project checks the health for a number of backends and sees if they are able to connect and do a simple action.



Add this to

url(r'^ht/$', include('health_check.urls'))

Add required apps:

'health_check',  # required


Not that you will need a result backend configured for celery.

Set up monitoring

You can use tools like Pingdom or other uptime robots. The /ht/ endpoint will respond a HTTP 200 if all checks passed and a HTTP 500 if any of the tests failed.

Machine-readable reports

If you want machine-readable status reports you can request the /ht/ endpoint with the Accept HTTP header set to application/json. The backend will return a JSON response of form:

    "CacheBackend": "OK"

Writing a custom health check

Writing a health check:

class MyHealthCheckBackend(BaseHealthCheckBackend):
    def check_status(self):
        # The test code goes here.
        # You can use `self.add_error` or raise a
        # `HealthCheckException`. Similar to Django's form validation.

    def identifier(self):
        return self.__class__.__name__  # Display name on the endpoint.

Register the backend in your app configuration:

from django.apps import AppConfig

from health_check.plugins import plugin_dir

class MyAppConfig(AppConfig):
    name = 'my_app'

    def ready(self):
        from .backends import MyHealthCheckBackend

Customizing output

You can customize JSON rendering by e.g. inheriting from MainView in health_check.views and customizing the render_to_response_json method:

from health_check.views import MainView

class HealthCheckCustomView(MainView)
    def render_to_response_json(self, plugins, status):
        return JsonResponse(
            {str(p.identifier()): "COOL" if status == 200 else "SWEATY" for p in plugins}

import views

urlpatterns = [
    # ...
    url(r'^ht/$', views.HealthCheckCustomView.as_view(), name='health_check_custom')),

Project details

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
django-health-check-2.2.0.tar.gz (10.8 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page