mdawar / rq-exporter

Prometheus metrics exporter for Python RQ (Redis Queue).
MIT License
67 stars 29 forks source link

Add SSL support for redis URLs beginning with rediss #22

Closed gataky closed 2 years ago

gataky commented 2 years ago

For some reason Redis.from_url doesn't work with redis urls beginning with rediss://. This is a problem if you do have secure redis instances for example on Heroku.

This change will allow for secure redis urls beginning with rediss:// by instantiating a redis connection with the parsed url along with ssl=True.

mdawar commented 2 years ago

Hi,

Thank you for your contribution.

Are you getting any errors when using a URL starting with rediss://?

I haven't tried it, but it seems that it's already supported, please take a look at ConnectionPool.from_url.

Here are the supported examples:

redis://[[username]:[password]]@localhost:6379/0
rediss://[[username]:[password]]@localhost:6379/0
unix://[[username]:[password]]@/path/to/socket.sock?db=0

Also please take a look at this answer for an old issue documenting the various ways to use Redis with TLS including the from_url method.

gataky commented 2 years ago

Hi thanks for the response and the work you've done here.

The issue I'm having is trying to run this on heroku and having a URL set for me without the query args set on that url giving me something like rediss://:***@ec2.compute-1.amazonaws.com:***. Without ssl=true py-redis doesn't treat this as a ssl connection and fails to connect.

Now that I'm trying this out, it's clearer that this isn't an issue with rq-exporter and can probably be closed.

I guess what I can do for now is append ?ssl=true to the redis url that heroku sets for me.