Skip to main content

Django-heartbeat is a simple reusable app that checks and lists various information about your project and its dependencies

Requirements

  • Python >=3.10 (tested with Python 3.10, 3.11, 3.12)
  • Django >=5.2 <=5.3

Installation

Install using pip:

pip install django-heartbeat

Next, add 'heartbeat' to your settings.py INSTALLED_APPS:

INSTALLED_APPS = (
  ...
  'heartbeat',
)

Configure urls.py

if 'heartbeat' in settings.INSTALLED_APPS:
    from heartbeat.urls import urlpatterns as heartbeat_urls

    urlpatterns += [
        url(r'^heartbeat/', include(heartbeat_urls))
    ]

Usage

  • /heartbeat/

    After this point you can access the /heartbeat/ endpoint and receive a 200 OK.

  • /heartbeat/1337/

    If you want a more detailed view of some custom checkers you MUST configure a custom profile for heartbeat in your settings.py. The profile should be a dictionary containing at least the basic auth credentials or the key disable set to True to disable basic authentication.

e.g.:

HEARTBEAT = {
  'package_name': 'foo_project',
  'checkers': [
      'heartbeat.checkers.build',
      'heartbeat.checkers.distribution_list',
      'heartbeat.checkers.debug_mode',
  ],
  'auth': {
      'username': 'foo',
      'password': 'bar',
  },
}

If no checkers are defined, heartbeat will default to the following:

  • heartbeat.checkers.distribution_list
  • heartbeat.checkers.debug_mode
  • heartbeat.checkers.python

Available checkers

Please make sure you have the latest version of django-heartbeat since checker names changed in versions 1.0.8 and 2.0.0. If for some reason you cannot install the latest version, read the release notes for the version you have and the versions mentioned above.

heartbeat.checkers.build

  • lists information about installed package
  • Please be aware that in order for this checker to work you have to add the 'package_name': 'foo_package' key, value pair in the HEARTBEAT settings

heartbeat.checkers.databases

  • displays information about the connection with your configured databases

heartbeat.checkers.debug_mode

  • displays whether the DEBUG mode is set to True or False

heartbeat.checkers.distribution_list

  • lists all installed dependencies

heartbeat.checkers.host

  • displays various information about your system (e.g. hostname, number of CPUs, uptime, used/free memory, etc.)

heartbeat.checkers.memcached_status

  • displays stats about your Memcached.
  • Before enabling this checker please make sure that you have installed the appropriate Memcached binding (the two most common are python-memcached and pylibmc)

heartbeat.checkers.python

  • lists the current python version

heartbeat.checkers.redis_status

  • checks your connection with the Redis server
  • Make sure that you have CACHEOPS_REDIS configured properly in your settings.py

Implementing your own checker

  • my_checker.py:
    def check(request):
      """
      :param request: HttpRequest object
      :return: dict
      """
    
      # Checker logic goes here
    
      return {'ping': 'pong'}
    

Note: The function name of your checker MUST be 'check' and has to return a JSON-serializable object

  • add it to the settings.HEARTBEAT config
    HEARTBEAT = {
        'checkers': [
            'heartbeat.checkers.distribution_list',
            'my_project.my_checker'
            ...
    
        ],
        ...
    }
    

Simple, huh?

If you would like to contribute to this library with a new checker (or any other functionality), feel free to make a pull request.

Contributors

  • Andrei Prădan
  • Dan Claudiu Pop

Metadata

Release files for django-heartbeat 2.2.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-heartbeat 2.2.5
File Size Uploaded Provenance Actions
django_heartbeat-2.2.5.tar.gz 8.2 kB Without provenance Details for django_heartbeat-2.2.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-heartbeat 2.2.5
File Interpreter ABI Platform Actions
django_heartbeat-2.2.5-py3-none-any.whl Python 3 none any Details for django_heartbeat-2.2.5-py3-none-any.whl

Total release size: 19.7 kB

Release files / django_heartbeat-2.2.5.tar.gz

Download URL django_heartbeat-2.2.5.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
62be6d166c75a0fba9c2c0d057603cf6727b2fdfec58fd7d06ac2e8640b370fc
BLAKE2b-256 checksum
How to use checksums
400e76c1879baf5e0056099dce27cf707aa42a03dbfcba9a11f7b2530f5a6795
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.21

Release files / django_heartbeat-2.2.5-py3-none-any.whl

Download URL django_heartbeat-2.2.5-py3-none-any.whl
Size 11.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bf158d3c44fd70f6480b08b36c8cb9b15ecdb4d22b1bb9c18f27ae5ebcc16e7c
BLAKE2b-256 checksum
How to use checksums
229a7bda8afe63bc5aaa8910752705f4cc0c11742eb68cef829060eb1437bbd9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.21

Security for django-heartbeat 2.2.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page