Prometheus redis exporter autodiscovery config
Problem
Some time ago at my job I had to implement prometheus monitoring for all redis instances. In this case redis was used as cache, one instance for each project and environment, running on kubernetes.
After some time I had ExternalName setup that connected prometheus namespace with all redis instances, and static list of all instances inside prometheus config. It was fine, just lot of manual work to add another one, and prometheus restart/reload to get new config going. Also not everybody in my team was able to add another instance.
I have set up kubernetes prometheus autodiscovery before, at that time it was quite easy- a lot of examples on the internet. But this time, for I couldn’t find anything for exporter that I was using.
After some trial and error (mostly errors) I came up with something at least kinda ok.
Solution
|
|
Of course to get this to work you have to also have RBAC setup, the same as for prometheus kubernetes discovery.
Now you just need to add annotations to redis service:
|
|
I think first one is self-explanatory, second one is redis protocol- redis for non ssl, rediss for tls.
For more inspiration check out my deploy repo - prometheus config in monitoring folder.