Supported OS Linux Windows Mac OS

インテグレーションバージョン4.8.0

概要

Redis をデータベース、キャッシュ、メッセージキューとして使用しているかどうかにかかわらず、このインテグレーションは、Redis サーバー、クラウドサービス、およびそれらが提供するインフラストラクチャーの一部の問題を追跡します。Datadog Agent の Redis チェックを使用して、以下に関連するメトリクスを収集します。

  • パフォーマンス
  • メモリ使用量
  • ブロックされたクライアント
  • 二次接続
  • ディスクの永続性
  • キーの期限切れとエビクション
  • その他多数

セットアップ

インストール

Redis チェックは Datadog Agent パッケージに含まれています。Redis サーバーに追加でインストールする必要はありません。

コンフィギュレーション

ホスト

ホストで実行中の Agent に対してこのチェックを構成するには:

メトリクスの収集
  1. Agent のコンフィギュレーションディレクトリのルートにある conf.d/ フォルダーの redisdb.d/conf.yaml ファイルを編集します。以下のパラメーターは、更新が必要な場合があります。使用可能なすべてのコンフィギュレーションオプションの詳細については、redisdb.d/conf.yaml のサンプルを参照してください。

    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. Redis 6+ と ACL を使用する場合、少なくともデータベースレベルの DB Viewer 権限、クラスター環境で運用する場合は Cluster Viewer 権限、および +config|get +info +slowlog|get ACL ルールが必要であることを確認してください。詳しくは、データベースアクセス制御を参照してください。

  3. Agent を再起動します

ログの収集

Agent バージョン 6.0 以降で利用可能

  1. Datadog Agent で、ログの収集はデフォルトで無効になっています。以下のように、datadog.yaml ファイルでこれを有効にします。

    logs_enabled: true
    
  2. redisdb.d/conf.yaml の下部にある、次の構成ブロックのコメントを解除して編集します。

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

    path パラメーターと service パラメーターの値を変更し、環境に合わせて構成してください。使用可能なすべてのコンフィギュレーションオプションの詳細については、redisdb.yaml のサンプルを参照してください。

  3. Agent を再起動します

トレースの収集

Datadog APM は、Redis と統合して分散システム全体のトレースを確認します。Datadog Agent v6 以降では、トレースの収集はデフォルトで有効化されています。トレースの収集を開始するには、以下の手順に従います。

  1. Datadog でトレースの収集を有効にします
  2. Redis へのリクエストを作成するアプリケーションをインスツルメントします

Docker

コンテナで実行中の Agent に対してこのチェックを構成するには:

メトリクスの収集

アプリケーションのコンテナで、オートディスカバリーのインテグレーションテンプレートを Docker ラベルとして設定します。

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%%"}]'

: パスワードがプレーンテキストで保存されることを避けるため、"%%env_<ENV_VAR>%%" テンプレート変数ロジックが使用されています。そのため、REDIS_PASSWORD 環境変数は Agent コンテナに設定される必要があります。詳細は、オートディスカバリーのテンプレート変数ドキュメントをご参照ください。または、Agent で secrets パッケージを利用してシークレット管理バックエンド(HashiCorp Vault または AWS Secrets Manager)と動作することも可能です。

ログの収集

Agent バージョン 6.0 以降で利用可能

Datadog Agent で、ログの収集はデフォルトで無効になっています。有効にする方法については、Docker ログ収集を参照してください。

次に、ログインテグレーションを Docker ラベルとして設定します。

LABEL "com.datadoghq.ad.logs"='[{"source":"redis","service":"<YOUR_APP_NAME>"}]'
トレースの収集

コンテナ化されたアプリケーションの APM は、Agent v6 以降でサポートされていますが、トレースの収集を開始するには、追加のコンフィギュレーションが必要です。

Agent コンテナで必要な環境変数

パラメーター
<DD_API_KEY>api_key
<DD_APM_ENABLED>true
<DD_APM_NON_LOCAL_TRAFFIC>true

利用可能な環境変数およびコンフィギュレーションの全リストについては、Docker アプリケーションのトレース を参照してください。

次に、Redis にリクエストを送信するアプリケーションのコンテナをインスツルメントし、Agent のコンテナ名に DD_AGENT_HOST を設定します。

Kubernetes

