Skip to main content

Prometheus Redis Metrics Exporter

· One min read
Mohammad Zakery

Prometheus Redis Metrics Exporter

Redis Exporter

Building and running the exporter

1.Build and install the Redis exporter.

cd /usr/local/bin/
git clone https://github.com/oliver006/redis_exporter.git
cd redis_exporter
go build .
./redis_exporter --version

2.Run with custom parameters.

./redis_exporter --redis.addr <redis IP> --redis.user <redis username> --redis.password <redis password>

3.Let’s configure Prometheus to start scraping this target, using the following configuration.

scrape_configs:
- job_name: redis_exporter
static_configs:
- targets: ['REDIS-EXPORTER-HOSTNAME:9121']

Firewall

4.Add port 9121 to the firewall.

vim /etc/nftables.conf
tcp dport 9121 accept;

5.Reload the Nftables.

systemctl reload nftables
caution

Be cautious when making changes to the firewall.

Unit file

6.Create the redis-exporter.service in the following path.

vim /lib/systemd/system/redis-exporter.service

7.Place its contents as follows.

[Unit]
Description=Redis Exporter
After=network.target
Documentation=https://zakops.com

[Service]
Type=simple
ExecStart=/usr/local/bin/redis_exporter --redis.addr <redis IP> --redis.user <redis username> --redis.password <redis password>
TimeoutStopSec=0
Restart=always

[Install]
WantedBy=multi-user.target

8.Reload the systemd files.

systemctl daemon-reload

9.Start redis-exporter.service .

systemctl start redis-exporter.service

10.Use this grafana redis exporter dashboard.

https://github.com/oliver006/redis_exporter/blob/master/contrib/grafana_prometheus_redis_dashboard.json