• /
  • EnglishEspañolFrançais日本語한국어Português
  • ログイン今すぐ開始

この機械翻訳は、参考として提供されています。

英語版と翻訳版に矛盾がある場合は、英語版が優先されます。詳細については、このページを参照してください。

問題を作成する

ホスト上のRedisをモニターする(OpenTelemetry)

サーバーまたは仮想マシンに直接OpenTelemetry Collectorをインストールして、セルフホスト型のRedisインスタンスをモニターします。このガイドでは、Redisメトリクスをスクレイピングし、ログを収集し、OTLPプロトコルを使用してすべてのテレメトリーをNew Relicに送信するようにコレクターを設定する手順を説明します。

あなたが始める前に

コレクターを設定する前に、以下のものが必要です:

各パスのセットアップ手順は、NRDOTコレクターotelcol-contrib、redis_exporterのいずれであっても、まだ必要となるインストレーションをカバーしています。

インストールオプション

環境に合ったコレクターディストリビューションを選択してください:

Redisの監視を設定する

この設定は、コレクターにRedisメトリクスを収集してNew Relicに送信する方法を指示します。3つの主なジョブを処理します:

  • redisレシーバーを通じてRedisからメトリクスを収集します。

  • データを形成します — カーディナリティを削減し、カウンターをデルタに変換し、エンティティ合成のためにタグ付けします。

  • 処理されたメトリクスをOTLP経由でNew Relicにエクスポートする

    コレクターの設定ファイルを作成します:

    bash
    $
    sudo nano /etc/nrdot-collector/redis-collector-config.yaml

    以下の設定を貼り付け、Redisのendpointlocalhost:6379でない場合は更新します:

    extensions:
    health_check:
    endpoint: "0.0.0.0:13133"
    receivers:
    redis:
    endpoint: "localhost:6379" # Update with your Redis host:port
    collection_interval: 10s
    metrics:
    redis.maxmemory:
    enabled: true
    redis.role:
    enabled: false
    redis.cmd.calls:
    enabled: true
    redis.cmd.usec:
    enabled: true
    redis.clients.max_input_buffer:
    enabled: false
    redis.clients.max_output_buffer:
    enabled: false
    redis.replication.backlog_first_byte_offset:
    enabled: false
    resource_attributes:
    server.address:
    enabled: true
    server.port:
    enabled: true
    processors:
    memory_limiter:
    check_interval: 5s
    limit_mib: 512
    spike_limit_mib: 128
    resource_detection:
    detectors: [env, system]
    timeout: 5s
    override: false
    system:
    resource_attributes:
    host.name:
    enabled: true
    host.id:
    enabled: true
    # Uncomment the section below to use a custom human-readable name for your
    # Redis entity instead of the default server.address:server.port identifier.
    # resource/redis:
    # attributes:
    # - key: redis.instance.id
    # value: "my-redis-instance"
    # action: upsert
    attributes/entity_tags:
    actions:
    - key: instrumentation.provider
    value: opentelemetry
    action: upsert
    cumulativetodelta:
    include:
    match_type: regexp
    metrics:
    - redis\.commands\.processed
    - redis\.connections\.received
    - redis\.connections\.rejected
    - redis\.keys\.evicted
    - redis\.keys\.expired
    - redis\.keyspace\.hits
    - redis\.keyspace\.misses
    - redis\.net\.input
    - redis\.net\.output
    - redis\.cpu\.time
    - redis\.cmd\.calls
    - redis\.cmd\.usec
    - redis\.uptime
    filter/cardinality:
    metrics:
    datapoint:
    - 'metric.name == "redis.cpu.time" and attributes["state"] != "sys" and attributes["state"] != "user"'
    - 'metric.name == "redis.cmd.calls" and attributes["cmd"] != "get" and attributes["cmd"] != "set" and attributes["cmd"] != "del" and attributes["cmd"] != "hget" and attributes["cmd"] != "hset" and attributes["cmd"] != "hgetall" and attributes["cmd"] != "lpush" and attributes["cmd"] != "rpop" and attributes["cmd"] != "zadd" and attributes["cmd"] != "expire"'
    - 'metric.name == "redis.cmd.usec" and attributes["cmd"] != "get" and attributes["cmd"] != "set" and attributes["cmd"] != "del" and attributes["cmd"] != "hget" and attributes["cmd"] != "hset" and attributes["cmd"] != "hgetall" and attributes["cmd"] != "lpush" and attributes["cmd"] != "rpop" and attributes["cmd"] != "zadd" and attributes["cmd"] != "expire"'
    transform/metadata_nullify:
    metric_statements:
    - context: metric
    statements:
    - set(description, "")
    - set(unit, "")
    batch:
    send_batch_size: 2048
    send_batch_max_size: 4096
    timeout: 10s
    exporters:
    otlp_http:
    endpoint: ${env:OTEL_EXPORTER_OTLP_ENDPOINT}
    headers:
    api-key: ${env:NEW_RELIC_LICENSE_KEY}
    compression: gzip
    service:
    extensions: [health_check]
    pipelines:
    metrics/redis:
    receivers: [redis]
    # If using resource/redis for custom name, add it to the processors list:
    # processors: [memory_limiter, resource_detection, resource/redis, attributes/entity_tags, cumulativetodelta, filter/cardinality, transform/metadata_nullify, batch]
    processors: [memory_limiter, resource_detection, attributes/entity_tags, cumulativetodelta, filter/cardinality, transform/metadata_nullify, batch]
    exporters: [otlp_http]

    この設定で行うこと

    パイプラインの各コンポーネントには特定の役割があります:

    コンポーネント説明
    health_checkコレクターが実行されていることを確認できるように、0.0.0.0:13133でヘルスエンドポイントを公開します。
    redis レシーバー10秒ごとにRedisエンドポイントに接続し、RedisのINFOコマンドからメトリクスを読み取ります。server.addressserver.portはエンティティのIDになります。
    memory_limiterホストを保護するために、コレクターのメモリ使用量を制限します(512 MiBのソフトリミット、128 MiBのスパイク)。
    resource_detectionホストを検出し、host.namehost.idを追加して、Redisメトリクスを基盤となるホストエンティティにリンクします。
    attributes/entity_tagsクエリをOpenTelemetryパスにスコープできるように、すべてのメトリクスにinstrumentation.provider: opentelemetryをスタンプします。
    cumulativetodeltaNew Relicがレートを正しくチャート化できるように、Redisの累積カウンター — コマンド、キースペースヒット、エビクションなど — をデルタ値に変換します。
    filter/cardinality取り込みコストを制御するために、高いカーディナリティのデータポイント(usersys以外のCPUステータス、および一般的ではないコマンドのコマンドごとのメトリクス)をドロップします。
    transform/metadata_nullifyペイロードのサイズを縮小するために、メトリクスの説明と単位をクリアします。
    batchネットワークのオーバーヘッドを削減するために、エクスポートする前にデータポイントをグループ化し(バッチあたり2,048、最大4,096)、少なくとも10秒ごとにフラッシュします。
    otlp_http処理されたメトリクスを、ライセンスキーで認証し、gzip圧縮を使用してOTLP経由でNew Relicにエクスポートします。

    ヒント

    ユーザーフレンドリーなエンティティ名をご希望ですか?デフォルトでは、Redisエンティティはserver.address:server.portの組み合わせを使用して名前が付けられます。代わりに人間が読めるカスタム名を使用するには、上記の設定のresource/redisセクションのコメントを解除し、redis.instance.idの値に希望する名前を設定して、プロセッサパイプラインにresource/redisを追加します。

