django-prometheus
django-prometheus copied to clipboard
Redis Cache Not Exposing Metrics
I cannot get django-prometheus to expose any metrics around the cache.
I have it configured like so:
CACHES = {
'default': {
'BACKEND': 'django_prometheus.cache.backends.redis.RedisCache',
'LOCATION': [
'redis://{}:{}/1'.format(REDIS['host'], REDIS['port']),
],
'OPTIONS': {
'CLIENT_CLASS': 'django_redis.client.DefaultClient',
'CONNECTION_POOL_KWARGS': {
'max_connections': 100,
},
'SOCKET_CONNECT_TIMEOUT': 5,
'SOCKET_TIMEOUT': 10,
},
},
}
However, whenever I look at /metrics
, I don't see any metrics with the word cache
in it, even though the cache appears to be working just fine.
All other metrics for http views and the database appears to be working just fine.
Can you confirm you're using django-prometheus>=1.0.15?
Can you confirm that the cache is being used? If nothing is using the cache the metrics may not be created.
@TheOldMop any ideas?
Yes, I can confirm that.
$ docker exec -ti c073 pip freeze | grep django
django-celery-results==1.0.1
django-netfields==0.9.0
django-prometheus==1.0.15
django-redis==4.9.0
django-redis-cache==1.7.1
django-storages==1.7.1
pytest-django==3.4.3
Our apps are using the cache extensively, but just to be sure:
$ docker exec -ti c073 python manage.py shell
Python 3.6.5 (default, May 5 2018, 03:05:30)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from django.core.cache import cache
>>> cache.set('zomg', 'heeeeey')
True
>>> cache.get('zomg')
'heeeeey'
Still no cache metrics after.
@korfuri I can check it in this weekends
Maybe you have problem with multiple processes collecting? https://github.com/korfuri/django-prometheus/blob/master/documentation/exports.md. When i run test app with your config and your version in single process setup everything work fine.