Redis
Integrating Redis Metrics to KubeSense
KubeSense provides comprehensive monitoring for Redis through OpenTelemetry (OTEL) Collector integration, allowing you to collect key Redis metrics and visualize them in the KubeSense platform.
Prerequisites
Before you begin, ensure you have:
- A Redis server running version 3.0 or newer
- KubeSense deployed with OpenTelemetry (OTEL) Collector with access to the Redis server
- Install the OTEL Collector if not done already
- Ensure the OTEL collector has access to the Redis server for metrics collection
Locating the KubeSense Sensor Service Endpoint
To find the endpoint for the Sensor service (referred to as {KUBESENSOR_HOST}), follow the instructions provided here.
Step 1: Create the Collector Config File
Create a file named redis-metrics-collection-config.yaml with the following content:
receivers:
redis:
# The hostname and port of the Redis instance, separated by a colon.
endpoint: ${env:REDIS_ENDPOINT}
# The frequency at which to collect metrics from the Redis instance.
collection_interval: 60s
# The password used to access the Redis instance; must match the password specified in the requirepass server configuration option.
password: ${env:REDIS_PASSWORD}
metrics:
redis.maxmemory:
enabled: true
redis.cmd.latency:
enabled: true
processors:
# enriches the data with additional host information
resourcedetection/system:
detectors: ["system"]
system:
hostname_sources: ["os"]
service:
pipelines:
metrics/redis:
receivers: [redis]
processors: [resourcedetection/system]
exporters: [otlphttp/kubesense_redis]Step 2: Set Environment Variables
Set the following environment variables:
# Redis endpoint reachable from the OTEL collector
export REDIS_ENDPOINT="localhost:6379"
# Password used to access the Redis instance.
# Can be left empty if the redis server is not configured to require a password.
export REDIS_PASSWORD=""If you want to add custom resource attributes to identify the Redis instance:
processors:
resource:
attributes:
- action: insert
key: kubesense.cluster
value: {CLUSTER_NAME}
- action: insert
key: kubesense.env_type
value: (k8s|docker|legacy)Metrics Pipeline:
pipelines:
metrics:
receivers: [redis]
processors: [resourcedetection/system, resource]
exporters: [otlphttp/kubesense_redis]Step 3: Use the Collector Config File
Add the following flag to your collector run command:
--config redis-metrics-collection-config.yamlNote: The collector can use multiple config files by specifying multiple --config flags.
Redis Metrics Collected
KubeSense automatically collects and enriches the following key Redis metrics:
| Metric Name | Category | Description |
|---|---|---|
| redis.commands_processed | Performance | Total number of commands processed by the server |
| redis.commands | Performance | Number of commands processed per second |
| redis.cmd.latency | Performance | Command execution latency |
| redis.cpu_time | Performance | System CPU consumed by the Redis server |
| redis.memory_used | Memory | Total bytes allocated by Redis using its allocator |
| redis.memory_rss | Memory | Bytes allocated as seen by the operating system |
| redis.memory_peak | Memory | Peak memory consumed by Redis |
| redis.memory_lua | Memory | Bytes used by the Lua engine |
| redis.maxmemory | Memory | Value of the maxmemory configuration directive |
| redis.memory_fragmentation_ratio | Memory | Ratio between used_memory_rss and used_memory |
| redis.clients_connected | Connection | Number of client connections (excluding replicas) |
| redis.clients_blocked | Connection | Number of clients pending on blocking calls |
| redis.clients_max_input_buffer | Connection | Biggest input buffer among client connections |
| redis.clients_max_output_buffer | Connection | Longest output list among client connections |
| redis.connections_received | Connection | Total connections accepted by the server |
| redis.connections_rejected | Connection | Connections rejected due to maxclients limit |
| redis.slaves_connected | Connection | Number of connected replicas |
| redis.net_input | Network | Total bytes read from the network |
| redis.net_output | Network | Total bytes written to the network |
| redis.keyspace_hits | Key Space | Successful key lookups in the main dictionary |
| redis.keyspace_misses | Key Space | Failed key lookups in the main dictionary |
| redis.db_keys | Key Space | Number of keyspace keys |
| redis.db_expires | Key Space | Keyspace keys with an expiration |
| redis.db_avg_ttl | Key Space | Average keyspace key TTL |
| redis.replication_offset | Replication | Server's current replication offset |
| redis.replication_backlog_first_byte_offset | Replication | Master offset of the replication backlog buffer |
| redis.keys_evicted | Replication | Keys evicted due to maxmemory limit |
| redis.keys_expired | Replication | Total key expiration events |
| redis.rdb_changes_since_last_save | Replication | Changes since last dump |
| redis.latest_fork | Replication | Duration of the latest fork operation |
| redis.uptime | Server | Seconds since Redis server start |
Visualization in KubeSense
Once configured, Redis metrics will appear in the KubeSense dashboard, allowing you to:
- Monitor Redis performance in real-time
- Track memory usage and identify potential bottlenecks
- Analyze command patterns and latency
- Monitor connection pool health
- Set up alerts for key Redis metrics
Conclusion
KubeSense provides seamless Redis monitoring through OpenTelemetry integration, enabling you to track the health and performance of your Redis instances alongside your other infrastructure and applications in a unified observability platform.