Simple Re Usable tool for Django Healthchecks
Install healthy_django:
pip install healthy_django
Add it to your INSTALLED_APPS:
INSTALLED_APPS = (
...
'healthy_django',
...
)
Add healthy_django's URL patterns:
urlpatterns = [
...
path("health/", include("healthy_django.urls", namespace="healthy_django")),
...
]
Add list of healthcheck plugins the currently supported plugins along with their spec and settings config.
Add the configs to your settings file as needed
Checks if a Database defined in Django is up and running
Config:
from healthy_django.healthcheck.django_database import DjangoDatabaseHealthCheck
...
DjangoDatabaseHealthCheck(
"Database",
slug="database",
connection_name="insert_connection_name_here"
),
...
Checks if a Cache defined in Django is up and running
Config:
from healthy_django.healthcheck.django_cache import DjangoCacheHealthCheck
...
DjangoCacheHealthCheck("Cache", slug="cache", connection_name="insert_connection_name_here"),
...
Checks if a Celery queue backlog is within given limits
Config:
from healthy_django.healthcheck.celery_queue_length import (
DjangoCeleryQueueLengthHealthCheck,
)
...
DjangoCeleryQueueLengthHealthCheck(
"CeleryQueue",
slug="celery",
broker="insert_celery_broker_url_here",
queue_name="insert_celery_queue_name_to_be_monitored",
info_length=env.int("CELERY_HEALTH_INFO_LENGTH", default=25), # Expecting integer data field here
warning_length=env.int("CELERY_HEALTH_WARN_LENGTH", default=50), # Expecting integer data field here
alert_length=env.int("CELERY_HEALTH_ALERT_LENGTH", default=100), # Expecting integer data field here
),
...
Checks if an AWS SQS queue backlog is within given limits
Access the overall data using a GET request to:
{{http_mode}}://{{domain_name}}/health/
Access the individual data using a GET request to:
{{http_mode}}://{{domain_name}}/health/{{slug}}
Made with Love by SecurityAdvisor