oliver006 / redis_exporter

Prometheus Exporter for ValKey & Redis Metrics. Supports ValKey and Redis 2.x, 3.x, 4.x, 5.x, 6.x, and 7.x
https://github.com/oliver006/redis_exporter
MIT License
3.16k stars 875 forks source link

Keep connection to redis alive #773

Closed gupta-mukul closed 1 year ago

gupta-mukul commented 1 year ago

Describe the problem Upon receiving the request from Prometheous, redis exporter is making a connection to redis, scraping data, and closing the connection. Is it possible to keep this connection alive?

What version of redis_exporter are you running? 4.1.1

Running the exporter ./redis_exporter (no parameters)

environment variable set: REDIS_EXPORTER_SCRIPT

oliver006 commented 1 year ago

It's possible but creating the connection for every scrape gives a reliable indicator that connecting to the Redis instance succeeded and that it's up and accepting connections.

Why do you want to keep the connection alive?

gupta-mukul commented 1 year ago

It seems like, creating a new connection every time will result in some overhead, though I do not have any numbers which help determine if that overhead is significant.

Another issue is that on the dashboard, the number of connections counter keeps on increasing which masks any disconnections with redis clients (other than redis exporter).

Is any such configuration already available which could help keep a permanent connection?

oliver006 commented 1 year ago

There is no such configuration right now and I don't plan on adding one.

...which masks any any disconnections with redis clients - can you elaborate on that one? What exactly is the concern and what else have you tried to address this? E.g. there's the list of connected clients - it includes a name so you can identify the redis_exporter - can you address your problem using that metric?