オプション:認証を構成する

デフォルトでは、コレクターは資格情報なしでRedisに接続します。Redisインスタンスに認証が必要な場合は、一致する資格情報をredisレシーバーに追加します。設定に一致するオプションを選択してください:

オプション:Redisログの収集

メトリクスに加えて、コレクターはRedisのログファイルをNew Relicに転送できるため、ログイベント — 再起動、永続化イベント、またはエラー — を同じエンティティ上のメトリクスのスパイクと関連付けることができます。Redisのログをテールするには、filelogレシーバーを追加します:

receivers:
# ... existing redis receiver ...
file_log/redis:
include:
- /var/log/redis/redis-server.log
start_at: end
operators:
- type: regex_parser
regex: '^\d+:[XCSM] \d+ \w+ \d+ \d+:\d+:\d+\.\d+ (?P<level>.) '
on_error: send
resource:
db.system: redis

ファイルからのログ行には、それ自体にRedis接続コンテキストがありません—New RelicがログをRedisエンティティに関連付けるように、ID属性を明示的にアタッチする必要があります。RedisエンティティのIDに一致するハードコードされた値を使用して、resource/redis_logsプロセッサを追加します:

processors:
# ... existing processors ...
resource/redis_logs:
attributes:
- key: server.address
value: "localhost" # Must match your redis receiver endpoint host
action: upsert
- key: server.port
value: 6379 # Must match your redis receiver endpoint port
action: upsert
- key: instrumentation.provider
value: opentelemetry
action: upsert

ヒント

カスタムインスタンスIDを使用していますか?カスタムエンティティの命名のためにresource/redisプロセッサーを有効にした場合は、上記のserver.addressserver.portredis.instance.idに置き換えます:

resource/redis_logs:
attributes:
- key: redis.instance.id
value: "my-redis-instance" # Must match the value in resource/redis
action: upsert
- key: instrumentation.provider
value: opentelemetry
action: upsert

serviceセクションに別のログパイプラインを追加します:

service:
pipelines:
metrics/redis:
receivers: [redis]
processors: [memory_limiter, resource_detection, attributes/entity_tags, cumulativetodelta, filter/cardinality, transform/metadata_nullify, batch]
exporters: [otlp_http]
logs/redis:
receivers: [file_log/redis]
processors: [memory_limiter, resource/redis_logs, batch]
exporters: [otlp_http]

重要

コレクターは、Redisログファイルとその親ディレクトリの両方に対する読み取りアクセス権を持っている必要があります。以下を実行します。

bash
$
sudo chmod 755 /var/log/redis
$
sudo chmod 644 /var/log/redis/redis-server.log

オプション:ホストメトリクスの収集

Redisのパフォーマンスは、多くの場合、ホストのリソースの圧迫 — CPUの飽和、メモリの枯渇、またはディスクI/Oの競合に連動します。Redisと一緒にホストからシステムメトリクスを収集するためにhostmetricsレシーバーを追加し、New Relicで2つを関連付けることができるようにします:

receivers:
# ... existing receivers ...
host_metrics:
collection_interval: 10s
scrapers:
cpu:
metrics:
system.cpu.utilization: {enabled: true}
system.cpu.time: {enabled: true}
load:
metrics:
system.cpu.load_average.1m: {enabled: true}
system.cpu.load_average.5m: {enabled: true}
system.cpu.load_average.15m: {enabled: true}
memory:
metrics:
system.memory.usage: {enabled: true}
system.memory.utilization: {enabled: true}
disk:
metrics:
system.disk.io: {enabled: true}
system.disk.operations: {enabled: true}
filesystem:
metrics:
system.filesystem.usage: {enabled: true}
system.filesystem.utilization: {enabled: true}
network:
metrics:
system.network.io: {enabled: true}
system.network.packets: {enabled: true}

ホストメトリクス用に別のmetrics/hostパイプラインを追加します(Redisパイプラインにhostmetricsを追加しないでください):

service:
pipelines:
metrics/redis:
receivers: [redis]
processors: [memory_limiter, resource_detection, attributes/entity_tags, cumulativetodelta, filter/cardinality, transform/metadata_nullify, batch]
exporters: [otlp_http]
metrics/host:
receivers: [host_metrics]
processors: [memory_limiter, resource_detection, attributes/entity_tags, cumulativetodelta, batch]
exporters: [otlp_http]

オプション:カスタムメタデータの追加

カスタムリソース属性によって、すべてのRedisメトリクスにコンテキスト — 環境、チーム、またはティア — のタグが付けられるため、New Relicでデータをフィルタリングおよびグループ化できます。必要なタグを含むresource/customプロセッサを追加します:

processors:
# ... existing processors ...
resource/custom:
attributes:
- key: environment
value: "production"
action: upsert
- key: team
value: "platform"
action: upsert
- key: redis.cluster
value: "cache-tier-1"
action: upsert

パイプラインにプロセッサを含めます:

service:
pipelines:
metrics/redis:
receivers: [redis]
processors: [memory_limiter, resource_detection, resource/custom, attributes/entity_tags, cumulativetodelta, filter/cardinality, transform/metadata_nullify, batch]
exporters: [otlp_http]

オプション:Redis Clusterの監視を有効にする

Redis Clusterの監視には、現在Prometheusレシーバーのアプローチ(redis_exporterを使用)が必要です。NRDOT CollectorのネイティブRedisレシーバーは、クラスタのメトリクスに必要なCLUSTER INFOコマンドをまだサポートしていません。クラスタの監視設定には、Prometheusレシーバータブを使用してください。

環境変数の設定

コレクターは、デプロイメント固有の値 — ライセンスキー、OTLPエンドポイント、および設定パス — を環境ファイルから読み取ります。これにより、設定YAMLからシークレットを排除できます。環境ファイルを作成します:

bash
$
sudo tee /etc/nrdot-collector/nrdot-collector.conf > /dev/null <<'EOF'
$
NEW_RELIC_LICENSE_KEY=YOUR_LICENSE_KEY
$
OTEL_EXPORTER_OTLP_ENDPOINT=YOUR_OTLP_ENDPOINT
$
# Set the New Relic OTLP endpoint for your region.
$
# See https://docs.newrelic.com/docs/opentelemetry/best-practices/opentelemetry-otlp
$
OTELCOL_OPTIONS="--config=/etc/nrdot-collector/redis-collector-config.yaml"
$
EOF
$
sudo chmod 600 /etc/nrdot-collector/nrdot-collector.conf

プレースホルダーを独自の値に置き換えます:

変数必須説明
NEW_RELIC_LICENSE_KEYはいNew Relic取り込みライセンスキー
OTEL_EXPORTER_OTLP_ENDPOINTはいご利用のリージョンのNew Relic OTLPエンドポイント。詳細については、New Relic OTLPエンドポイントを参照してください。
OTELCOL_OPTIONSはいコレクターにRedis設定ファイルを指定します。

ヒント

この設定は、デフォルトのNRDot設定を置き換えます。Redis監視と並行してデフォルトのNRDotパイプラインを保持する必要がある場合は、デフォルトの設定ファイルも追加してください:

bash
$
OTELCOL_OPTIONS="--config=/etc/nrdot-collector/config.yaml --config=/etc/nrdot-collector/redis-collector-config.yaml"

複数の設定ファイルを使用する場合は、それらの間でコンポーネント名が競合していないことを確認してください。サフィックスを追加して、Redis設定内の重複するプロセッサの名前を変更します(例:memory_limiterの代わりにmemory_limiter/redis)。

再起動して確認します

新しい設定を読み込むにはコレクターを再起動します:

bash
$
sudo systemctl daemon-reload
$
sudo systemctl restart nrdot-collector
$
sudo systemctl status nrdot-collector

statusコマンドはActive: active (running)を表示するはずです。Active: failedと表示される場合は、journalctl -u nrdot-collector -n 100 --no-pagerでログを確認してください — 最も一般的な原因は、YAMLのインデントエラーと到達不可能なRedisエンドポイントです。

次に、メトリクスがNew Relicに到達していることを確認します。再起動後約1分待ってから、クエリビルダーで次のクエリを実行します:

SELECT count(*) FROM Metric WHERE metricName LIKE 'redis.%' AND instrumentation.provider = 'opentelemetry' SINCE 5 minutes ago

ゼロ以外のカウントにより、Redisメトリクスが流れていることが確認できます。0が返される場合は、Redisのトラブルシューティング(OpenTelemetry)を参照してください。

コレクターをインストールする

まだ存在しない場合は、OpenTelemetry Collector Contribをインストールします:

インストレーション後、コレクターはotelcol-contrib.serviceという名前のsystemdサービスとして利用できます。

Redisの監視を設定する

この設定は、コレクターにRedisメトリクスを収集してNew Relicに送信する方法を指示します。3つの主なジョブを処理します:

  • redisレシーバーを通じてRedisからメトリクスを収集します。

  • データを形成します — カーディナリティを削減し、カウンターをデルタに変換し、エンティティ合成のためにタグ付けします。

  • 処理されたメトリクスをOTLP経由でNew Relicにエクスポートする

    コレクターの設定ファイルを作成します:

    bash
    $
    sudo nano /etc/otelcol-contrib/redis-collector-config.yaml

    以下の設定を貼り付け、Redisのendpointlocalhost:6379でない場合は更新します:

    extensions:
    health_check:
    endpoint: "0.0.0.0:13133"
    receivers:
    redis:
    endpoint: "localhost:6379" # Update with your Redis host:port
    collection_interval: 10s
    metrics:
    redis.maxmemory:
    enabled: true
    redis.role:
    enabled: false
    redis.cmd.calls:
    enabled: true
    redis.cmd.usec:
    enabled: true
    redis.clients.max_input_buffer:
    enabled: false
    redis.clients.max_output_buffer:
    enabled: false
    redis.replication.backlog_first_byte_offset:
    enabled: false
    resource_attributes:
    server.address:
    enabled: true
    server.port:
    enabled: true
    processors:
    memory_limiter:
    check_interval: 5s
    limit_mib: 512
    spike_limit_mib: 128
    resource_detection:
    detectors: [env, system]
    timeout: 5s
    override: false
    system:
    resource_attributes:
    host.name:
    enabled: true
    host.id:
    enabled: true
    # Uncomment the section below to use a custom human-readable name for your
    # Redis entity instead of the default server.address:server.port identifier.
    # resource/redis:
    # attributes:
    # - key: redis.instance.id
    # value: "my-redis-instance"
    # action: upsert
    attributes/entity_tags:
    actions:
    - key: instrumentation.provider
    value: opentelemetry
    action: upsert
    cumulativetodelta:
    include:
    match_type: regexp
    metrics:
    - redis\.commands\.processed
    - redis\.connections\.received
    - redis\.connections\.rejected
    - redis\.keys\.evicted
    - redis\.keys\.expired
    - redis\.keyspace\.hits
    - redis\.keyspace\.misses
    - redis\.net\.input
    - redis\.net\.output
    - redis\.cpu\.time
    - redis\.cmd\.calls
    - redis\.cmd\.usec
    - redis\.uptime
    filter/cardinality:
    metrics:
    datapoint:
    - 'metric.name == "redis.cpu.time" and attributes["state"] != "sys" and attributes["state"] != "user"'
    - 'metric.name == "redis.cmd.calls" and attributes["cmd"] != "get" and attributes["cmd"] != "set" and attributes["cmd"] != "del" and attributes["cmd"] != "hget" and attributes["cmd"] != "hset" and attributes["cmd"] != "hgetall" and attributes["cmd"] != "lpush" and attributes["cmd"] != "rpop" and attributes["cmd"] != "zadd" and attributes["cmd"] != "expire"'
    - 'metric.name == "redis.cmd.usec" and attributes["cmd"] != "get" and attributes["cmd"] != "set" and attributes["cmd"] != "del" and attributes["cmd"] != "hget" and attributes["cmd"] != "hset" and attributes["cmd"] != "hgetall" and attributes["cmd"] != "lpush" and attributes["cmd"] != "rpop" and attributes["cmd"] != "zadd" and attributes["cmd"] != "expire"'
    transform/metadata_nullify:
    metric_statements:
    - context: metric
    statements:
    - set(description, "")
    - set(unit, "")
    batch:
    send_batch_size: 2048
    send_batch_max_size: 4096
    timeout: 10s
    exporters:
    otlp_http:
    endpoint: ${env:OTEL_EXPORTER_OTLP_ENDPOINT}
    headers:
    api-key: ${env:NEW_RELIC_LICENSE_KEY}
    compression: gzip
    service:
    extensions: [health_check]
    pipelines:
    metrics/redis:
    receivers: [redis]
    # If using resource/redis for custom name, add it to the processors list:
    # processors: [memory_limiter, resource_detection, resource/redis, attributes/entity_tags, cumulativetodelta, filter/cardinality, transform/metadata_nullify, batch]
    processors: [memory_limiter, resource_detection, attributes/entity_tags, cumulativetodelta, filter/cardinality, transform/metadata_nullify, batch]
    exporters: [otlp_http]

    この設定で行うこと

    パイプラインの各コンポーネントには特定の役割があります:

    コンポーネント説明
    health_checkコレクターが実行されていることを確認できるように、0.0.0.0:13133でヘルスエンドポイントを公開します。
    redis レシーバー10秒ごとにRedisエンドポイントに接続し、RedisのINFOコマンドからメトリクスを読み取ります。server.addressserver.portはエンティティのIDになります。
    memory_limiterホストを保護するために、コレクターのメモリ使用量を制限します(512 MiBのソフトリミット、128 MiBのスパイク)。
    resource_detectionホストを検出し、host.namehost.idを追加して、Redisメトリクスを基盤となるホストエンティティにリンクします。
    attributes/entity_tagsクエリをOpenTelemetryパスにスコープできるように、すべてのメトリクスにinstrumentation.provider: opentelemetryをスタンプします。
    cumulativetodeltaNew Relicがレートを正しくチャート化できるように、Redisの累積カウンター — コマンド、キースペースヒット、エビクションなど — をデルタ値に変換します。
    filter/cardinality取り込みコストを制御するために、高いカーディナリティのデータポイント(usersys以外のCPUステータス、および一般的ではないコマンドのコマンドごとのメトリクス)をドロップします。
    transform/metadata_nullifyペイロードのサイズを縮小するために、メトリクスの説明と単位をクリアします。
    batchネットワークのオーバーヘッドを削減するために、エクスポートする前にデータポイントをグループ化し(バッチあたり2,048、最大4,096)、少なくとも10秒ごとにフラッシュします。
    otlp_http処理されたメトリクスを、ライセンスキーで認証し、gzip圧縮を使用してOTLP経由でNew Relicにエクスポートします。

    ヒント

    ユーザーフレンドリーなエンティティ名をご希望ですか?デフォルトでは、Redisエンティティはserver.address:server.portの組み合わせを使用して名前が付けられます。代わりに人間が読めるカスタム名を使用するには、上記の設定のresource/redisセクションのコメントを解除し、redis.instance.idの値に希望する名前を設定して、プロセッサパイプラインにresource/redisを追加します。

オプション:認証を構成する

デフォルトでは、コレクターは資格情報なしでRedisに接続します。Redisインスタンスに認証が必要な場合は、一致する資格情報をredisレシーバーに追加します。設定に一致するオプションを選択してください:

オプション:Redisログの収集

メトリクスに加えて、コレクターはRedisのログファイルをNew Relicに転送できるため、ログイベント — 再起動、永続化イベント、またはエラー — を同じエンティティ上のメトリクスのスパイクと関連付けることができます。Redisのログをテールするには、filelogレシーバーを追加します:

receivers:
# ... existing redis receiver ...
file_log/redis:
include:
- /var/log/redis/redis-server.log
start_at: end
operators:
- type: regex_parser
regex: '^\d+:[XCSM] \d+ \w+ \d+ \d+:\d+:\d+\.\d+ (?P<level>.) '
on_error: send
resource:
db.system: redis

ファイルからのログ行には、それ自体にRedis接続コンテキストがありません—New RelicがログをRedisエンティティに関連付けるように、ID属性を明示的にアタッチする必要があります。RedisエンティティのIDに一致するハードコードされた値を使用して、resource/redis_logsプロセッサを追加します:

processors:
# ... existing processors ...
resource/redis_logs:
attributes:
- key: server.address
value: "localhost" # Must match your redis receiver endpoint host
action: upsert
- key: server.port
value: 6379 # Must match your redis receiver endpoint port
action: upsert
- key: instrumentation.provider
value: opentelemetry
action: upsert

ヒント

カスタムインスタンスIDを使用していますか?カスタムエンティティの命名のためにresource/redisプロセッサーを有効にした場合は、上記のserver.addressserver.portredis.instance.idに置き換えます:

resource/redis_logs:
attributes:
- key: redis.instance.id
value: "my-redis-instance" # Must match the value in resource/redis
action: upsert
- key: instrumentation.provider
value: opentelemetry
action: upsert

serviceセクションに別のログパイプラインを追加します:

service:
pipelines:
metrics/redis:
receivers: [redis]
processors: [memory_limiter, resource_detection, attributes/entity_tags, cumulativetodelta, filter/cardinality, transform/metadata_nullify, batch]
exporters: [otlp_http]
logs/redis:
receivers: [file_log/redis]
processors: [memory_limiter, resource/redis_logs, batch]
exporters: [otlp_http]

重要

コレクターは、Redisログファイルとその親ディレクトリの両方に対する読み取りアクセス権を持っている必要があります。以下を実行します。

bash
$
sudo chmod 755 /var/log/redis
$
sudo chmod 644 /var/log/redis/redis-server.log

オプション:ホストメトリクスの収集

Redisのパフォーマンスは、多くの場合、ホストのリソースの圧迫 — CPUの飽和、メモリの枯渇、またはディスクI/Oの競合に連動します。Redisと一緒にホストからシステムメトリクスを収集するためにhostmetricsレシーバーを追加し、New Relicで2つを関連付けることができるようにします:

receivers:
# ... existing receivers ...
host_metrics:
collection_interval: 10s
scrapers:
cpu:
metrics:
system.cpu.utilization: {enabled: true}
system.cpu.time: {enabled: true}
load:
metrics:
system.cpu.load_average.1m: {enabled: true}
system.cpu.load_average.5m: {enabled: true}
system.cpu.load_average.15m: {enabled: true}
memory:
metrics:
system.memory.usage: {enabled: true}
system.memory.utilization: {enabled: true}
disk:
metrics:
system.disk.io: {enabled: true}
system.disk.operations: {enabled: true}
filesystem:
metrics:
system.filesystem.usage: {enabled: true}
system.filesystem.utilization: {enabled: true}
network:
metrics:
system.network.io: {enabled: true}
system.network.packets: {enabled: true}

ホストメトリクス用に別のmetrics/hostパイプラインを追加します(Redisパイプラインにhost_metricsを追加しないでください):

service:
pipelines:
metrics/redis:
receivers: [redis]
processors: [memory_limiter, resource_detection, attributes/entity_tags, cumulativetodelta, filter/cardinality, transform/metadata_nullify, batch]
exporters: [otlp_http]
metrics/host:
receivers: [host_metrics]
processors: [memory_limiter, resource_detection, attributes/entity_tags, cumulativetodelta, batch]
exporters: [otlp_http]

オプション:Redis Clusterの監視を有効にする

Redis Clusterの監視には、現在Prometheusレシーバーのアプローチ(redis_exporterを使用)が必要です。OpenTelemetry Collector ContribのネイティブRedisレシーバーは、クラスタメトリクスに必要なCLUSTER INFOコマンドをまだサポートしていません。クラスタの監視設定には、Prometheusレシーバータブを使用してください。

環境変数の設定

コレクターは、デプロイメント固有の値 — ライセンスキー、OTLPエンドポイント、および設定パス — を環境ファイルから読み取ります。これにより、設定YAMLからシークレットを排除できます。環境ファイルを作成します:

bash
$
sudo tee /etc/otelcol-contrib/otelcol-contrib.conf > /dev/null <<'EOF'
$
NEW_RELIC_LICENSE_KEY=YOUR_LICENSE_KEY
$
OTEL_EXPORTER_OTLP_ENDPOINT=YOUR_OTLP_ENDPOINT
$
# Set the New Relic OTLP endpoint for your region.
$
# See https://docs.newrelic.com/docs/opentelemetry/best-practices/opentelemetry-otlp
$
OTELCOL_OPTIONS="--config=/etc/otelcol-contrib/redis-collector-config.yaml"
$
EOF
$
sudo chmod 600 /etc/otelcol-contrib/otelcol-contrib.conf

プレースホルダーを独自の値に置き換えます:

変数必須説明
NEW_RELIC_LICENSE_KEYはいNew Relic取り込みライセンスキー
OTEL_EXPORTER_OTLP_ENDPOINTはいご利用のリージョンのNew Relic OTLPエンドポイント。詳細については、New Relic OTLPエンドポイントを参照してください。
OTELCOL_OPTIONSはいコレクターにRedis設定ファイルを指定します。

ヒント

この設定は、デフォルトのOTel Collector Contrib設定を置き換えます。Redis監視と並行してデフォルトの設定を保持する必要がある場合は、デフォルトの設定ファイルも追加してください:

bash
$
OTELCOL_OPTIONS="--config=/etc/otelcol-contrib/config.yaml --config=/etc/otelcol-contrib/redis-collector-config.yaml"

複数の設定ファイルを使用する場合は、それらの間でコンポーネント名が競合していないことを確認してください。サフィックスを追加して、Redis設定内の重複するプロセッサの名前を変更します(例:memory_limiterの代わりにmemory_limiter/redis)。

再起動して確認します

新しい設定を読み込むにはコレクターを再起動します:

bash
$
sudo systemctl daemon-reload
$
sudo systemctl restart otelcol-contrib
$
sudo systemctl status otelcol-contrib

statusコマンドはActive: active (running)を表示するはずです。Active: failedと表示される場合は、journalctl -u otelcol-contrib -n 100 --no-pagerでログを確認してください — 最も一般的な原因は、YAMLのインデントエラーと到達不可能なRedisエンドポイントです。

次に、メトリクスがNew Relicに到達していることを確認します。再起動後約1分待ってから、クエリビルダーで次のクエリを実行します:

SELECT count(*) FROM Metric WHERE metricName LIKE 'redis.%' AND instrumentation.provider = 'opentelemetry' SINCE 5 minutes ago

ゼロ以外のカウントにより、Redisメトリクスが流れていることが確認できます。0が返される場合は、Redisのトラブルシューティング(OpenTelemetry)を参照してください。

redis_exporterをインストールする

redis_exporterは、ポート9121でPrometheus形式のRedisメトリクスを公開します。

redis_exporterのsystemdサービスを作成します:

bash
$
sudo tee /etc/systemd/system/redis_exporter.service > /dev/null <<'EOF'
$
[Unit]
$
Description=Redis Exporter
$
After=network.target
$
$
[Service]
$
ExecStart=/usr/local/bin/redis_exporter --redis.addr=redis://localhost:6379
$
Restart=always
$
User=nobody
$
$
[Install]
$
WantedBy=multi-user.target
$
EOF
$
$
sudo systemctl daemon-reload
$
sudo systemctl enable --now redis_exporter

エクスポーターが実行中であることを確認します:

bash
$
curl -s http://localhost:9121/metrics | grep redis_up

redis_up 1が表示されます。

コレクターの設定を作成します

この設定は、redis_exporterからメトリクスをスクレイピングし、それらをNew Relicに送信します。これは以下の主なジョブを処理します:

  • prometheusレシーバーを介してredis_exporterPrometheusエンドポイントをスクレイプします

  • PrometheusのメトリクスをNew RelicのRedisメトリクス名に名前変更します

  • データを形成します — カーディナリティを削減し、カウンターをデルタに変換し、エンティティ合成のためにタグ付けします。

  • 処理されたメトリクスをOTLP経由でNew Relicにエクスポートする

    設定ファイルを作成します。コレクターに適切なパスを使用します:

  • NRDOT: /etc/nrdot-collector/redis-prometheus-config.yaml

  • OTel Contrib: /etc/otelcol-contrib/redis-prometheus-config.yaml

    extensions:
    health_check:
    endpoint: "0.0.0.0:13133"
    receivers:
    prometheus:
    config:
    scrape_configs:
    - job_name: 'redis'
    scrape_interval: 10s
    static_configs:
    - targets: ['localhost:9121'] # Update with your Redis exporter host:port
    metric_relabel_configs:
    - source_labels: [__name__]
    regex: '(go_|process_|promhttp_|redis_exporter_).*'
    action: drop
    processors:
    memory_limiter:
    check_interval: 5s
    limit_mib: 512
    spike_limit_mib: 128
    resource_detection:
    detectors: [env, system]
    timeout: 5s
    override: false
    system:
    resource_attributes:
    host.name:
    enabled: true
    host.id:
    enabled: true
    # Required: Set a unique identifier for your Redis entity.
    # The Prometheus receiver does not provide server.address/server.port,
    # so redis.instance.id is required for entity creation in New Relic.
    resource/redis_identity:
    attributes:
    - key: redis.instance.id
    value: "my-redis-instance:6379" # Update with a unique name for this Redis instance
    action: upsert
    attributes/entity_tags:
    actions:
    - key: instrumentation.provider
    value: opentelemetry
    action: upsert
    metricstransform:
    transforms:
    - include: redis_uptime_in_seconds
    action: update
    new_name: redis.uptime
    - include: redis_connected_clients
    action: update
    new_name: redis.clients.connected
    - include: redis_blocked_clients
    action: update
    new_name: redis.clients.blocked
    - include: redis_memory_used_bytes
    action: update
    new_name: redis.memory.used
    - include: redis_memory_max_bytes
    action: update
    new_name: redis.maxmemory
    - include: redis_mem_fragmentation_ratio
    action: update
    new_name: redis.memory.fragmentation_ratio
    - include: redis_memory_used_rss_bytes
    action: update
    new_name: redis.memory.rss
    - include: redis_memory_used_peak_bytes
    action: update
    new_name: redis.memory.peak
    - include: redis_memory_used_lua_bytes
    action: update
    new_name: redis.memory.lua
    - include: redis_connections_received_total
    action: update
    new_name: redis.connections.received
    - include: redis_rejected_connections_total
    action: update
    new_name: redis.connections.rejected
    - include: redis_commands_processed_total
    action: update
    new_name: redis.commands.processed
    - include: redis_keyspace_hits_total
    action: update
    new_name: redis.keyspace.hits
    - include: redis_keyspace_misses_total
    action: update
    new_name: redis.keyspace.misses
    - include: redis_evicted_keys_total
    action: update
    new_name: redis.keys.evicted
    - include: redis_expired_keys_total
    action: update
    new_name: redis.keys.expired
    - include: redis_net_input_bytes_total
    action: update
    new_name: redis.net.input
    - include: redis_net_output_bytes_total
    action: update
    new_name: redis.net.output
    - include: redis_connected_slaves
    action: update
    new_name: redis.slaves.connected
    - include: redis_db_keys
    action: update
    new_name: redis.db.keys
    - include: redis_db_keys_expiring
    action: update
    new_name: redis.db.expires
    - include: redis_rdb_changes_since_last_save
    action: update
    new_name: redis.rdb.changes_since_last_save
    - include: redis_db_avg_ttl_seconds
    action: update
    new_name: redis.db.avg_ttl
    - include: redis_latest_fork_seconds
    action: update
    new_name: redis.latest_fork
    - include: redis_master_repl_offset
    action: update
    new_name: redis.replication.offset
    - include: redis_repl_backlog_first_byte_offset
    action: update
    new_name: redis.replication.backlog_first_byte_offset
    - include: redis_commands_total
    action: update
    new_name: redis.cmd.calls
    - include: redis_commands_duration_seconds_total
    action: update
    new_name: redis.cmd.usec
    - include: redis_cpu_sys_seconds_total
    action: update
    new_name: redis.cpu.time
    operations:
    - action: add_label
    new_label: state
    new_value: sys
    - include: redis_cpu_user_seconds_total
    action: update
    new_name: redis.cpu.time
    operations:
    - action: add_label
    new_label: state
    new_value: user
    cumulativetodelta:
    include:
    match_type: regexp
    metrics:
    - redis\.commands\.processed
    - redis\.connections\.received
    - redis\.connections\.rejected
    - redis\.keys\.evicted
    - redis\.keys\.expired
    - redis\.keyspace\.hits
    - redis\.keyspace\.misses
    - redis\.net\.input
    - redis\.net\.output
    - redis\.cpu\.time
    - redis\.cmd\.calls
    - redis\.cmd\.usec
    - redis\.uptime
    filter/cardinality:
    metrics:
    datapoint:
    - 'metric.name == "redis.cpu.time" and attributes["state"] != "sys" and attributes["state"] != "user"'
    - 'metric.name == "redis.cmd.calls" and attributes["cmd"] != "get" and attributes["cmd"] != "set" and attributes["cmd"] != "del" and attributes["cmd"] != "hget" and attributes["cmd"] != "hset" and attributes["cmd"] != "hgetall" and attributes["cmd"] != "lpush" and attributes["cmd"] != "rpop" and attributes["cmd"] != "zadd" and attributes["cmd"] != "expire"'
    - 'metric.name == "redis.cmd.usec" and attributes["cmd"] != "get" and attributes["cmd"] != "set" and attributes["cmd"] != "del" and attributes["cmd"] != "hget" and attributes["cmd"] != "hset" and attributes["cmd"] != "hgetall" and attributes["cmd"] != "lpush" and attributes["cmd"] != "rpop" and attributes["cmd"] != "zadd" and attributes["cmd"] != "expire"'
    transform/metadata_nullify:
    metric_statements:
    - context: metric
    statements:
    - set(description, "")
    - set(unit, "")
    batch:
    send_batch_size: 2048
    send_batch_max_size: 4096
    timeout: 10s
    exporters:
    otlp_http:
    endpoint: ${env:OTEL_EXPORTER_OTLP_ENDPOINT}
    headers:
    api-key: ${env:NEW_RELIC_LICENSE_KEY}
    compression: gzip
    service:
    extensions: [health_check]
    pipelines:
    metrics/redis:
    receivers: [prometheus]
    processors: [memory_limiter, resource_detection, resource/redis_identity, attributes/entity_tags, metricstransform, cumulativetodelta, filter/cardinality, transform/metadata_nullify, batch]
    exporters: [otlp_http]

    この設定で行うこと

    パイプラインの各コンポーネントには特定の役割があります:

    コンポーネント説明
    health_checkコレクターが実行されていることを確認できるように、0.0.0.0:13133でヘルスエンドポイントを公開します。
    prometheus レシーバー10秒ごとにredis_exporterエンドポイント(デフォルトはlocalhost:9121)をスクレイピングし、エクスポーター自身のgo_*process_*promhttp_*、およびredis_exporter_*メトリクスを破棄します。
    memory_limiterホストを保護するために、コレクターのメモリ使用量を制限します(512 MiBのソフトリミット、128 MiBのスパイク)。
    resource_detectionホストを検出し、host.namehost.idを追加して、Redisメトリクスを基盤となるホストエンティティにリンクします。
    resource/redis_identityNew RelicでRedisエンティティを識別するredis.instance.idを設定します。Prometheusレシーバーはserver.addressserver.portを提供しないため、ここではこれが必要です。
    attributes/entity_tagsクエリをOpenTelemetryパスにスコープできるように、すべてのメトリクスにinstrumentation.provider: opentelemetryをスタンプします。
    metricstransformエクスポーターのPrometheusメトリクス(たとえばredis_uptime_in_seconds)をNew RelicのRedis名(redis.uptime)に名前変更し、CPUメトリクスにstateラベルを追加します。
    cumulativetodeltaNew Relicがレートを正確にグラフ化できるように、累積カウンター — コマンド、キースペースヒット、エビクションなど — をデルタ値に変換します。
    filter/cardinality取り込みコストを制御するために、高いカーディナリティのデータポイント(usersys以外のCPUステータス、および一般的ではないコマンドのコマンドごとのメトリクス)をドロップします。
    transform/metadata_nullifyペイロードのサイズを縮小するために、メトリクスの説明と単位をクリアします。
    batchネットワークのオーバーヘッドを削減するために、エクスポートする前にデータポイントをグループ化し(バッチあたり2,048、最大4,096)、少なくとも10秒ごとにフラッシュします。
    otlp_http処理されたメトリクスを、ライセンスキーで認証し、gzip圧縮を使用してOTLP経由でNew Relicにエクスポートします。

    重要

    Prometheusレシーバーのアプローチでは、redis.instance.idを使用するresource/redis_identityプロセッサが必須です。ネイティブのRedisレシーバーとは異なり、Prometheusレシーバーはserver.addressserver.portを提供しないため、New RelicでRedisエンティティを識別する唯一の方法はredis.instance.idです。各インスタンスに対して、一意で分かりやすい名前(例:prod-redis-cache:6379)を設定します。

オプション:Redis Clusterの監視を有効にする

RedisがClusterモードで実行されている場合、すべてのノードからクラスタのヘルスメトリクスを自動的に収集するために、--is-clusterフラグを付けてredis_exporterを開始します:

bash
$
redis_exporter --redis.addr=redis://localhost:7000 --is-cluster

上記のPrometheusレシーバーの設定では、すでにクラスタメトリクスの名前が変更されています(例:redis_cluster_stateredis.cluster.state)。New Relicで別のクラスタエンティティを作成するには、redis.instance.idを含まない別のパイプラインredis.cluster.nameリソース属性を追加します:

resource/cluster:
attributes:
- key: redis.cluster.name
value: "my-redis-cluster" # Update with your cluster name
action: upsert

サービスセクションにクラスタパイプラインを追加します:

metrics/cluster:
receivers: [prometheus]
processors: [memory_limiter, resource_detection, resource/cluster, attributes/entity_tags, metricstransform, cumulativetodelta, filter/cardinality, transform/metadata_nullify, batch]
exporters: [otlp_http]

重要

クラスタエンティティは、redis.cluster.nameが存在し、かつredis.instance.idが存在しないことを必要とします。両方が同じメトリクスに設定されている場合、インスタンスエンティティのみが作成されます。インスタンスとクラスタのメトリクスには、別々のパイプラインを使用します。

オプション:Redisログの収集

メトリクスに加えて、コレクターはRedisのログファイルをNew Relicに転送できるため、ログイベント — 再起動、永続化イベント、またはエラー — を同じエンティティ上のメトリクスのスパイクと関連付けることができます。Redisのログをテールするには、filelogレシーバーを追加します:

receivers:
# ... existing prometheus receiver ...
file_log/redis:
include:
- /var/log/redis/redis-server.log
start_at: end
operators:
- type: regex_parser
regex: '^\d+:[XCSM] \d+ \w+ \d+ \d+:\d+:\d+\.\d+ (?P<level>.) '
on_error: send
resource:
db.system: redis

ファイルからのログ行には、それ自体にRedis接続コンテキストがありません—New RelicがログをRedisエンティティに関連付けるように、ID属性を明示的にアタッチする必要があります。RedisエンティティのIDに一致するハードコードされた値を使用して、resource/redis_logsプロセッサを追加します:

processors:
# ... existing processors ...
resource/redis_logs:
attributes:
- key: redis.instance.id
value: "my-redis-instance:6379" # Must match the value in resource/redis_identity
action: upsert
- key: instrumentation.provider
value: opentelemetry
action: upsert

serviceセクションに別のログパイプラインを追加します:

service:
pipelines:
metrics/redis:
receivers: [prometheus]
processors: [memory_limiter, resource_detection, resource/redis_identity, attributes/entity_tags, metricstransform, cumulativetodelta, filter/cardinality, transform/metadata_nullify, batch]
exporters: [otlp_http]
logs/redis:
receivers: [file_log/redis]
processors: [memory_limiter, resource/redis_logs, batch]
exporters: [otlp_http]

重要

コレクターは、Redisログファイルとその親ディレクトリの両方に対する読み取りアクセス権を持っている必要があります。以下を実行します。

