Problem
health_check.contrib.redis.Redis can be configured multiple times with different client_factory values, which is useful when a Django app has separate Redis clients for cache, channels, Celery, Constance, etc.
However, the Redis check does not expose an alias or any other repr-enabled identifying field. The OpenMetrics renderer builds metric labels from result.check.labels, and HealthCheck.labels only includes dataclass fields with repr=True. Because Redis.client and Redis.client_factory are repr=False, multiple Redis checks all emit the same labels:
django_health_check_status{check="Redis"} 1
django_health_check_status{check="Redis"} 1
django_health_check_status{check="Redis"} 1
That makes the individual Redis checks indistinguishable in Prometheus and can create duplicate samples for the same metric/label set in a single scrape.
Example
checks = [
(
"health_check.contrib.redis.Redis",
{"client_factory": lambda: RedisClient.from_url(settings.CHANNELS_REDIS_URL)},
),
(
"health_check.contrib.redis.Redis",
{"client_factory": lambda: RedisClient.from_url(settings.CONSTANCE_REDIS_URL)},
),
(
"health_check.contrib.redis.Redis",
{"client_factory": lambda: RedisClient.from_url(settings.CELERY_BROKER_URL)},
),
]
Expected behavior
The Redis check should support a stable human-readable label, matching the existing pattern used by checks such as Cache, Database, and Storage, which expose an alias field.
For example:
(
"health_check.contrib.redis.Redis",
{
"alias": "channels",
"client_factory": lambda: RedisClient.from_url(settings.CHANNELS_REDIS_URL),
},
)
Would emit distinct OpenMetrics labels:
django_health_check_status{check="Redis",alias="channels"} 1
Proposed fix
Add an optional alias: str | None = None field to Redis. This should be backwards-compatible because existing callers can omit it, while apps with multiple Redis checks can opt into distinct labels.
Problem
health_check.contrib.redis.Rediscan be configured multiple times with differentclient_factoryvalues, which is useful when a Django app has separate Redis clients for cache, channels, Celery, Constance, etc.However, the Redis check does not expose an
aliasor any other repr-enabled identifying field. The OpenMetrics renderer builds metric labels fromresult.check.labels, andHealthCheck.labelsonly includes dataclass fields withrepr=True. BecauseRedis.clientandRedis.client_factoryarerepr=False, multiple Redis checks all emit the same labels:That makes the individual Redis checks indistinguishable in Prometheus and can create duplicate samples for the same metric/label set in a single scrape.
Example
Expected behavior
The Redis check should support a stable human-readable label, matching the existing pattern used by checks such as
Cache,Database, andStorage, which expose analiasfield.For example:
( "health_check.contrib.redis.Redis", { "alias": "channels", "client_factory": lambda: RedisClient.from_url(settings.CHANNELS_REDIS_URL), }, )Would emit distinct OpenMetrics labels:
Proposed fix
Add an optional
alias: str | None = Nonefield toRedis. This should be backwards-compatible because existing callers can omit it, while apps with multiple Redis checks can opt into distinct labels.