このチェックを、Kubernetes で実行している Agent に構成します。

メトリクスの収集

アプリケーションのコンテナで、オートディスカバリーのインテグレーションテンプレートをポッドアノテーションとして設定します。他にも、ファイル、ConfigMap、または key-value ストアを使用してテンプレートを構成できます。

Annotations v1 (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 (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

: パスワードがプレーンテキストで保存されることを避けるため、"%%env_<ENV_VAR>%%" テンプレート変数ロジックが使用されています。そのため、REDIS_PASSWORD 環境変数は Agent コンテナに設定される必要があります。詳細は、オートディスカバリーのテンプレート変数ドキュメントをご参照ください。または、Agent で secrets パッケージを利用してシークレット管理バックエンド(HashiCorp Vault または AWS Secrets Manager)と動作することも可能です。

ログの収集

Agent バージョン 6.0 以降で利用可能

Datadog Agent で、ログの収集はデフォルトで無効になっています。有効にする方法については、Kubernetes ログ収集を参照してください。

次に、ログのインテグレーションをポッドアノテーションとして設定します。これは、ファイル、ConfigMap、または key-value ストアを使用して構成することも可能です。

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
トレースの収集

コンテナ化されたアプリケーションの APM は、Agent v6 以降を実行するホストでサポートされていますが、トレースの収集を開始するには、追加のコンフィギュレーションが必要です。

Agent コンテナで必要な環境変数

パラメーター
<DD_API_KEY>api_key
<DD_APM_ENABLED>true
<DD_APM_NON_LOCAL_TRAFFIC>true

利用可能な環境変数とコンフィギュレーションの完全なリストについては、Kubernetes アプリケーションのトレースおよび Kubernetes Daemon のセットアップを参照してください。

そして、Redis へのリクエストを作成するアプリケーションコンテナをインスツルメントします

ECS

このチェックを、ECS で実行している Agent に構成するには:

メトリクスの収集

アプリケーションのコンテナで、オートディスカバリーのインテグレーションテンプレートを Docker ラベルとして設定します。

{
  "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%%\"}]"
    }
  }]
}

: パスワードがプレーンテキストで保存されることを避けるため、"%%env_<ENV_VAR>%%" テンプレート変数ロジックが使用されています。そのため、REDIS_PASSWORD 環境変数は Agent コンテナに設定される必要があります。詳細は、オートディスカバリーのテンプレート変数ドキュメントをご参照ください。または、Agent で secrets パッケージを利用してシークレット管理バックエンド(HashiCorp Vault または AWS Secrets Manager)と動作することも可能です。

ログの収集

Agent バージョン 6.0 以降で利用可能

Datadog Agent で、ログの収集はデフォルトで無効になっています。有効にする方法については、ECS ログ収集を参照してください。

次に、ログインテグレーションを Docker ラベルとして設定します。

{
  "containerDefinitions": [{
    "name": "redis",
    "image": "redis:latest",
    "dockerLabels": {
      "com.datadoghq.ad.logs": "[{\"source\":\"redis\",\"service\":\"<YOUR_APP_NAME>\"}]"
    }
  }]
}
トレースの収集

コンテナ化されたアプリケーションの APM は、Agent v6 以降でサポートされていますが、トレースの収集を開始するには、追加のコンフィギュレーションが必要です。

Agent コンテナで必要な環境変数

パラメーター
<DD_API_KEY>api_key
<DD_APM_ENABLED>true
<DD_APM_NON_LOCAL_TRAFFIC>true

利用可能な環境変数およびコンフィギュレーションの全リストについては、Docker アプリケーションのトレース を参照してください。

次に、Redis にリクエストを送信するアプリケーションのコンテナをインスツルメントし、 EC2 プライベート IP アドレスDD_AGENT_HOST を設定します。

検証

Agent の status サブコマンドを実行し、Checks セクションで redisdb を探します。

収集データ

メトリクス

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

イベント

Redis チェックには、イベントは含まれません。

サービスのチェック

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

トラブルシューティング

Agent が接続できない

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

redisdb.yaml 内の接続情報が正しいかどうかをチェックしてください。

Agent を認証できない

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

redisdb.yamlpassword を設定してください。

その他の参考資料

お役に立つドキュメント、リンクや記事: