Redis

Supported OS Linux Windows Mac OS

Integration version5.6.0
이 페이지는 아직 한국어로 제공되지 않으며 번역 작업 중입니다. 번역에 관한 질문이나 의견이 있으시면 언제든지 저희에게 연락해 주십시오.

Overview

Whether you use Redis as a database, cache, or message queue, this integration tracks problems with your Redis servers, cloud service, and the parts of your infrastructure they serve. Use the Datadog Agent’s Redis check to collects metrics related to:

  • Performance
  • Memory usage
  • Blocked clients
  • Secondary connections
  • Disk persistence
  • Expired and evicted keys
  • and many more

Setup

Installation

The Redis check is included in the Datadog Agent package, so you don’t need to install anything else on your Redis servers.

Configuration

Host

To configure this check for an Agent running on a host:

Metric collection
  1. Edit the redisdb.d/conf.yaml file, in the conf.d/ folder at the root of your Agent’s configuration directory. The following parameters may require updating. See the sample redisdb.d/conf.yaml for all available configuration options.

    init_config:
    instances:
      ## @param host - string - required
      ## Enter the host to connect to.
      - host: localhost
        ## @param port - integer - required
        ## Enter the port of the host to connect to.
        port: 6379
    
        ## @param username - string - optional
        ## The username to use for the connection. Redis 6+ only.
        #
        # username: <USERNAME>
    
        ## @param password - string - optional
        ## The password to use for the connection.
        #
        # password: <PASSWORD>
    
  2. If using Redis 6+ and ACLs, ensure that the user has at least DB Viewer permissions at the Database level, Cluster Viewer permissions if operating in a cluster environment, and +config|get +info +slowlog|get ACL rules. For more details, see Database access control.

  3. Restart the Agent.

Log collection

Available for Agent versions >6.0

  1. Collecting logs is disabled by default in the Datadog Agent, enable it in your datadog.yaml file:

    logs_enabled: true
    
  2. Uncomment and edit this configuration block at the bottom of your redisdb.d/conf.yaml:

    logs:
      - type: file
        path: /var/log/redis_6379.log
        source: redis
        service: myapplication
    

    Change the path and service parameter values and configure them for your environment. See the sample redisdb.yaml for all available configuration options.

  3. Restart the Agent.

Trace collection

Datadog APM integrates with Redis to see the traces across your distributed system. Trace collection is enabled by default in the Datadog Agent v6+. To start collecting traces:

  1. Enable trace collection in Datadog.
  2. Instrument your application that makes requests to Redis.

Docker

To configure this check for an Agent running on a container:

Metric collection

Set Autodiscovery Integrations Templates as Docker labels on your application container:

LABEL "com.datadoghq.ad.check_names"='["redisdb"]'
LABEL "com.datadoghq.ad.init_configs"='[{}]'
LABEL "com.datadoghq.ad.instances"='[{"host":"%%host%%","port":"6379","password":"%%env_REDIS_PASSWORD%%"}]'

Note: The "%%env_<ENV_VAR>%%" template variable logic is used to avoid storing the password in plain text, hence the REDIS_PASSWORD environment variable must be set on the Agent container. See the Autodiscovery Template Variable documentation for more details. Alternatively, the Agent can leverage the secrets package to work with any secrets management backend (such as HashiCorp Vault or AWS Secrets Manager).

Log collection

Available for Agent versions >6.0

Collecting logs is disabled by default in the Datadog Agent. To enable it, see Docker Log Collection.

Then, set Log Integrations as Docker labels:

LABEL "com.datadoghq.ad.logs"='[{"source":"redis","service":"<YOUR_APP_NAME>"}]'
Trace collection

APM for containerized apps is supported on Agent v6+ but requires extra configuration to begin collecting traces.

Required environment variables on the Agent container:

ParameterValue
<DD_API_KEY>api_key
<DD_APM_ENABLED>true
<DD_APM_NON_LOCAL_TRAFFIC>true

See Tracing Docker Applications for a complete list of available environment variables and configuration.

Then, instrument your application container that makes requests to Redis and set DD_AGENT_HOST to the name of your Agent container.

Kubernetes

To configure this check for an Agent running on Kubernetes:

Metric collection

Set Autodiscovery Integrations Templates as pod annotations on your application container. Aside from this, templates can also be configured using a file, configmap, or key-value store.

Annotations v1 (for Datadog Agent < v7.36)

apiVersion: v1
kind: Pod
metadata:
  name: redis
  annotations:
    ad.datadoghq.com/redis.check_names: '["redisdb"]'
    ad.datadoghq.com/redis.init_configs: '[{}]'
    ad.datadoghq.com/redis.instances: |
      [
        {
          "host": "%%host%%",
          "port":"6379",
          "password":"%%env_REDIS_PASSWORD%%"
        }
      ]      
  labels:
    name: redis
spec:
  containers:
    - name: redis
      image: redis:latest
      ports:
        - containerPort: 6379

Annotations v2 (for Datadog Agent v7.36+)

apiVersion: v1
kind: Pod
metadata:
  name: redis
  annotations:
    ad.datadoghq.com/redis.checks: |
      {
        "redisdb": {
          "init_config": {},
          "instances": [
            {
              "host": "%%host%%",
              "port":"6379",
              "password":"%%env_REDIS_PASSWORD%%"
            }
          ]
        }
      }      
  labels:
    name: redis
spec:
  containers:
    - name: redis
      image: redis:latest
      ports:
        - containerPort: 6379

Note: The "%%env_<ENV_VAR>%%" template variable logic is used to avoid storing the password in plain text, hence the REDIS_PASSWORD environment variable must be set on the Agent container. See the Autodiscovery Template Variable documentation. Alternatively, the Agent can leverage the secrets package to work with any secrets management backend (such as HashiCorp Vault or AWS Secrets Manager).

Log collection

Available for Agent versions >6.0

Collecting logs is disabled by default in the Datadog Agent. To enable it, see Kubernetes Log Collection.

Then, set Log Integrations as pod annotations. This can also be configure using a file, configmap, or key-value store.

Annotations v1/v2

apiVersion: v1
kind: Pod
metadata:
  name: redis
  annotations:
    ad.datadoghq.com/redis.logs: '[{"source":"redis","service":"<YOUR_APP_NAME>"}]'
  labels:
    name: redis
spec:
  containers:
    - name: redis
      image: redis:latest
      ports:
        - containerPort: 6379
Trace collection

APM for containerized apps is supported on hosts running Agent v6+ but requires extra configuration to begin collecting traces.

Required environment variables on the Agent container:

ParameterValue
<DD_API_KEY>api_key
<DD_APM_ENABLED>true
<DD_APM_NON_LOCAL_TRAFFIC>true

See Tracing Kubernetes Applications and the Kubernetes Daemon Setup for a complete list of available environment variables and configuration.

Then, instrument your application container that makes requests to Redis.

ECS

To configure this check for an Agent running on ECS:

Metric collection

Set Autodiscovery Integrations Templates as Docker labels on your application container:

{
  "containerDefinitions": [{
    "name": "redis",
    "image": "redis:latest",
    "dockerLabels": {
      "com.datadoghq.ad.check_names": "[\"redisdb\"]",
      "com.datadoghq.ad.init_configs": "[{}]",
      "com.datadoghq.ad.instances": "[{\"host\":\"%%host%%\",\"port\":\"6379\",\"password\":\"%%env_REDIS_PASSWORD%%\"}]"
    }
  }]
}

Note: The "%%env_<ENV_VAR>%%" template variable logic is used to avoid storing the password in plain text, hence the REDIS_PASSWORD environment variable must be set on the Agent container. See the Autodiscovery Template Variable documentation. Alternatively, the Agent can leverage the secrets package to work with any secrets management backend (such as HashiCorp Vault or AWS Secrets Manager).

Log collection

Available for Agent versions >6.0

Collecting logs is disabled by default in the Datadog Agent. To enable it, see ECS Log Collection.

Then, set Log Integrations as Docker labels:

{
  "containerDefinitions": [{
    "name": "redis",
    "image": "redis:latest",
    "dockerLabels": {
      "com.datadoghq.ad.logs": "[{\"source\":\"redis\",\"service\":\"<YOUR_APP_NAME>\"}]"
    }
  }]
}
Trace collection

APM for containerized apps is supported on Agent v6+ but requires extra configuration to begin collecting traces.

Required environment variables on the Agent container:

ParameterValue
<DD_API_KEY>api_key
<DD_APM_ENABLED>true
<DD_APM_NON_LOCAL_TRAFFIC>true

See Tracing Docker Applications for a complete list of available environment variables and configuration.

Then, instrument your application container that makes requests to Redis and set DD_AGENT_HOST to the EC2 private IP address.

Validation

Run the Agent’s status subcommand and look for redisdb under the Checks section.

Data Collected

Metrics

redis.active_defrag.hits
(gauge)
Number of value reallocations performed by the active defragmentation process.
Shown as operation
redis.active_defrag.key_hits
(gauge)
Number of keys that were actively defragmented.
Shown as key
redis.active_defrag.key_misses
(gauge)
Number of keys that were skipped by.
Shown as key
redis.active_defrag.misses
(gauge)
Number of aborted value reallocations started by the active defragmentation process.
Shown as operation
redis.active_defrag.running
(gauge)
Whether active defragmentation is running or not.
redis.aof.buffer_length
(gauge)
Size of the AOF buffer.
Shown as byte
redis.aof.last_rewrite_time
(gauge)
Duration of the last AOF rewrite.
Shown as second
redis.aof.loading_eta_seconds
(gauge)
The estimated amount of time left to load.
Shown as second
redis.aof.loading_loaded_bytes
(gauge)
The amount of bytes to load.
Shown as byte
redis.aof.loading_loaded_perc
(gauge)
The percent loaded.
Shown as percent
redis.aof.loading_total_bytes
(gauge)
The total amount of bytes already loaded.
Shown as byte
redis.aof.rewrite
(gauge)
Flag indicating a AOF rewrite operation is on-going.
redis.aof.size
(gauge)
AOF current file size (aofcurrentsize).
Shown as byte
redis.clients.biggest_input_buf
(gauge)
The biggest input buffer among current client connections [v3 & v4].
redis.clients.blocked
(gauge)
The number of connections waiting on a blocking call.
Shown as connection
redis.clients.longest_output_list
(gauge)
The longest output list among current client connections [v3 & v4].
redis.clients.recent_max_input_buffer
(gauge)
The biggest input buffer among recent client connections [v5+].
redis.clients.recent_max_output_buffer
(gauge)
The longest output buffer among recent client connections [v5+].
redis.command.calls
(gauge)
The number of times a redis command has been called, tagged by 'command', e.g. 'command:append'. Enable in Agent's redisdb.yaml with the command_stats option.
redis.command.usec_per_call
(gauge)
The CPU time consumed per redis command call, tagged by 'command', e.g. 'command:append'. Enable in Agent's redisdb.yaml with the command_stats option.
redis.cpu.sys
(gauge)
System CPU consumed by the Redis server.
redis.cpu.sys_children
(gauge)
System CPU consumed by the background processes.
redis.cpu.sys_main_thread
(gauge)
System CPU consumed by the Redis server main thread. [v7+].
redis.cpu.user
(gauge)
User CPU consumed by the Redis server.
redis.cpu.user_children
(gauge)
User CPU consumed by the background processes.
redis.cpu.user_main_thread
(gauge)
User CPU consumed by the Redis server main thread. [v7+].
redis.expires
(gauge)
The number of keys with an expiration.
Shown as key
redis.expires.percent
(gauge)
Percentage of total keys with an expiration.
Shown as percent
redis.info.latency_ms
(gauge)
The latency of the redis INFO command.
Shown as millisecond
redis.key.length
(gauge)
The number of elements in a given key, tagged by key, e.g. 'key:mykeyname'. Enable in Agent's redisdb.yaml with the keys option.
redis.keys
(gauge)
The total number of keys.
Shown as key
redis.keys.evicted
(gauge)
The total number of keys evicted due to the maxmemory limit.
Shown as key
redis.keys.expired
(gauge)
The total number of keys expired from the db.
Shown as key
redis.mem.fragmentation_ratio
(gauge)
Ratio between usedmemoryrss and used_memory.
Shown as fraction
redis.mem.lua
(gauge)
Amount of memory used by the Lua engine.
Shown as byte
redis.mem.maxmemory
(gauge)
Maximum amount of memory allocated to the Redisdb system.
Shown as byte
redis.mem.overhead
(gauge)
Sum of all overheads allocated by Redis for managing its internal datastructures [v4+].
Shown as byte
redis.mem.peak
(gauge)
The peak amount of memory used by Redis.
Shown as byte
redis.mem.rss
(gauge)
Amount of memory that Redis allocated as seen by the os.
Shown as byte
redis.mem.startup
(gauge)
Amount of memory consumed by Redis at startup.
Shown as byte
redis.mem.used
(gauge)
Amount of memory allocated by Redis.
Shown as byte
redis.net.clients
(gauge)
The number of connected clients (excluding slaves).
Shown as connection
redis.net.commands
(gauge)
The number of commands processed by the server.
Shown as command
redis.net.commands.instantaneous_ops_per_sec
(gauge)
The number of commands processed by the server per second.
Shown as command
redis.net.connections
(gauge)
The number of connections tagged by client name.
Shown as connection
redis.net.instantaneous_input
(gauge)
The network's read rate per second in KB/sec.
Shown as kibibyte
redis.net.instantaneous_ops_per_sec
(gauge)
Number of commands processed per second.
Shown as operation
redis.net.instantaneous_output
(gauge)
The network's write rate per second in KB/sec.
Shown as kibibyte
redis.net.maxclients
(gauge)
The maximum number of connected clients.
Shown as connection
redis.net.rejected
(gauge)
The number of rejected connections.
Shown as connection
redis.net.slaves
(gauge)
The number of connected slaves.
Shown as connection
redis.net.total_connections_received
(gauge)
Total number of connections accepted by the server.
Shown as connection
redis.perf.latest_fork_usec
(gauge)
The duration of the latest fork.
Shown as microsecond
redis.persist
(gauge)
The number of keys persisted (redis.keys - redis.expires).
Shown as key
redis.persist.percent
(gauge)
Percentage of total keys that are persisted.
Shown as percent
redis.ping.latency_ms
(gauge)
The latency of the redis PING command.
Shown as millisecond
redis.pubsub.channels
(gauge)
The number of active pubsub channels.
redis.pubsub.patterns
(gauge)
The number of active pubsub patterns.
redis.rdb.bgsave
(gauge)
One if a bgsave is in progress and zero otherwise.
redis.rdb.changes_since_last
(gauge)
The number of changes since the last background save.
redis.rdb.last_bgsave_time
(gauge)
Duration of the last bg_save operation.
Shown as second
redis.replication.backlog_histlen
(gauge)
The amount of data in the backlog sync buffer.
Shown as byte
redis.replication.delay
(gauge)
The replication delay in offsets.
Shown as offset
redis.replication.last_io_seconds_ago
(gauge)
Amount of time since the last interaction with master.
Shown as second
redis.replication.master_link_down_since_seconds
(gauge)
Amount of time that the master link has been down.
Shown as second
redis.replication.master_repl_offset
(gauge)
The replication offset reported by the master.
Shown as offset
redis.replication.slave_repl_offset
(gauge)
The replication offset reported by the slave.
Shown as offset
redis.replication.sync
(gauge)
One if a sync is in progress and zero otherwise.
redis.replication.sync_left_bytes
(gauge)
Amount of data left before syncing is complete.
Shown as byte
redis.server.io_threads_active
(gauge)
Flag indicating if I/O threads are active. This metric is only provided by redis >=6.x.
redis.slowlog.micros.95percentile
(gauge)
The 95th percentile of the duration of queries reported in the slow log.
Shown as microsecond
redis.slowlog.micros.avg
(gauge)
The average duration of queries reported in the slow log.
Shown as microsecond
redis.slowlog.micros.count
(rate)
The rate of queries reported in the slow log.
Shown as query
redis.slowlog.micros.max
(gauge)
The maximum duration of queries reported in the slow log.
Shown as microsecond
redis.slowlog.micros.median
(gauge)
The median duration of queries reported in the slow log.
Shown as microsecond
redis.stats.io_threaded_reads_processed
(gauge)
Number of read events processed by the main and I/O threads. This metric is only provided by redis >=6.x.
redis.stats.io_threaded_writes_processed
(gauge)
Number of write events processed by the main and I/O threads. This metric is only provided by redis >=6.x.
redis.stats.keyspace_hits
(gauge)
The rate of successful lookups in the main db.
Shown as key
redis.stats.keyspace_misses
(gauge)
The rate of missed lookups in the main db.
Shown as key

Events

The Redis check does not include any events.

Service Checks

redis.can_connect
Returns CRITICAL if the Agent check is unable to connect to the monitored redis instance. Returns OK otherwise.
Statuses: ok, critical

redis.replication.master_link_status
Returns CRITICAL if this Redis instance is unable to connect to its master instance. Returns OK otherwise.
Statuses: ok, critical

Troubleshooting

Agent cannot connect

    redisdb
    -------
      - instance #0 [ERROR]: 'Error 111 connecting to localhost:6379. Connection refused.'
      - Collected 0 metrics, 0 events & 1 service check

Check that the connection info in redisdb.yaml is correct.

Agent cannot authenticate

    redisdb
    -------
      - instance #0 [ERROR]: 'NOAUTH Authentication required.'
      - Collected 0 metrics, 0 events & 1 service check

Configure a password in redisdb.yaml.

Further Reading

Additional helpful documentation, links, and articles: