Checks
Django Built-in Services
health_check.Cache
dataclass
Bases: HealthCheck
Check that the cache backend is able to set and get a value.
It can be setup multiple times for different cache aliases if needed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alias
|
str
|
The cache alias to test against. |
'default'
|
key_prefix
|
str
|
Prefix for the node specific cache key. |
'djangohealthcheck_test'
|
timeout
|
timedelta
|
Time until probe keys expire in the cache backend. |
timedelta(seconds=5)
|
Source code in health_check/checks.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
health_check.DNS
dataclass
Bases: HealthCheck
Check DNS resolution by resolving the server's hostname.
Verifies that DNS resolution is working using the system's configured DNS servers, as well as nameserver resolution for the provided hostname.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hostname
|
str
|
The hostname to resolve. |
gethostname()
|
timeout
|
timedelta
|
DNS query timeout. |
timedelta(seconds=5)
|
Source code in health_check/checks.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
health_check.Database
dataclass
Bases: HealthCheck
Check database operation by executing a simple SELECT 1 query.
It can be setup multiple times for different database connections if needed. No actual data is read from or written to the database to minimize the performance impact and work with conservative database user permissions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alias
|
str
|
The alias of the database connection to check. |
'default'
|
Source code in health_check/checks.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |
health_check.Mail
dataclass
Bases: HealthCheck
Check that mail backend is able to open and close connection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backend
|
str
|
The email backend to test against. |
EMAIL_BACKEND
|
timeout
|
timedelta
|
Timeout for connection to mail server in seconds. |
timedelta(seconds=15)
|
Source code in health_check/checks.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | |
health_check.Storage
dataclass
Bases: HealthCheck
Check file storage backends by saving, reading, and deleting a test file.
It can be setup multiple times for different storage backends if needed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alias
|
str
|
The alias of the storage backend to check. |
'default'
|
Source code in health_check/checks.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | |
System Services
To use the psutil-based checks, you will need to install psutil extra:
pip install django-health-check[psutil]
health_check.contrib.psutil.Battery
dataclass
Bases: HealthCheck
Warn about system battery status and power connection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_percent_available
|
float | None
|
Minimum battery percentage available or None to disable the check. |
20.0
|
power_plugged
|
bool
|
Whether to warn if the power is unplugged. |
False
|
Source code in health_check/contrib/psutil.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | |
health_check.contrib.psutil.CPU
dataclass
Bases: HealthCheck
Warn about system CPU utilization.
The utilization represents an interval rather than a point in time measurement. The interval starts with the previous execution of this check and with the current unless an explicit interval is provided. An explicit interval will cause a blocking measurement and increases the execution time of the check by the length of the interval.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_usage_percent
|
float | None
|
Maximum CPU usage in percent or None to disable the check. |
80.0
|
interval
|
timedelta | None
|
The interval to measure CPU usage over or None to use the interval since the last check execution. |
None
|
Source code in health_check/contrib/psutil.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
health_check.contrib.psutil.Memory
dataclass
Bases: HealthCheck
Warn about system memory utilization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_gibibytes_available
|
float | None
|
Minimum available memory in gibibytes or None to disable the check. |
None
|
max_memory_usage_percent
|
float | None
|
Maximum memory usage in percent or None to disable the check. |
90.0
|
Source code in health_check/contrib/psutil.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
health_check.contrib.psutil.Disk
dataclass
Bases: HealthCheck
Warn about disk usage for a given system path.
It can be setup multiple times at different system paths, e.g. one at your application root and one at your media storage root.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path | str
|
Path to check disk usage for. |
getcwd()
|
max_disk_usage_percent
|
float | None
|
Maximum disk usage in percent or None to disable the check. |
90.0
|
Source code in health_check/contrib/psutil.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |
health_check.contrib.psutil.Temperature
dataclass
Bases: HealthCheck
Warn about system temperature.
If no maximum temperature is specified, the sensor's high threshold will be used.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device
|
str | None
|
The device to check temperature for, e.g. 'coretemp' for CPU temperature on many systems. If None, check all available sensors. |
'coretemp'
|
max_temperature_celsius
|
float | None
|
Maximum temperature in degree Celsius or None to disable the check. |
None
|
Source code in health_check/contrib/psutil.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
3rd Party Services
To use the checks, you will need to install and set up their corresponding dependencies.
To enable AWS health checks, install the extra for the contrib checks:
pip install django-health-check[redis,rabbitmq,celery,kafka]
health_check.contrib.celery.Ping
dataclass
Bases: HealthCheck
Check Celery worker availability using the ping control command.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app
|
Celery
|
Celery application instance to use for the health check, defaults to the default Celery app. |
app_or_default()
|
timeout
|
timedelta
|
Timeout duration for the ping command. |
timedelta(seconds=1)
|
limit
|
int | None
|
Maximum number of workers to wait for before returning. If not specified, waits for the full timeout duration. When set, returns immediately after receiving responses from this many workers. |
None
|
Source code in health_check/contrib/celery.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
health_check.contrib.kafka.Kafka
dataclass
Bases: HealthCheck
Check Kafka service by connecting to a Kafka broker and listing topics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bootstrap_servers
|
list[str]
|
List of Kafka bootstrap servers, e.g., ['localhost:9092']. |
required |
timeout
|
timedelta
|
Timeout duration for the connection check as a datetime.timedelta. |
timedelta(seconds=10)
|
Source code in health_check/contrib/kafka.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
health_check.contrib.rabbitmq.RabbitMQ
dataclass
Bases: HealthCheck
Check RabbitMQ service by opening and closing a broker channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
amqp_url
|
str
|
The URL of the RabbitMQ broker to connect to, e.g., 'amqp://guest:guest@localhost:5672//'. |
required |
Source code in health_check/contrib/rabbitmq.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
health_check.contrib.redis.Redis
dataclass
Bases: HealthCheck
Check Redis service by pinging a Redis client.
This check works with any Redis client that implements the ping() method, including standard Redis, Sentinel, and Cluster clients.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client_factory
|
Callable[[], Redis | RedisCluster] | None
|
A callable that returns an instance of a Redis client. |
None
|
client
|
Redis | RedisCluster | None
|
Deprecated, use |
None
|
Examples:
Using a standard Redis client:
>>> from redis.asyncio import Redis as RedisClient
>>> Redis(client_factory=lambda: RedisClient(host='localhost', port=6379))
Using from_url to create a client:
>>> from redis.asyncio import Redis as RedisClient
>>> Redis(client_factory=lambda: RedisClient.from_url('redis://localhost:6379'))
Using a Cluster client:
>>> from redis.asyncio import RedisCluster
>>> Redis(client_factory=lambda: RedisCluster(host='localhost', port=7000))
Using a Sentinel client:
>>> from redis.asyncio import Sentinel
>>> Redis(client_factory=lambda: Sentinel([('localhost', 26379)]).master_for('mymaster'))
Source code in health_check/contrib/redis.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
Cloud Provider Status
Monitor cloud provider service health using their public RSS/Atom status feeds or APIs.
Cloud provider health checks require different extras depending on the provider:
pip install django-health-check[rss,atlassian]
health_check.contrib.rss.AWS
dataclass
Bases: Feed
Check AWS service status via their public RSS status feeds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
region
|
str
|
AWS region code (e.g., 'us-east-1', 'eu-west-1'). |
required |
service
|
str
|
AWS service name (e.g., 'ec2', 's3', 'rds'). |
required |
timeout
|
timedelta
|
Request timeout duration. |
timedelta(seconds=10)
|
max_age
|
timedelta
|
Maximum age for an incident to be considered active. |
timedelta(hours=8)
|
Source code in health_check/contrib/rss.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
health_check.contrib.rss.Azure
dataclass
Bases: Feed
Check Azure platform status via their public RSS status feed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
timedelta
|
Request timeout duration. |
timedelta(seconds=10)
|
max_age
|
timedelta
|
Maximum age for an incident to be considered active. |
timedelta(hours=8)
|
Source code in health_check/contrib/rss.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | |
health_check.contrib.atlassian.Cloudflare
dataclass
Bases: AtlassianStatusPage
Check Cloudflare platform status via Atlassian Status Page API v2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
timedelta
|
Request timeout duration. |
timedelta(seconds=10)
|
component
|
str
|
Name of a specific component to monitor. Monitors all components when empty. |
''
|
Source code in health_check/contrib/atlassian.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
health_check.contrib.atlassian.DigitalOcean
dataclass
Bases: AtlassianStatusPage
Check DigitalOcean platform status via Atlassian Status Page API v2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
timedelta
|
Request timeout duration. |
timedelta(seconds=10)
|
component
|
str
|
Name of a specific component to monitor. Monitors all components when empty. |
''
|
Source code in health_check/contrib/atlassian.py
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | |
health_check.contrib.atlassian.FlyIo
dataclass
Bases: AtlassianStatusPage
Check Fly.io platform status via Atlassian Status Page API v2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
timedelta
|
Request timeout duration. |
timedelta(seconds=10)
|
component
|
str
|
Name of a specific component to monitor. Monitors all components when empty. |
''
|
Source code in health_check/contrib/atlassian.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
health_check.contrib.atlassian.GitHub
dataclass
Bases: AtlassianStatusPage
Check GitHub platform status via Atlassian Status Page API v2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enterprise_region
|
EnterpriseRegion | None
|
GitHub Enterprise status page region (if applicable). |
None
|
timeout
|
timedelta
|
Request timeout duration. |
timedelta(seconds=10)
|
component
|
str
|
Name of a specific component to monitor. Monitors all components when empty. |
''
|
Source code in health_check/contrib/atlassian.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | |
EnterpriseRegion
Bases: StrEnum
GitHub Enterprise status page regions.
Source code in health_check/contrib/atlassian.py
161 162 163 164 165 166 167 168 169 170 171 | |
australia = 'au'
class-attribute
instance-attribute
Australia.
eu = 'eu'
class-attribute
instance-attribute
Europe.
japan = 'jp'
class-attribute
instance-attribute
Japan.
us = 'us'
class-attribute
instance-attribute
United States.
health_check.contrib.rss.GoogleCloud
dataclass
Bases: Feed
Check Google Cloud platform status via their public Atom status feed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
timedelta
|
Request timeout duration. |
timedelta(seconds=10)
|
max_age
|
timedelta
|
Maximum age for an incident to be considered active. |
timedelta(hours=8)
|
Source code in health_check/contrib/rss.py
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | |
health_check.contrib.rss.Heroku
dataclass
Bases: Feed
Check Heroku platform status via their public RSS status feed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
timedelta
|
Request timeout duration. |
timedelta(seconds=10)
|
max_age
|
timedelta
|
Maximum age for an incident to be considered active. |
timedelta(hours=8)
|
Source code in health_check/contrib/rss.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | |
health_check.contrib.rss.Hetzner
dataclass
Bases: Feed
Check Hetzner platform status via their public ATOM status feed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
timedelta
|
Request timeout duration. |
timedelta(seconds=10)
|
max_age
|
timedelta
|
Maximum age for an incident to be considered active. |
timedelta(hours=8)
|
Source code in health_check/contrib/rss.py
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | |
health_check.contrib.atlassian.PlatformSh
dataclass
Bases: AtlassianStatusPage
Check Platform.sh platform status via Atlassian Status Page API v2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
timedelta
|
Request timeout duration. |
timedelta(seconds=10)
|
component
|
str
|
Name of a specific component to monitor. Monitors all components when empty. |
''
|
Source code in health_check/contrib/atlassian.py
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | |
health_check.contrib.atlassian.Render
dataclass
Bases: AtlassianStatusPage
Check Render platform status via Atlassian Status Page API v2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
timedelta
|
Request timeout duration. |
timedelta(seconds=10)
|
component
|
str
|
Name of a specific component to monitor. Monitors all components when empty. |
''
|
Source code in health_check/contrib/atlassian.py
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | |
health_check.contrib.atlassian.Sentry
dataclass
Bases: AtlassianStatusPage
Check Sentry platform status via Atlassian Status Page API v2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
timedelta
|
Request timeout duration. |
timedelta(seconds=10)
|
component
|
str
|
Name of a specific component to monitor. Monitors all components when empty. |
''
|
Source code in health_check/contrib/atlassian.py
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | |
health_check.contrib.atlassian.Vercel
dataclass
Bases: AtlassianStatusPage
Check Vercel platform status via Atlassian Status Page API v2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
timedelta
|
Request timeout duration. |
timedelta(seconds=10)
|
component
|
str
|
Name of a specific component to monitor. Monitors all components when empty. |
''
|
Source code in health_check/contrib/atlassian.py
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | |
Custom Status Page Feeds
These classes can be used to write custom status page proxy checks. Subclasses need to implement the required attributes as documented.
health_check.contrib.rss.Feed
dataclass
Bases: HealthCheck
Base class for cloud provider status feed health checks.
Monitor cloud provider service health via their public RSS or Atom status feeds.
Subclasses must provide:
Attributes:
| Name | Type | Description |
|---|---|---|
feed_url |
str
|
The full URL of the RSS or Atom feed to monitor. |
timeout |
timedelta
|
Maximum duration to wait for the HTTP request before failing. |
max_age |
timedelta
|
Maximum age for an incident entry to be considered active. |
The timeout and max_age values are used to control how long the
health check waits for the feed and how far back in time incidents are
considered relevant. The feed_url is used to fetch the status feed.
Examples:
>>> import dataclasses
>>> import datetime
>>> import typing
>>> from health_check.contrib.rss import Feed
>>> @dataclasses.dataclass
... class MyProviderStatus(Feed):
... """Check MyProvider status via its public RSS feed."""
... timeout: datetime.timedelta = dataclasses.field(
... default=datetime.timedelta(seconds=10),
... repr=False,
... )
... max_age: datetime.timedelta = dataclasses.field(
... default=datetime.timedelta(hours=4),
... repr=False,
... )
... feed_url: typing.ClassVar[str] = "https://status.myprovider.com/feed"
Source code in health_check/contrib/rss.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | |
health_check.contrib.atlassian.AtlassianStatusPage
dataclass
Bases: HealthCheck
Base class for Atlassian status page health checks.
Monitor cloud provider service health via Atlassian Status Page API v2.
Each subclass should define the base_url for the specific status page
and appropriate timeout value.
When component is non-empty, only incidents affecting that named component are
reported. Use separate check instances to monitor multiple components independently.
Examples:
>>> import dataclasses
>>> import datetime
>>> from health_check.contrib.atlassian import AtlassianStatusPage
>>> @dataclasses.dataclass
... class FlyIo(AtlassianStatusPage):
... timeout: datetime.timedelta = datetime.timedelta(seconds=10)
... base_url: str = dataclasses.field(default="https://status.flyio.net", init=False, repr=False)
Source code in health_check/contrib/atlassian.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |