Monitor Redis Server with Prometheus and Grafana in 5 minutes

Posted on 265 views

This guide will focus on monitoring of Redis application on a Linux server. Redis is an open source in-memory data structure store, used as a database, cache and message broker. Redis provides a distributed, in-memory key-value database with optional durability.

Redis supports different kinds of abstract data structures, such as strings, sets, maps, lists, sorted sets, spatial indexes, and bitmaps.

So far we have covered the following monitoring with Prometheus:

What’s exported by Redis exporter?

Most items from the INFO command are exported, see for details. In addition, for every database there are metrics for total keys, expiring keys and the average TTL for keys in the database.

You can also export values of keys if they’re in numeric format by using the -check-keys flag. The exporter will also export the size (or, depending on the data type, the length) of the key. This can be used to export the number of elements in (sorted) sets, hashes, lists, etc.

Setup Pre-requisite

  1. Installed Prometheus Server – Install Prometheus Server on CentOS 7 and Ubuntu
  2. Installed Grafana Data Visualization & Monitoring – Install Prometheus Server on CentOS 7 and Ubuntu

Step 1: Download and Install Redis Prometheus exporter

This Prometheus exporter for Redis metrics supports Redis:

curl -s | grep browser_download_url | grep linux-amd64 | cut -d '"' -f 4 | wget -qi -

Extract the downloaded archive file

tar xvf redis_exporter-*.linux-amd64.tar.gz
sudo mv redis_exporter-*.linux-amd64/redis_exporter /usr/local/bin/
rm -rf redis_exporter-*.linux-amd64*

redis_exporter should be executable from your current SHELL

$ redis_exporter  --version
INFO[0000] Redis Metrics Exporter v1.27.0    build date: 2021-08-30-23:37:23    sha1: ef05f8642cd71d632ca14d728c9c7534835d3674    Go: go1.17    GOOS: linux    GOARCH: amd64

To get a list of all options supported, pass --help option

# redis_exporter  --help
Usage of redis_exporter:
  -check-keys string
    	Comma separated list of key-patterns to export value and length/size, searched for with SCAN
  -check-single-keys string
    	Comma separated list of single keys to export value and length/size
    	Output verbose debug information
  -log-format string
    	Log format, valid options are txt and json (default "txt")
  -namespace string
    	Namespace for metrics (default "redis")
    	Whether to export go runtime metrics also
  -redis.addr string
    	Address of one or more redis nodes, separated by separator
  -redis.alias string
    	Redis instance alias for one or more redis nodes, separated by separator
  -redis.file string
    	Path to file containing one or more redis nodes, separated by newline. NOTE: mutually exclusive with redis.addr
  -redis.password string
    	Password for one or more redis nodes, separated by separator
  -script string
    	Path to Lua Redis script for collecting extra metrics
  -separator string
    	separator used to split redis.addr, redis.password and redis.alias into several elements. (default ",")
    	Use Cloud Foundry service bindings
    	Show version information and exit
  -web.listen-address string
    	Address to listen on for web interface and telemetry. (default ":9121")
  -web.telemetry-path string
    	Path under which to expose metrics. (default "/metrics")

Step 2: Create Prometheus redis exporter systemd service / Init script

The user prometheus will be used to run the service. Add Promethes system user if it doesn’t exist

sudo groupadd --system prometheus
sudo useradd -s /sbin/nologin --system -g prometheus prometheus

Then proceed to create a systemd service unit file.

sudo vim /etc/systemd/system/redis_exporter.service

Add below content


ExecReload=/bin/kill -HUP $MAINPID
ExecStart=/usr/local/bin/redis_exporter \
  --log-format=txt \
  --namespace=redis \
  --web.listen-address=:9121 \



For Init system

Install daemonize ( CentOS / Ubuntu )

sudo yum -y install daemonize
sudo apt-get install daemonize

Create init script

sudo vim /etc/init.d/redis_exporter


# Author: Josphat Mutai, [email protected] ,
# redis_exporter     This shell script takes care of starting and stopping Prometheus redis exporter 
# chkconfig: 2345 80 80
# description: Prometheus redis exporter  start script
# processname: redis_exporter
# pidfile: /var/run/

