Published on

How to setup a Redis Exporter for Prometheus


In this tutorial we will visualize our Redis Cluster's Metrics with Grafana. In order to do that we will setup a redis exporter which will authenticate with redis and then configure prometheus to scrape the endpoint of the redis exporter's http endpoint to write the time series data to prometheus.

Install Golang

We need to build a binary from the redis exporter project, and we need a Golang environment. If you don't have golang installed already:

$ cd /tmp/
$ wget
$ tar -xf go1.14.2.linux-amd64.tar.gz -C /usr/local
$ mkdir -p $HOME/go/{bin,src,pkg}
$ export GOPATH=/go
$ export PATH=${PATH}:${GOPATH}/bin:/usr/local/go/bin

You should now be able to get a response:

$ go version
go version go1.14.2 linux/amd64

Redis Exporter

Get the source code and build the binary:

$ git clone
$ cd redis_exporter
$ go build .

Now the binary should be built, and you should be able to get a response when running the following:

$ ./redis_exporter --help

Copy the binary the the following path:

$ cp redis_exporter /usr/bin/

Then create the systemd unit file, in /etc/systemd/system/redis_exporter.service:

Description=Redis Exporter

ExecStart=/usr/bin/redis_exporter \
    -web.listen-address ":9121" \
    -redis.addr "redis://ip.of.redis.server:6379" \
    -redis.password "your-strong-redis-password"


Reload systemd:

$ systemctl daemon-relaod

Then start the redis exporter:

$ systemctl restart redis_exporter

Now you should be able to get redis metrics when you hit the redis exporter:

$ curl
# TYPE redis_commands_duration_seconds_total counter
redis_commands_duration_seconds_total{cmd="auth"} 0.000308
redis_commands_duration_seconds_total{cmd="client"} 0.000251
redis_commands_duration_seconds_total{cmd="config"} 0.010594
redis_commands_duration_seconds_total{cmd="evalsha"} 229.214873
redis_commands_duration_seconds_total{cmd="get"} 0.002343
redis_commands_duration_seconds_total{cmd="info"} 0.013722
redis_commands_duration_seconds_total{cmd="latency"} 0.000557
redis_commands_duration_seconds_total{cmd="lrange"} 11.102069
redis_commands_duration_seconds_total{cmd="ltrim"} 3.731263
redis_commands_duration_seconds_total{cmd="ping"} 2e-05
redis_commands_duration_seconds_total{cmd="rpush"} 3.460981
redis_commands_duration_seconds_total{cmd="script"} 0.008393
redis_commands_duration_seconds_total{cmd="set"} 0.001329
redis_commands_duration_seconds_total{cmd="slowlog"} 0.001308

Configure Prometheus

If you don't have prometheus setup, you can view this blogpost to get it setup.

Then configure your prometheus.yml and add the target to scrape the redis exporter endpoint to write the time series data into prometheus:

  - job_name: redis_exporter
    - targets: ['ip.of.redis.exporter:9121']

Then restart prometheus, if you have docker redeploy your stack or prometheus container. For prometheus as a service you can use systemctl restart prometheus, depending on your operating system distribution.


Head over to Grafana, if you don't have Grafana, you can view this post to install Grafana.

Then import the dashboard 763 and after some time, you should see a dashboard more or less like this:

Thank You

Thanks for reading, feel free to check out my website, and subscrube to my newsletter or follow me at @ruanbekker on Twitter.

Buy Me A Coffee