Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scrape redis instances with passwords not working #323

Closed
siitao opened this issue Oct 22, 2019 · 10 comments
Closed

Scrape redis instances with passwords not working #323

siitao opened this issue Oct 22, 2019 · 10 comments
Assignees
Labels

Comments

@siitao
Copy link

siitao commented Oct 22, 2019

I use file_sd_configs to monitor multiple redis instances But the connection authentication fails with redis://h:password@ip:port. Prompt for the following error ,The password is correct

redis_exporter_last_scrape_error{err="NOAUTH Authentication required."} 1

redis version

Redis server v=3.2.5 sha=00000000:0 malloc=jemalloc-4.0.3 bits=64 build=851d3fa91d926a59

Redis_exporter startup method

./redis_exporter -redis.addr=

details

[root@aa-test-1-11 ]# curl http://172.16.1.10:9121/scrape?target=redis://h:[email protected]:6379
# HELP redis_exporter_build_info redis exporter build_info
# TYPE redis_exporter_build_info gauge
redis_exporter_build_info{build_date="<<< filled in by build >>>",commit_sha="<<< filled in by build >>>",golang_version="go1.13.1",version="<<< filled in by build >>>"} 1
# HELP redis_exporter_last_scrape_duration_seconds exporter_last_scrape_duration_seconds metric
# TYPE redis_exporter_last_scrape_duration_seconds gauge
redis_exporter_last_scrape_duration_seconds 0.001855103
# HELP redis_exporter_last_scrape_error The last scrape error status.
# TYPE redis_exporter_last_scrape_error gauge
redis_exporter_last_scrape_error{err="NOAUTH Authentication required."} 1
# HELP redis_exporter_scrape_duration_seconds Duration of scrape by the exporter
# TYPE redis_exporter_scrape_duration_seconds summary
redis_exporter_scrape_duration_seconds{quantile="0.5"} NaN
redis_exporter_scrape_duration_seconds{quantile="0.9"} NaN
redis_exporter_scrape_duration_seconds{quantile="0.99"} NaN
redis_exporter_scrape_duration_seconds_sum 0
redis_exporter_scrape_duration_seconds_count 0
# HELP redis_exporter_scrapes_total Current total redis scrapes.
# TYPE redis_exporter_scrapes_total counter
redis_exporter_scrapes_total 1
# HELP redis_target_scrape_request_errors_total Errors in requests to the exporter
# TYPE redis_target_scrape_request_errors_total counter
redis_target_scrape_request_errors_total 0
# HELP redis_up Information about the Redis instance
# TYPE redis_up gauge
redis_up 0
@oliver006
Copy link
Owner

Using the password as part of the redis URI is not supported, you can configure the password to use via the command line by using --redis.password.

If you have different passwords for each redis instance then this is not currently possible to use the same redis_exporter for all of them, see #278 for a discussion of the issue

@fsckzy
Copy link

fsckzy commented Dec 13, 2019

I want to ask why I am prompted for authentication failure? The password is fine

nohup ./redis_exporter -redis.addr 172.18.11.139:7000 172.18.11.139:7001 172.18.11.140:7002 172.18.11.140:7003 172.18.11.141:7004 172.18.11.141:7005 -redis.password xxxxx &

tips:

level=error msg="Redis INFO err: NOAUTH Authentication required."

why?

@oliver006
Copy link
Owner

@fsckzy You can only provide one redis instance address as the parameter to the redis_exporter.

What happens if you run
./redis_exporter -redis.addr=172.18.11.139:7000 -redis.password=xxxxx
and try to retrieve the metrics ?

@fsckzy
Copy link

fsckzy commented Dec 16, 2019

@fsckzy You can only provide one redis instance address as the parameter to the redis_exporter.

What happens if you run
./redis_exporter -redis.addr=172.18.11.139:7000 -redis.password=xxxxx
and try to retrieve the metrics ?

One instance will do. But I want to monitor the cluster. If the instance launches redis-exporter, many commands will not work, such as cluster slot failure. What is the solution?

@oliver006
Copy link
Owner

oliver006 commented Dec 16, 2019

If you want to monitor the cluster then you'll need to scrape each of the instances.
You can do this by either running a redis_exporter per redis instance (sidecar in k8s or on the host if running on regular VMs) or you have a look at the docs here how to configure scraping multiple instances: https://github.com/oliver006/redis_exporter#prometheus-configuration-to-scrape-multiple-redis-hosts

@fsckzy
Copy link

fsckzy commented Dec 17, 2019

If you want to monitor the cluster then you'll need to scrape each of the instances.
You can do this by either running a redis_exporter per redis instance (sidecar in k8s or on the host if running on regular VMs) or you have a look at the docs here how to configure scraping multiple instances: https://github.com/oliver006/redis_exporter#prometheus-configuration-to-scrape-multiple-redis-hosts

Thank you for your patience. I successfully monitored the Redis cluster. I do n’t know how to upload pictures, so I wo n’t pass them on.
But strangely, the redis_exporter log shows the following prompt:

time="2019-12-17T09:10:49+08:00" level=error msg="Couldn't connect to redis instance"

Prometheus can collect data, just curious。

@oliver006
Copy link
Owner

Are you using the multi-instance configuration? If yes, did you set the --redis.addr= command line parameter?

@fsckzy
Copy link

fsckzy commented Dec 17, 2019

Are you using the multi-instance configuration? If yes, did you set the --redis.addr= command line parameter?

I do it like this:

nohup ./redis_exporter -redis.password xxxxx  &
  - job_name: 'redis_exporter_targets'
    static_configs:
      - targets:
        - redis://172.18.11.139:7000
        - redis://172.18.11.139:7001
        - redis://172.18.11.140:7002
        - redis://172.18.11.140:7003
        - redis://172.18.11.141:7004
        - redis://172.18.11.141:7005
    metrics_path: /scrape
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: 172.18.11.139:9121

Can collect data。

@oliver006
Copy link
Owner

Cool. Just pass --redis.addr= to the redis_exporter and you won't see the error any longer.

@fsckzy
Copy link

fsckzy commented Dec 17, 2019

thank you very much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants