Redis
Monitor Redis performance, memory usage, and key metrics with OpenTelemetry and Last9
Use OpenTelemetry to monitor Redis performance and send telemetry data to Last9. This integration provides comprehensive monitoring of Redis server metrics, memory usage, command statistics, and log analysis.
Prerequisites
Before setting up Redis monitoring, ensure you have:
- Redis server installed and running
- Administrative access to your Redis server
- OpenTelemetry Collector installation access
- Last9 account with integration credentials
-
Verify Redis Installation
Ensure Redis server is installed and running on your system:
sudo apt updatesudo apt install redis-serversudo systemctl status redis-server -
Install OpenTelemetry Collector
Choose the appropriate package for your operating system. Note that systemd is required for automatic service configuration.
For Debian/Ubuntu systems:
wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.118.0/otelcol-contrib_0.118.0_linux_amd64.debsudo dpkg -i otelcol-contrib_0.118.0_linux_amd64.debFor Red Hat/CentOS systems:
wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.118.0/otelcol-contrib_0.118.0_linux_amd64.rpmsudo rpm -ivh otelcol-contrib_0.118.0_linux_amd64.rpmMore installation options can be found in the official OpenTelemetry documentation.
-
Configure OpenTelemetry Collector
Create the collector configuration file:
sudo nano /etc/otelcol-contrib/config.yamlAdd the following configuration to monitor Redis metrics, logs, and system resources:
receivers:filelog:# File path pattern to read logs from. Update this to the destination from where you want to read Redis logs.include: [/var/log/redis/*.log]include_file_path: trueretry_on_failure:enabled: truehostmetrics:collection_interval: 60sscrapers:cpu:metrics:system.cpu.logical.count:enabled: truememory:metrics:system.memory.utilization:enabled: truesystem.memory.limit:enabled: trueload:disk:filesystem:metrics:system.filesystem.utilization:enabled: truenetwork:paging:redis:endpoint: "localhost:6379"collection_interval: 60sprocessors:batch:timeout: 20ssend_batch_size: 10000send_batch_max_size: 10000resourcedetection/cloud:detectors: ["aws", "gcp", "azure"]resourcedetection/system:detectors: ["system"]system:hostname_sources: ["os"]transform/logs:flatten_data: truelog_statements:- context: logstatements:- set(observed_time, Now())- set(time_unix_nano, observed_time_unix_nano) where time_unix_nano == 0- set(resource.attributes["service.name"], "redis") # Change this to appropriate service name- set(resource.attributes["deployment.environment"], "staging") # Set to environmentexporters:otlp/last9:endpoint: "{{ .Logs.WriteURL }}"headers:"Authorization": "{{ .Logs.AuthValue }}"debug:verbosity: detailedservice:pipelines:logs:receivers: [filelog]processors: [batch, resourcedetection/system, transform/logs]exporters: [otlp/last9]metrics:receivers: [redis, hostmetrics]processors: [batch, resourcedetection/system, resourcedetection/cloud]exporters: [otlp/last9]Replace the placeholder values in the
exporterssection with your actual Last9 credentials from the Last9 Integrations page.Update the following settings as needed:
- Redis endpoint (default:
localhost:6379) - Service name and environment in the transform processor
- Log file paths based on your Redis configuration
- Redis endpoint (default:
-
Configure OpenTelemetry Collector Service
Create a systemd service file for the collector:
sudo nano /etc/systemd/system/otelcol-contrib.serviceAdd the following service configuration:
[Unit]Description=OpenTelemetry Collector Contrib with custom flagsAfter=network.target[Service]ExecStart=/usr/bin/otelcol-contrib --config /etc/otelcol-contrib/config.yaml --feature-gates transform.flatten.logsRestart=alwaysUser=rootGroup=root[Install]WantedBy=multi-user.target -
Start and Enable the Service
Reload systemd configuration and start the collector service:
sudo systemctl daemon-reloadsudo systemctl enable otelcol-contribsudo systemctl start otelcol-contrib
Understanding the Setup
Redis Receiver
The Redis receiver connects directly to your Redis server and collects comprehensive metrics including:
- Memory Metrics: Used memory, peak memory, memory fragmentation ratio
- Performance Metrics: Commands processed, keyspace hits/misses, evicted keys
- Connection Metrics: Connected clients, blocked clients, total connections
- Persistence Metrics: RDB and AOF statistics
- Replication Metrics: Master/slave sync status and lag
Host Metrics Collection
The collector also gathers system-level metrics to provide context for Redis performance:
- CPU utilization and system load
- Memory usage and availability
- Disk I/O and filesystem utilization
- Network traffic statistics
Log Collection
The filelog receiver monitors Redis log files for:
- Connection and disconnection events
- Configuration changes
- Error messages and warnings
- Slow query logs and performance issues
Verification and Monitoring
-
Check Service Status
Verify the OpenTelemetry Collector service is running:
sudo systemctl status otelcol-contrib -
Monitor Service Logs
Check for any configuration errors or connection issues:
sudo journalctl -u otelcol-contrib -f -
Verify Redis Connection
Test that the collector can connect to your Redis instance:
# Test Redis connectivityredis-cli ping# Check Redis inforedis-cli info -
Check Metrics Collection
Look for successful metric collection in the collector logs. You should see log entries indicating successful data export to Last9.
-
Verify Data in Last9
Log into your Last9 account and check that Redis metrics are being received in Grafana.
Key Redis Metrics to Monitor
The integration automatically collects important Redis metrics including:
Memory Metrics
redis.memory.used: Current memory usageredis.memory.peak: Peak memory usageredis.memory.rss: Resident set sizeredis.memory.fragmentation.ratio: Memory fragmentation ratio
Performance Metrics
redis.commands.processed: Total commands processedredis.keyspace.hits: Number of successful key lookupsredis.keyspace.misses: Number of failed key lookupsredis.keys.evicted: Number of evicted keys
Connection Metrics
redis.clients.connected: Currently connected clientsredis.clients.blocked: Clients blocked on operationsredis.connections.received: Total connections received
Configuration Tips
Redis Authentication
If your Redis instance requires authentication, update the receiver configuration:
redis: endpoint: "localhost:6379" password: "your_redis_password" collection_interval: 60sCustom Log Paths
Update the log file paths based on your Redis configuration:
filelog: include: [/path/to/your/redis/logs/*.log] include_file_path: trueResource Attribution
Customize resource attributes for better organization:
transform/logs: flatten_data: true log_statements: - context: log statements: - set(resource.attributes["service.name"], "redis-primary") - set(resource.attributes["deployment.environment"], "production") - set(resource.attributes["redis.instance"], "cache-cluster-1")Troubleshooting
Service Issues
If the collector service fails to start:
# Check service statussudo systemctl status otelcol-contrib
# View detailed logssudo journalctl -u otelcol-contrib --no-pager
# Validate configurationsudo /usr/bin/otelcol-contrib --config /etc/otelcol-contrib/config.yaml --dry-runRedis Connection Issues
For Redis connection problems:
# Test Redis connectivityredis-cli -h localhost -p 6379 ping
# Check Redis logssudo tail -f /var/log/redis/redis-server.log
# Verify Redis configurationredis-cli config get '*'Performance Considerations
- Adjust
collection_intervalbased on your monitoring needs - Monitor the collector’s resource usage with high-traffic Redis instances
- Consider using Redis replica instances for monitoring to reduce load on primary
Need Help?
If you encounter any issues or have questions:
- Join our Discord community for real-time support
- Contact our support team at support@last9.io