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.04k stars 860 forks source link

Couldn't connect to redis instance #772

Closed KYV365 closed 1 year ago

KYV365 commented 1 year ago

Describe the problem redis three master,three slave 192.168.0.1 7001 master 192.168.0.1 7002 slave 192.168.0.2 7001 master 192.168.0.2 7002 slave 192.168.0.3 7001 master 192.168.0.3 7002 slave ./redis_exporter -redis.addr 192.168.0.1 7001 -redis.password xxx -web.listen-address :9121

report error: INFO[0000] Redis Metrics Exporter v1.40.0 build date: 2022-06-10-00:53:59 sha1: 3a743038c6c5a80d10ce45a3fbd49412262c300b Go: go1.18.3 GOOS: linux GOARCH: amd64 INFO[0000] Providing metrics at :9121/metrics
ERRO[0000] Couldn't connect to redis instance (redis://192.168.0.1 7001) ERRO[0001] Couldn't connect to redis instance (redis://192.168.0.1 7002) ERRO[0002] Couldn't connect to redis instance (redis://192.168.0.2 7001) ERRO[0004] Couldn't connect to redis instance (redis://192.168.0.2 7002) ERRO[0005] Couldn't connect to redis instance (redis://192.169.6.9:7003) ERRO[0006] Couldn't connect to redis instance (redis://192.168.0.3 7001) ERRO[0007] Couldn't connect to redis instance (redis://192.168.0.3 7002)

What version of redis_exporter are you running? Please run redis_exporter --version if you're not sure what version you're running. redis_exporter-v1.40.0 Redis Version: 6.0.9

KYV365 commented 1 year ago

redis_exporter-v1.40.0.linux-amd64.tar prometheus-2.41.0.linux-amd64.tar

imatthew-nq commented 1 year ago

redis_version:5.0.7 redis_exporter-v1.48.0.linux-amd64 I have some issues just like raojun0504 In a redis cluster built on 5 instances and each instance runs master and slave on different ports and the whole cluster has credential authentication.

172.16.1.21 7000 master
172.16.1.21 7002 slave
172.16.1.22 7000 master
172.16.1.22 7001 slave
172.16.1.23 7000 master
172.16.1.23 7001 slave
172.16.1.24 7000 master
172.16.1.24 7001 slave
172.16.1.25 7000 master
172.16.1.25 7001 slave

Create a redis_exporter.conf file and it contains master & slave IP and PORT + PASSWORD

redis_addr: "redis://<PASSWORD>@IP:7000"
redis_alias: "master"

redis_slave_addr: "redis://<PASSWORD>@IP:7001"
redis_slave_alias: "slave"

namespace: "redis"

When running the below command there would be errors appear:

redis_exporter -config-command redis_exporter.conf 
INFO[0000] Redis Metrics Exporter v1.48.0    build date: 2023-03-03-03:23:47    sha1: 30fba62cc31d80ccb8653ac33965e17c15929a24    Go: go1.20.1    GOOS: linux    GOARCH: amd64 
INFO[0000] Providing metrics at :9121/metrics           
ERRO[0001] Couldn't connect to redis instance (redis://localhost:6379) 
ERRO[0002] Couldn't connect to redis instance (redis://localhost:6379) 

There is no redis service running on redis://localhost:6379 and when I pass the config file to redis_exporter it does not work probably. Any suggestion?

KYV365 commented 1 year ago

redis_version:5.0.7 redis_exporter-v1.48.0.linux-amd64 I have some issues just like raojun0504 In a redis cluster built on 5 instances and each instance runs master and slave on different ports and the whole cluster has credential authentication.

172.16.1.21 7000 master
172.16.1.21 7002 slave
172.16.1.22 7000 master
172.16.1.22 7001 slave
172.16.1.23 7000 master
172.16.1.23 7001 slave
172.16.1.24 7000 master
172.16.1.24 7001 slave
172.16.1.25 7000 master
172.16.1.25 7001 slave

Create a redis_exporter.conf file and it contains master & slave IP and PORT + PASSWORD

redis_addr: "redis://<PASSWORD>@IP:7000"
redis_alias: "master"

redis_slave_addr: "redis://<PASSWORD>@IP:7001"
redis_slave_alias: "slave"

namespace: "redis"

When running the below command there would be errors appear:

redis_exporter -config-command redis_exporter.conf 
INFO[0000] Redis Metrics Exporter v1.48.0    build date: 2023-03-03-03:23:47    sha1: 30fba62cc31d80ccb8653ac33965e17c15929a24    Go: go1.20.1    GOOS: linux    GOARCH: amd64 
INFO[0000] Providing metrics at :9121/metrics           
ERRO[0001] Couldn't connect to redis instance (redis://localhost:6379) 
ERRO[0002] Couldn't connect to redis instance (redis://localhost:6379) 

There is no redis service running on redis://localhost:6379 and when I pass the config file to redis_exporter it does not work probably. Any suggestion?

scrape_configs:

The job name is added as a label job=<job_name> to any timeseries scraped from this config.

KYV365 commented 1 year ago

redis_version:5.0.7 redis_exporter-v1.48.0.linux-amd64 I have some issues just like raojun0504 In a redis cluster built on 5 instances and each instance runs master and slave on different ports and the whole cluster has credential authentication.

172.16.1.21 7000 master
172.16.1.21 7002 slave
172.16.1.22 7000 master
172.16.1.22 7001 slave
172.16.1.23 7000 master
172.16.1.23 7001 slave
172.16.1.24 7000 master
172.16.1.24 7001 slave
172.16.1.25 7000 master
172.16.1.25 7001 slave

Create a redis_exporter.conf file and it contains master & slave IP and PORT + PASSWORD

redis_addr: "redis://<PASSWORD>@IP:7000"
redis_alias: "master"

redis_slave_addr: "redis://<PASSWORD>@IP:7001"
redis_slave_alias: "slave"

namespace: "redis"

When running the below command there would be errors appear:

redis_exporter -config-command redis_exporter.conf 
INFO[0000] Redis Metrics Exporter v1.48.0    build date: 2023-03-03-03:23:47    sha1: 30fba62cc31d80ccb8653ac33965e17c15929a24    Go: go1.20.1    GOOS: linux    GOARCH: amd64 
INFO[0000] Providing metrics at :9121/metrics           
ERRO[0001] Couldn't connect to redis instance (redis://localhost:6379) 
ERRO[0002] Couldn't connect to redis instance (redis://localhost:6379) 

There is no redis service running on redis://localhost:6379 and when I pass the config file to redis_exporter it does not work probably. Any suggestion?

scrape_configs:

The job name is added as a label job=<job_name> to any timeseries scraped from this config.

redis_version:5.0.7 redis_exporter-v1.48.0.linux-amd64 I have some issues just like raojun0504 In a redis cluster built on 5 instances and each instance runs master and slave on different ports and the whole cluster has credential authentication.

172.16.1.21 7000 master
172.16.1.21 7002 slave
172.16.1.22 7000 master
172.16.1.22 7001 slave
172.16.1.23 7000 master
172.16.1.23 7001 slave
172.16.1.24 7000 master
172.16.1.24 7001 slave
172.16.1.25 7000 master
172.16.1.25 7001 slave

Create a redis_exporter.conf file and it contains master & slave IP and PORT + PASSWORD

redis_addr: "redis://<PASSWORD>@IP:7000"
redis_alias: "master"

redis_slave_addr: "redis://<PASSWORD>@IP:7001"
redis_slave_alias: "slave"

namespace: "redis"

When running the below command there would be errors appear:

redis_exporter -config-command redis_exporter.conf 
INFO[0000] Redis Metrics Exporter v1.48.0    build date: 2023-03-03-03:23:47    sha1: 30fba62cc31d80ccb8653ac33965e17c15929a24    Go: go1.20.1    GOOS: linux    GOARCH: amd64 
INFO[0000] Providing metrics at :9121/metrics           
ERRO[0001] Couldn't connect to redis instance (redis://localhost:6379) 
ERRO[0002] Couldn't connect to redis instance (redis://localhost:6379) 

There is no redis service running on redis://localhost:6379 and when I pass the config file to redis_exporter it does not work probably. Any suggestion?

redis_version:5.0.7 redis_exporter-v1.48.0.linux-amd64 I have some issues just like raojun0504 In a redis cluster built on 5 instances and each instance runs master and slave on different ports and the whole cluster has credential authentication.

172.16.1.21 7000 master
172.16.1.21 7002 slave
172.16.1.22 7000 master
172.16.1.22 7001 slave
172.16.1.23 7000 master
172.16.1.23 7001 slave
172.16.1.24 7000 master
172.16.1.24 7001 slave
172.16.1.25 7000 master
172.16.1.25 7001 slave

Create a redis_exporter.conf file and it contains master & slave IP and PORT + PASSWORD

redis_addr: "redis://<PASSWORD>@IP:7000"
redis_alias: "master"

redis_slave_addr: "redis://<PASSWORD>@IP:7001"
redis_slave_alias: "slave"

namespace: "redis"

When running the below command there would be errors appear:

redis_exporter -config-command redis_exporter.conf 
INFO[0000] Redis Metrics Exporter v1.48.0    build date: 2023-03-03-03:23:47    sha1: 30fba62cc31d80ccb8653ac33965e17c15929a24    Go: go1.20.1    GOOS: linux    GOARCH: amd64 
INFO[0000] Providing metrics at :9121/metrics           
ERRO[0001] Couldn't connect to redis instance (redis://localhost:6379) 
ERRO[0002] Couldn't connect to redis instance (redis://localhost:6379) 

There is no redis service running on redis://localhost:6379 and when I pass the config file to redis_exporter it does not work probably. Any suggestion?

scrape_configs:

The job name is added as a label job=<job_name> to any timeseries scraped from this config.

stevleibelt commented 1 year ago

I had the same issue and as far as I get it right, this error messages comes from the redis exporter itself.

I've adapted my docker compose file with the following line.

    command: ["--redis.addr=<string: one_of_my_host_or_ip>:<int: the_port>"]  # This line prevents the logging entry `time="2023-03-17T10:09:20Z" level=error msg="Couldn't connect to redis instance (redis://localhost:6379)"` ref: https://github.com/oliver006/redis_exporter#prometheus-configuration-to-scrape-multiple-redis-hosts

It is a bit odd, that you have to choose one redis server that should never go down to prevent this error log message. If there is a better solution, let me know.

Cheers, Stev

Edit

@raojun0504 feel free to close this issue if my answer solves your problem (neither you like it or not ;-))

oliver006 commented 1 year ago

It's in the README: https://github.com/oliver006/redis_exporter#prometheus-configuration-to-scrape-multiple-redis-hosts

Run the exporter with the command line flag --redis.addr= so it won't try to access the local instance every time the /metrics endpoint is scraped