# Source function library.
. /etc/rc.d/init.d/functions


# GO CPU core Limit

#GOMAXPROCS=$(grep -c ^processor /proc/cpuinfo)

# Source config


    if [[ -f $PIDFILE ]] > /dev/null; then
        echo "redis_exporter  is already running"
        exit 0

    echo -n "Starting redis_exporter  service…"
    daemonize -u $USER -p $PIDFILE -l $LOCKFILE -a -e $LOGFILE -o $LOGFILE $PROG $ARGS
    echo ""
    return $RETVAL

    if [ ! -f "$PIDFILE" ] 

status()  kill -0 $(cat "$PIDFILE"); then
      echo "redis exporter  service running..."
      echo "Service PID: `cat $PIDFILE`"
      echo "Service not running"
     return $RETVAL

# Call function
case "$1" in
        echo "Usage: $0 stop"
        exit 2

Create Arguments configuration file

sudo vim /etc/sysconfig/redis_exporter

Define used command Arguments

ARGS="--log-format=txt \
--namespace=redis \
--web.listen-address=:9121 \

Test the script

$ sudo /etc/init.d/redis_exporter
Usage: /etc/init.d/redis_exporter start

Step 3: Start Redis Prometheus exporter and enable service to start on boot

For a Systemd server, use systemctl command

sudo systemctl daemon-reload
sudo systemctl enable redis_exporter
sudo systemctl start redis_exporter

Confirm service status:

$ systemctl status redis_exporter
 redis_exporter.service - Prometheus
     Loaded: loaded (/etc/systemd/system/redis_exporter.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2021-09-01 10:33:03 UTC; 49s ago
   Main PID: 14814 (redis_exporter)
      Tasks: 4 (limit: 2340)
     Memory: 2.5M
        CPU: 6ms
     CGroup: /system.slice/redis_exporter.service
             └─14814 /usr/local/bin/redis_exporter --log-format=txt --namespace=redis --web.listen-address=:9121 --web.telemetry-path=/metrics

Sep 01 10:33:03 debian-bullseye-01 systemd[1]: Started Prometheus.
Sep 01 10:33:03 debian-bullseye-01 redis_exporter[14814]: time="2021-09-01T10:33:03Z" level=info msg="Redis Metrics Exporter v1.27.0    build date: 2021-08-30-23:37:23    sha1: ef05f8642cd71d632ca1>
Sep 01 10:33:03 debian-bullseye-01 redis_exporter[14814]: time="2021-09-01T10:33:03Z" level=info msg="Providing metrics at :9121/metrics"

For SysV Init system, use

sudo /etc/init.d/redis_exporter start
sudo chkconfig redis_exporter on

You can verify that the service is running using

$ sudo /etc/init.d/redis_exporter status
redis exporter  service running...
Service PID: 27106

$ sudo chkconfig --list | grep redis_exporter
redis_exporter 0:off   1:off   2:on    3:on    4:on    5:on    6:off

$ sudo ss -tunelp | grep 9121
tcp    LISTEN     0      128                   :::9121                 :::*      users:(("redis_exporter",1970,6)) ino:1823474168 sk:ffff880341cd7800

Step 4: Add exporter job to Prometheus

The last step is to add a job to the Prometheus server for scraping metrics. Edit /etc/prometheus/prometheus.yml

# Redis Servers
  - job_name:
      - targets: ['']

  - job_name:
      - targets: ['']

Restart prometheus service for scraping of data metrics to begin

sudo systemctl restart prometheus

Test access to port 9121 from Prometheus server, it should be able to connect.

$ telnet 9121
Connected to
Escape character is '^]'.

If it can’t connect, check your Service port and firewall.

Step 5: Add Dashboard to Grafana

Add Prometheus data source to Grafana and import or create a grafana dashboard for Redis.

Grafana dashboard is available on and/or My Job configuration uses an alias, I’ll use Grafana dashboard with host & alias selector is available on

Download the dashboard json file


On Grafana UI, go to Create > Import Dashboard > Upload .json File. Select downloaded json file and click “Import“.


Wait for data to start appearing on your Grafana Dashboard, below is a sample view


Enjoy using Grafana to monitor your Redis server(s).


Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.