Kubesense

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:

  1. A Redis server running version 3.0 or newer
  2. 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.yaml

Note: 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 NameCategoryDescription
redis.commands_processedPerformanceTotal number of commands processed by the server
redis.commandsPerformanceNumber of commands processed per second
redis.cmd.latencyPerformanceCommand execution latency
redis.cpu_timePerformanceSystem CPU consumed by the Redis server
redis.memory_usedMemoryTotal bytes allocated by Redis using its allocator
redis.memory_rssMemoryBytes allocated as seen by the operating system
redis.memory_peakMemoryPeak memory consumed by Redis
redis.memory_luaMemoryBytes used by the Lua engine
redis.maxmemoryMemoryValue of the maxmemory configuration directive
redis.memory_fragmentation_ratioMemoryRatio between used_memory_rss and used_memory
redis.clients_connectedConnectionNumber of client connections (excluding replicas)
redis.clients_blockedConnectionNumber of clients pending on blocking calls
redis.clients_max_input_bufferConnectionBiggest input buffer among client connections
redis.clients_max_output_bufferConnectionLongest output list among client connections
redis.connections_receivedConnectionTotal connections accepted by the server
redis.connections_rejectedConnectionConnections rejected due to maxclients limit
redis.slaves_connectedConnectionNumber of connected replicas
redis.net_inputNetworkTotal bytes read from the network
redis.net_outputNetworkTotal bytes written to the network
redis.keyspace_hitsKey SpaceSuccessful key lookups in the main dictionary
redis.keyspace_missesKey SpaceFailed key lookups in the main dictionary
redis.db_keysKey SpaceNumber of keyspace keys
redis.db_expiresKey SpaceKeyspace keys with an expiration
redis.db_avg_ttlKey SpaceAverage keyspace key TTL
redis.replication_offsetReplicationServer's current replication offset
redis.replication_backlog_first_byte_offsetReplicationMaster offset of the replication backlog buffer
redis.keys_evictedReplicationKeys evicted due to maxmemory limit
redis.keys_expiredReplicationTotal key expiration events
redis.rdb_changes_since_last_saveReplicationChanges since last dump
redis.latest_forkReplicationDuration of the latest fork operation
redis.uptimeServerSeconds 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.