bash
$
sudo chmod 755 /var/log/redis
$
sudo chmod 644 /var/log/redis/redis-server.log

オプション:ホストメトリクスの収集

Redisのパフォーマンスは、多くの場合、ホストのリソースの圧迫 — CPUの飽和、メモリの枯渇、またはディスクI/Oの競合に連動します。Redisと一緒にホストからシステムメトリクスを収集するためにhostmetricsレシーバーを追加し、New Relicで2つを関連付けることができるようにします:

receivers:
# ... existing receivers ...
host_metrics:
collection_interval: 10s
scrapers:
cpu:
metrics:
system.cpu.utilization: {enabled: true}
system.cpu.time: {enabled: true}
load:
metrics:
system.cpu.load_average.1m: {enabled: true}
system.cpu.load_average.5m: {enabled: true}
system.cpu.load_average.15m: {enabled: true}
memory:
metrics:
system.memory.usage: {enabled: true}
system.memory.utilization: {enabled: true}
disk:
metrics:
system.disk.io: {enabled: true}
system.disk.operations: {enabled: true}
filesystem:
metrics:
system.filesystem.usage: {enabled: true}
system.filesystem.utilization: {enabled: true}
network:
metrics:
system.network.io: {enabled: true}
system.network.packets: {enabled: true}

ホストメトリクス用に別のmetrics/hostパイプラインを追加します(Redisパイプラインにhost_metricsを追加しないでください):

service:
pipelines:
metrics/redis:
receivers: [prometheus]
processors: [memory_limiter, resource_detection, resource/redis_identity, attributes/entity_tags, metricstransform, cumulativetodelta, filter/cardinality, transform/metadata_nullify, batch]
exporters: [otlp_http]
metrics/host:
receivers: [host_metrics]
processors: [memory_limiter, resource_detection, attributes/entity_tags, cumulativetodelta, batch]
exporters: [otlp_http]

環境変数と設定パスを設定する

コレクターは、デプロイメント固有の値 — ライセンスキー、OTLPエンドポイント、および設定パス — を環境ファイルから読み取ります。これにより、設定YAMLからシークレットを排除できます。インストールしたコレクターに合わせてこれらを設定します:

変数必須説明
NEW_RELIC_LICENSE_KEYはいNew Relic取り込みライセンスキー
OTEL_EXPORTER_OTLP_ENDPOINTはいご利用のリージョンのNew Relic OTLPエンドポイント。詳細については、New Relic OTLPエンドポイントを参照してください。
OTELCOL_OPTIONSはいコレクターにRedis Prometheus設定ファイルを指定します。

NRDOTの場合:

bash
$
sudo tee /etc/nrdot-collector/nrdot-collector.conf > /dev/null <<'EOF'
$
NEW_RELIC_LICENSE_KEY=YOUR_LICENSE_KEY
$
OTEL_EXPORTER_OTLP_ENDPOINT=YOUR_OTLP_ENDPOINT
$
# Set the New Relic OTLP endpoint for your region.
$
# See https://docs.newrelic.com/docs/opentelemetry/best-practices/opentelemetry-otlp
$
OTELCOL_OPTIONS="--config=/etc/nrdot-collector/redis-prometheus-config.yaml"
$
EOF
$
sudo chmod 600 /etc/nrdot-collector/nrdot-collector.conf

ヒント

この設定は、デフォルトのNRDot設定を置き換えます。Redis監視と並行してデフォルトのNRDotパイプラインを保持する必要がある場合は、デフォルトの設定ファイルも追加してください:

bash
$
OTELCOL_OPTIONS="--config=/etc/nrdot-collector/config.yaml --config=/etc/nrdot-collector/redis-prometheus-config.yaml"

複数の設定ファイルを使用する場合は、それらの間でコンポーネント名が競合していないことを確認してください。サフィックスを追加して、Redis設定内の重複するプロセッサの名前を変更します(例:memory_limiterの代わりにmemory_limiter/redis)。

OTel Collector Contribの場合:

bash
$
sudo tee /etc/otelcol-contrib/otelcol-contrib.conf > /dev/null <<'EOF'
$
NEW_RELIC_LICENSE_KEY=YOUR_LICENSE_KEY
$
OTEL_EXPORTER_OTLP_ENDPOINT=YOUR_OTLP_ENDPOINT
$
# Set the New Relic OTLP endpoint for your region.
$
# See https://docs.newrelic.com/docs/opentelemetry/best-practices/opentelemetry-otlp
$
OTELCOL_OPTIONS="--config=/etc/otelcol-contrib/redis-prometheus-config.yaml"
$
EOF
$
sudo chmod 600 /etc/otelcol-contrib/otelcol-contrib.conf

再起動して確認します

新しい設定を読み込むにはコレクターを再起動します。

NRDOTの場合:

bash
$
sudo systemctl daemon-reload
$
sudo systemctl restart nrdot-collector
$
sudo systemctl status nrdot-collector

OTel Collector Contribの場合:

bash
$
sudo systemctl daemon-reload
$
sudo systemctl restart otelcol-contrib
$
sudo systemctl status otelcol-contrib

statusコマンドはActive: active (running)を表示するはずです。Active: failedと表示される場合は、journalctl -u nrdot-collector -n 100 --no-pager(またはotelcol-contrib)でログを確認してください — 最も一般的な原因は、YAMLのインデントエラー、到達不可能なredis_exporter、またはエクスポーターが実行されていないことです。

次に、メトリクスがNew Relicに到達していることを確認します。再起動後約1分待ってから、クエリビルダーで次のクエリを実行します:

SELECT count(*) FROM Metric WHERE metricName LIKE 'redis.%' AND instrumentation.provider = 'opentelemetry' SINCE 5 minutes ago

ゼロ以外のカウントにより、Redisメトリクスが流れていることが確認できます。0が返される場合は、Redisのトラブルシューティング(OpenTelemetry)を参照してください。

ヒント

APMとRedisを関連付ける: サービスマップでAPMアプリケーションとRedisインスタンスを接続するには、選択したエンティティ識別子パターン — redis.instance.id、またはserver.addressserver.portのいずれか — とともにdb.system="redis"をAPMメトリクスのリソース属性として含めます。この値は、コレクターで設定したものと一致する必要があります。これにより、New Relic内でのサービス間の可視性が向上し、トラブルシューティングが迅速化されます。

次のステップ

Copyright © 2026 New Relic株式会社。

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.