
Monitoring Redis Droplet Using Redis Exporter
Setting up proper monitoring for your Redis instances is crucial for maintaining performance, identifying bottlenecks, and preventing outages before they happen. The Redis Exporter, a powerful Prometheus exporter specifically designed for Redis, makes it incredibly easy to collect detailed metrics from your Redis deployments and visualize them through tools like Grafana. In this guide, you’ll learn how to install and configure Redis Exporter, set up monitoring dashboards, interpret key Redis metrics, and troubleshoot common issues that can arise in production environments.
How Redis Exporter Works
Redis Exporter functions as a bridge between your Redis instances and Prometheus monitoring system. It connects to Redis servers, executes INFO commands to gather comprehensive metrics, and exposes these metrics in Prometheus format on an HTTP endpoint.
The exporter collects over 100 different metrics including:
- Memory usage statistics (used_memory, maxmemory, memory fragmentation)
- Connection metrics (connected_clients, blocked_clients, rejected_connections)
- Performance data (instantaneous_ops_per_sec, keyspace_hits, keyspace_misses)
- Persistence information (rdb_last_save_time, aof_last_rewrite_time)
- Replication status for master-slave setups
- Key expiration and eviction statistics
The exporter runs as a lightweight daemon that periodically scrapes Redis instances and maintains minimal overhead, typically consuming less than 50MB of RAM and negligible CPU resources.
Step-by-Step Setup Guide
Let’s walk through setting up Redis Exporter on a typical DigitalOcean droplet. This assumes you already have Redis running and want to add monitoring capabilities.
Installing Redis Exporter
First, download and install the Redis Exporter binary:
cd /opt
sudo wget https://github.com/oliver006/redis_exporter/releases/download/v1.57.0/redis_exporter-v1.57.0.linux-amd64.tar.gz
sudo tar xvfz redis_exporter-v1.57.0.linux-amd64.tar.gz
sudo mv redis_exporter-v1.57.0.linux-amd64/redis_exporter /usr/local/bin/
sudo chmod +x /usr/local/bin/redis_exporter
Create a dedicated user for the exporter:
sudo useradd --no-create-home --shell /bin/false redis_exporter
Creating the Systemd Service
Create a systemd service file to manage the Redis Exporter:
sudo nano /etc/systemd/system/redis_exporter.service
Add the following configuration:
[Unit]
Description=Redis Exporter
Wants=network-online.target
After=network-online.target
[Service]
User=redis_exporter
Group=redis_exporter
Type=simple
ExecStart=/usr/local/bin/redis_exporter \
-redis.addr=redis://localhost:6379 \
-web.listen-address=:9121 \
-log-format=txt
SyslogIdentifier=redis_exporter
Restart=always
RestartSec=1
StartLimitInterval=0
[Install]
WantedBy=multi-user.target
Enable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable redis_exporter
sudo systemctl start redis_exporter
sudo systemctl status redis_exporter
Configuring for Multiple Redis Instances
If you’re running multiple Redis instances, create a configuration file:
sudo nano /etc/redis_exporter/config.yml
redis_addrs:
- "redis://localhost:6379"
- "redis://localhost:6380"
- "redis://redis-slave:6379"
check_keys:
- "user:*"
- "session:*"
- "cache:*"
check_single_keys:
- "system:health"
- "queue:priority"
Update the systemd service to use the config file:
ExecStart=/usr/local/bin/redis_exporter \
-config-command CONFIG \
-redis.addr=redis://localhost:6379 \
-web.listen-address=:9121 \
-check-keys=user:*,session:*,cache:* \
-log-format=txt
Prometheus Configuration
Add the Redis Exporter target to your Prometheus configuration:
scrape_configs:
- job_name: 'redis_exporter'
static_configs:
- targets: ['localhost:9121']
scrape_interval: 15s
metrics_path: /metrics
- job_name: 'redis_exporter_targets'
static_configs:
- targets:
- redis://localhost:6379
- redis://redis-cluster-1:6379
- redis://redis-cluster-2:6379
metrics_path: /scrape
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: localhost:9121
Key Metrics to Monitor
Understanding which Redis metrics matter most can save you hours of debugging. Here’s a breakdown of critical metrics and their significance:
Metric | Description | Alert Threshold | Impact |
---|---|---|---|
redis_memory_used_bytes | Total memory consumed by Redis | > 85% of maxmemory | OOM kills, performance degradation |
redis_connected_clients | Number of active connections | > 80% of maxclients | Connection refused errors |
redis_keyspace_hits_total | Successful key lookups | Hit ratio < 80% | Cache inefficiency |
redis_commands_processed_total | Total commands executed | Rate-based alerting | Performance baseline |
redis_blocked_clients | Clients waiting on blocking operations | > 10% of connected clients | Application timeouts |
Real-World Use Cases and Examples
Here are some practical scenarios where Redis monitoring has proven invaluable:
E-commerce Session Store Monitoring
For high-traffic e-commerce sites using Redis for session storage, monitoring key expiration patterns helps optimize TTL settings:
# PromQL query to track session key patterns
rate(redis_expired_keys_total[5m])
# Alert for unusual session expiration spikes
redis_expired_keys_total - redis_expired_keys_total offset 1h > 1000
Cache Hit Ratio Optimization
Tracking cache performance across different key patterns:
# Calculate hit ratio percentage
(rate(redis_keyspace_hits_total[5m]) /
(rate(redis_keyspace_hits_total[5m]) + rate(redis_keyspace_misses_total[5m]))) * 100
Memory Usage Prediction
Using historical data to predict when Redis will hit memory limits:
# Memory growth rate over 24 hours
predict_linear(redis_memory_used_bytes[24h], 3600 * 24)
Alternative Monitoring Solutions
While Redis Exporter is excellent for Prometheus ecosystems, here’s how it compares to other monitoring approaches:
Solution | Pros | Cons | Best For |
---|---|---|---|
Redis Exporter + Prometheus | Comprehensive metrics, flexible queries, great Grafana integration | Requires Prometheus setup, learning curve | DevOps teams, microservices |
RedisInsight | Official Redis GUI, real-time monitoring, easy setup | Limited historical data, not suitable for production alerting | Development, debugging |
DataDog Redis Integration | Managed solution, automatic alerting, APM correlation | Expensive, vendor lock-in | Enterprise environments |
Custom Redis INFO parsing | Lightweight, custom metrics | Maintenance overhead, limited features | Simple deployments |
Best Practices and Common Pitfalls
Security Considerations
Always secure your Redis Exporter endpoints, especially in production:
# Enable basic auth in Prometheus config
basic_auth:
username: monitoring
password: your-secure-password
# Or use TLS with client certificates
tls_config:
cert_file: /path/to/client.crt
key_file: /path/to/client.key
ca_file: /path/to/ca.crt
Performance Optimization
Don’t over-monitor. Collecting too many key-level metrics can impact Redis performance:
# Good: Monitor key patterns, not individual keys
-check-keys=user:session:*,cache:products:*
# Bad: Monitoring thousands of individual keys
-check-single-keys=user:1,user:2,user:3...
Common Troubleshooting Issues
Here are the most frequent problems and their solutions:
- Connection refused errors: Check Redis AUTH requirements and network connectivity
- Missing metrics: Verify Redis version compatibility and ensure CONFIG command access
- High memory usage: Limit key scanning with appropriate check-keys patterns
- Scrape timeouts: Increase Prometheus scrape timeout for large Redis instances
Alerting Rules
Set up essential alerts with these Prometheus rules:
groups:
- name: redis
rules:
- alert: RedisDown
expr: redis_up == 0
for: 0m
labels:
severity: critical
annotations:
summary: "Redis instance is down"
- alert: RedisMemoryHigh
expr: redis_memory_used_bytes / redis_memory_max_bytes > 0.9
for: 2m
labels:
severity: warning
annotations:
summary: "Redis memory usage is above 90%"
- alert: RedisConnectionsHigh
expr: redis_connected_clients > redis_config_maxclients * 0.8
for: 2m
labels:
severity: warning
annotations:
summary: "Redis connection count is high"
Advanced Configuration Options
For production deployments, consider these advanced Redis Exporter features:
Custom Scripts and Lua Monitoring
Monitor custom Lua script performance:
# Enable script metrics collection
-include-system-metrics=true
-redis.addr=redis://localhost:6379?script-metrics=true
Multi-Instance Discovery
For dynamic Redis discovery in containerized environments:
# Using consul discovery
- job_name: 'redis-consul'
consul_sd_configs:
- server: 'localhost:8500'
services: ['redis']
relabel_configs:
- source_labels: [__meta_consul_service_port]
target_label: __param_target
- target_label: __address__
replacement: redis-exporter:9121
Redis Exporter provides a robust foundation for monitoring Redis infrastructure at scale. The key to success lies in starting with essential metrics, gradually expanding coverage based on your specific use cases, and maintaining a balance between comprehensive monitoring and system performance. For additional configuration options and troubleshooting guides, refer to the official Redis Exporter documentation and the Redis optimization guide.

This article incorporates information and material from various online sources. We acknowledge and appreciate the work of all original authors, publishers, and websites. While every effort has been made to appropriately credit the source material, any unintentional oversight or omission does not constitute a copyright infringement. All trademarks, logos, and images mentioned are the property of their respective owners. If you believe that any content used in this article infringes upon your copyright, please contact us immediately for review and prompt action.
This article is intended for informational and educational purposes only and does not infringe on the rights of the copyright owners. If any copyrighted material has been used without proper credit or in violation of copyright laws, it is unintentional and we will rectify it promptly upon notification. Please note that the republishing, redistribution, or reproduction of part or all of the contents in any form is prohibited without express written permission from the author and website owner. For permissions or further inquiries, please contact us.