Sign In

Redis Monitoring

Monitor your Redis instances with OpenTelemetry


Overview

Monitor Redis performance and health using the OpenTelemetry Collector with the Redis receiver. Track memory usage, hit rates, connection counts, and command throughput.

What You'll Monitor

  • • Memory usage and fragmentation
  • • Cache hit/miss ratio
  • • Commands per second
  • • Connected clients
  • • Key evictions
  • • Replication status

OpenTelemetry Collector Setup

Use the OpenTelemetry Collector with the Redis receiver to collect metrics.

1. Configure the Collector

# otel-collector-config.yaml
receivers:
  redis:
    endpoint: "localhost:6379"
    collection_interval: 30s
    # If Redis requires authentication:
    password: ${REDIS_PASSWORD}
    # For Redis Cluster:
    # endpoint: "redis-cluster:6379"

exporters:
  otlphttp:
    endpoint: https://qorrelate.io
    headers:
      Authorization: "Bearer ${QORRELATE_API_KEY}"
      X-Organization-Id: "${QORRELATE_ORG_ID}"

service:
  pipelines:
    metrics:
      receivers: [redis]
      exporters: [otlphttp]

2. Run the Collector

# Docker
docker run -v ./otel-collector-config.yaml:/etc/otel/config.yaml \
  -e REDIS_PASSWORD=your_redis_password \
  -e QORRELATE_API_KEY=your_api_key \
  -e QORRELATE_ORG_ID=your_org_id \
  otel/opentelemetry-collector-contrib:latest \
  --config=/etc/otel/config.yaml

Kubernetes Deployment

apiVersion: v1
kind: ConfigMap
metadata:
  name: otel-collector-config
data:
  config.yaml: |
    receivers:
      redis:
        endpoint: "redis-master.default.svc:6379"
        collection_interval: 30s
    exporters:
      otlphttp:
        endpoint: https://qorrelate.io
        headers:
          Authorization: "Bearer ${QORRELATE_API_KEY}"
          X-Organization-Id: "${QORRELATE_ORG_ID}"
    service:
      pipelines:
        metrics:
          receivers: [redis]
          exporters: [otlphttp]

Available Metrics

Metric Description Type
redis.memory.used Total memory used by Redis Gauge
redis.memory.peak Peak memory consumption Gauge
redis.memory.fragmentation_ratio Memory fragmentation ratio Gauge
redis.clients.connected Number of connected clients Gauge
redis.clients.blocked Clients blocked on BLPOP etc. Gauge
redis.commands Total commands processed Counter
redis.keyspace.hits Successful key lookups Counter
redis.keyspace.misses Failed key lookups (cache misses) Counter
redis.keys.evicted Keys evicted due to maxmemory Counter
redis.keys.expired Keys expired Counter
redis.connections.received Total connections received Counter
redis.connections.rejected Connections rejected (maxclients) Counter
redis.replication.offset Replication offset Gauge

Application-Level Command Tracing

To trace individual Redis commands from your application, use OpenTelemetry SDK instrumentation.

Python (redis-py)

pip install opentelemetry-instrumentation-redis
from opentelemetry.instrumentation.redis import RedisInstrumentor

# Auto-instrument all redis connections
RedisInstrumentor().instrument()

# Your Redis commands are now traced
import redis
r = redis.Redis()
r.get("my_key")  # Creates a span for this command

Node.js (ioredis/redis)

npm install @opentelemetry/instrumentation-ioredis
# or
npm install @opentelemetry/instrumentation-redis
const { IORedisInstrumentation } = require('@opentelemetry/instrumentation-ioredis');

// Add to your instrumentation setup
instrumentations: [
  new IORedisInstrumentation({
    dbStatementSerializer: (cmdName, cmdArgs) => {
      return `${cmdName} ${cmdArgs.join(' ')}`;
    }
  })
]

Go

import "go.opentelemetry.io/contrib/instrumentation/github.com/go-redis/redis/otelredis"

// Wrap your Redis client
rdb := redis.NewClient(&redis.Options{Addr: "localhost:6379"})
rdb.AddHook(otelredis.NewTracingHook())

Redis Slow Log

Redis has a built-in slow log. Configure and collect it:

1. Configure Slow Log in Redis

# Log commands taking longer than 10ms
redis-cli CONFIG SET slowlog-log-slower-than 10000

# Keep 1000 slow log entries
redis-cli CONFIG SET slowlog-max-len 1000

2. View Slow Log

# Get last 10 slow log entries
redis-cli SLOWLOG GET 10

Tip: The OpenTelemetry Collector's Redis receiver can be configured to periodically collect and forward slow log entries as log events.

Pre-built Dashboard Queries

Use these PromQL queries to build your Redis dashboard:

Cache Hit Ratio

100 * rate(redis_keyspace_hits[5m]) / 
  (rate(redis_keyspace_hits[5m]) + rate(redis_keyspace_misses[5m]))

Commands per Second

rate(redis_commands[5m])

Memory Usage %

100 * redis_memory_used / redis_memory_max

Eviction Rate

rate(redis_keys_evicted[5m])

Connected Clients

redis_clients_connected

Recommended Alerts

Memory Near Limit

redis_memory_used / redis_memory_max > 0.9

Alert when memory usage exceeds 90% of maxmemory

High Eviction Rate

rate(redis_keys_evicted[5m]) > 100

Alert when evicting >100 keys/sec (adjust based on your usage)

Low Cache Hit Ratio

100 * rate(redis_keyspace_hits[5m]) / 
  (rate(redis_keyspace_hits[5m]) + rate(redis_keyspace_misses[5m])) < 80

Alert when hit ratio drops below 80%

Connection Spike

redis_clients_connected > 1000

Alert on unusually high connection count

High Memory Fragmentation

redis_memory_fragmentation_ratio > 1.5

Alert when fragmentation ratio exceeds 1.5