Skip to main content

Simple Django app/framework to publish health checks

Project description

Simple Django app/framework to publish health check for monitoring purposes


  • Custom checks via Python functions

  • Remote healthchecks

  • Heartbeat monitoring



pip install django_healthchecks


Add the following to your

url(r'^healthchecks/', include('django_healthchecks.urls')),

Add a setting with the available healthchecks:

    'postgresql': 'django_healthchecks.contrib.check_database',
    'cache_default': 'django_healthchecks.contrib.check_cache_default',
    'solr': 'your_project.lib.healthchecks.check_solr',

You can also include healthchecks over http. This is useful when you want to monitor if depending services are up:

    'my_microservice': '',

By default, http health checks will time out after 500ms. You can override this as follows:


By default the status code is always 200, you can change this to something else by using the HEALTH_CHECKS_ERROR_CODE setting:


You can also add some simple protection to your healthchecks via basic auth. This can be specified per check or a wildcard can be used *.

    '*': [('admin', 'pass')],
    'solr': [],

Using heartbeats

Heartbeats give a periodic update, to see whether an service was recently active. When the service doesn’t report back within timeout, a healthcheck can be triggered. To use heartbeats, add the application to the INSTALLED_APPS:


Include one of these checks:

    'heartbeats': 'django_healthchecks.contrib.check_heartbeats'
    'expired_heartbeats': 'django_healthchecks.contrib.check_expired_heartbeats',

Optionally, define an initial timeout:


Let your code track the beats:

from datetime import timedelta
from django_healthchecks.heartbeats import update_heartbeat

update_heartbeat("", default_timeout=timedelta(days=2))

Or use the decorator:

from django_healthchecks.heartbeats import update_heartbeat_on_success

@update_heartbeat_on_success("", default_timeout=...)
def long_running_task():

Each time update_heartbeat() is called, the heartbeat is reset. When a heartbeat didn’t receive an update before it’s timeout, the service name be mentioned in the check_expired_heartbeats check.

Updating timeouts

The default_timeout parameter is only assigned upon creation. Any updates happen through the Django admin. To update the timeout automatically on code deployment, use the timeout parameter instead. This will replace the stored timeout value each time the update_heartbeat() function is called, erasing any changes made in the Django admin.

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

django-healthchecks-1.5.0.tar.gz (10.7 kB view hashes)

Uploaded Source

Built Distribution

django_healthchecks-1.5.0-py2.py3-none-any.whl (12.1 kB view hashes)

Uploaded Python 2 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