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

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

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

問題を作成する

Prometheusレシーバーを使用してKubernetes上のElasticsearchをモニターする

|View as Markdown (English)

このページでは、クラスタ内で実行されている既存のPrometheus Elasticsearch exporterを介してElasticsearchをモニターするように、KubernetesにデプロイされたOpenTelemetry CollectorのPrometheusレシーバーを設定します。このパスは、すでにそのエクスポーターを実行している場合、またはPrometheusベースの監視スタックから移行している場合にのみ使用してください。そうでない場合は、ポッドの自動検出を使用してElasticsearch APIに直接接続し、追加のコンポーネントを必要としないNRDOT(マニフェストのインストールまたはHelmのインストール)、またはOTel Collector Contribを代わりに使用してください。

互換性と要件

サポート対象

  • Kubernetesクラスタ内のポッドとして実行され、elasticsearch_exporter 1.x経由でモニターされるElasticsearch 7.16以降
  • エクスポーターとコレクターの両方に対するHelm 3.xのインストール方法

サポートされていない

  • 自動ポッド検出:このパスは、Elasticsearchのポッドを直接検出するのではなく、単一のエクスポーターのエンドポイントをスクレイピングします。

必要なこと

始める前に、以下があることを確認してください:

Elasticsearch エクスポーターをインストールして設定する

Prometheus Elasticsearchエクスポーターをクラスタにデプロイしてください。これは、ポート9114でPrometheus形式のElasticsearchメトリクスを公開します。

  1. Elasticsearchエクスポーターがまだ実行されていない場合は、デプロイします:

    bash
    $
    helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
    $
    helm repo update
    $
    helm install elasticsearch-exporter prometheus-community/prometheus-elasticsearch-exporter \
    >
    --namespace monitoring \
    >
    --create-namespace \
    >
    --set es.uri=http://elasticsearch.default.svc.cluster.local:9200

    elasticsearch.default.svc.cluster.local:9200をElasticsearchサービスアドレスに置き換えてください。

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

    bash
    $
    kubectl get pods -n monitoring -l app=prometheus-elasticsearch-exporter

認証情報シークレットの作成

コレクターがNew Relicにデータを送信するために必要な認証情報シークレットを作成してください。シークレットは、monitoringネームスペースに配置します。前のステップでエクスポーターをデプロイしなかったために、そのネームスペースがまだ存在しない場合は、まずkubectl create namespace monitoringを使用して作成してください。

bash
$
kubectl create secret generic newrelic-credentials \
>
--namespace monitoring \
>
--from-literal=NEWRELIC_LICENSE_KEY=YOUR_LICENSE_KEY_HERE \
>
--from-literal=NEWRELIC_OTLP_ENDPOINT=<YOUR_OTLP_ENDPOINT>

ヒント

米国アカウントの場合は、NEWRELIC_OTLP_ENDPOINT=https://otlp.nr-data.net:4318を使用してください。EUアカウントの場合は、NEWRELIC_OTLP_ENDPOINT=https://otlp.eu01.nr-data.net:4318を使用してください。

コレクターConfigMapを作成する

コレクターの設定を含むConfigMapを作成してください。これにより、エクスポーターのPrometheusメトリクス名が、New Relic Elasticsearchダッシュボードを機能させるOTelスタイルの名前にマッピングされます。次をotel-collector-prometheus-es.yamlとして保存し、<elasticsearch-cluster-name>とエクスポーターのサービスアドレスを更新してください:

apiVersion: v1
kind: ConfigMap
metadata:
name: otel-collector-prometheus-es
namespace: monitoring
data:
config.yaml: |
receivers:
prometheus/elasticsearch:
config:
scrape_configs:
- job_name: 'elasticsearch'
scrape_interval: 15s
static_configs:
- targets: ['elasticsearch-exporter-prometheus-elasticsearch-exporter.monitoring.svc.cluster.local:9114']
processors:
memory_limiter:
check_interval: 60s
limit_mib: 100
metricstransform/prom_to_otel:
transforms:
- include: ^elasticsearch_cluster_health_number_of_data_nodes$
match_type: regexp
action: update
new_name: elasticsearch.cluster.data_nodes
- include: ^elasticsearch_cluster_health_status$
match_type: regexp
action: update
new_name: elasticsearch.cluster.health
operations:
- action: update_label
label: color
new_label: status
- include: ^elasticsearch_cluster_health_number_of_in_flight_fetch$
match_type: regexp
action: update
new_name: elasticsearch.cluster.in_flight_fetch
- include: ^elasticsearch_cluster_health_number_of_nodes$
match_type: regexp
action: update
new_name: elasticsearch.cluster.nodes
- include: ^elasticsearch_cluster_health_number_of_pending_tasks$
match_type: regexp
action: update
new_name: elasticsearch.cluster.pending_tasks
- include: ^elasticsearch_cluster_health_active_shards$
match_type: regexp
action: update
new_name: elasticsearch.cluster.shards
operations:
- action: add_label
new_label: state
new_value: active
- include: ^elasticsearch_cluster_health_unassigned_shards$
match_type: regexp
action: update
new_name: elasticsearch.cluster.shards
operations:
- action: add_label
new_label: state
new_value: unassigned
- include: ^elasticsearch_indices_docs$
match_type: regexp
action: insert
new_name: elasticsearch.node.documents
operations:
- action: add_label
new_label: state
new_value: active
- include: ^elasticsearch_indices_docs$
match_type: regexp
action: insert
new_name: elasticsearch.index.documents
operations:
- action: add_label
new_label: state
new_value: active
- action: add_label
new_label: aggregation
new_value: primary_shards
- action: add_label
new_label: elasticsearch.index.name
new_value: _all
- include: ^elasticsearch_indices_fielddata_evictions$
match_type: regexp
action: update
new_name: elasticsearch.node.cache.evictions
operations:
- action: add_label
new_label: cache_name
new_value: fielddata
- include: ^elasticsearch_indices_query_cache_evictions$
match_type: regexp
action: update
new_name: elasticsearch.node.cache.evictions
operations:
- action: add_label
new_label: cache_name
new_value: query
- include: ^elasticsearch_transport_rx_size_bytes_total$
match_type: regexp
action: update
new_name: elasticsearch.node.cluster.io
operations:
- action: add_label
new_label: direction
new_value: received
- include: ^elasticsearch_transport_tx_size_bytes_total$
match_type: regexp
action: update
new_name: elasticsearch.node.cluster.io
operations:
- action: add_label
new_label: direction
new_value: sent
- include: ^elasticsearch_filesystem_data_available_bytes$
match_type: regexp
action: update
new_name: elasticsearch.node.fs.disk.available
- include: ^elasticsearch_filesystem_data_size_bytes$
match_type: regexp
action: update
new_name: elasticsearch.node.fs.disk.total
- include: ^elasticsearch_indices_indexing_index_total$
match_type: regexp
action: update
new_name: elasticsearch.node.operations.completed
operations:
- action: add_label
new_label: operation
new_value: index
- include: ^elasticsearch_indices_search_query_total$
match_type: regexp
action: update
new_name: elasticsearch.node.operations.completed
operations:
- action: add_label
new_label: operation
new_value: query
- include: ^elasticsearch_indices_get_total$
match_type: regexp
action: update
new_name: elasticsearch.node.operations.completed
operations:
- action: add_label
new_label: operation
new_value: get
- include: ^elasticsearch_indices_merges_total$
match_type: regexp
action: update
new_name: elasticsearch.node.operations.completed
operations:
- action: add_label
new_label: operation
new_value: merge
- include: ^elasticsearch_indices_indexing_index_time_seconds_total$
match_type: regexp
action: update
new_name: elasticsearch.node.operations.time
operations:
- action: add_label
new_label: operation
new_value: index
- action: experimental_scale_value
experimental_scale: 1000
- include: ^elasticsearch_indices_search_query_time_seconds$
match_type: regexp
action: update
new_name: elasticsearch.node.operations.time
operations:
- action: add_label
new_label: operation
new_value: query
- action: experimental_scale_value
experimental_scale: 1000
- include: ^elasticsearch_os_cpu_percent$
match_type: regexp
action: update
new_name: elasticsearch.os.cpu.usage
- include: ^elasticsearch_jvm_gc_collection_seconds_count$
match_type: regexp
action: update
new_name: jvm.gc.collections.count
- include: ^elasticsearch_jvm_memory_max_bytes$
match_type: regexp
action: update
new_name: jvm.memory.heap.max
- include: ^elasticsearch_jvm_memory_used_bytes$
match_type: regexp
action: update
new_name: jvm.memory.heap.used
- include: ^elasticsearch_thread_pool_threads_count$
match_type: regexp
action: update
new_name: jvm.threads.count
operations:
- action: aggregate_labels
label_set: [name, cluster]
aggregation_type: sum
- include: ^elasticsearch_indices_segments_count$
match_type: regexp
action: update
new_name: elasticsearch.index.segments.count
filter/allowed_metrics:
metrics:
include:
match_type: strict
metric_names:
- elasticsearch.cluster.data_nodes
- elasticsearch.cluster.health
- elasticsearch.cluster.in_flight_fetch
- elasticsearch.cluster.nodes
- elasticsearch.cluster.pending_tasks
- elasticsearch.cluster.shards
- elasticsearch.index.documents
- elasticsearch.index.segments.count
- elasticsearch.node.cache.evictions
- elasticsearch.node.cluster.io
- elasticsearch.node.documents
- elasticsearch.node.fs.disk.available
- elasticsearch.node.fs.disk.total
- elasticsearch.node.operations.completed
- elasticsearch.node.operations.time
- elasticsearch.os.cpu.usage
- jvm.gc.collections.count
- jvm.memory.heap.max
- jvm.memory.heap.used
- jvm.threads.count
transform/rename_node_name:
metric_statements:
- context: datapoint
statements:
- set(attributes["elasticsearch.node.name"], attributes["name"]) where attributes["name"] != nil
- delete_key(attributes, "name") where attributes["elasticsearch.node.name"] != nil
groupbyattrs/node:
keys:
- elasticsearch.node.name
- elasticsearch.cluster.name
cumulativetodelta: {}
resource/cluster_name_override:
attributes:
- key: elasticsearch.cluster.name
value: "<elasticsearch-cluster-name>"
action: upsert
transform/scope_override:
metric_statements:
- context: scope
statements:
- set(name, "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/elasticsearchreceiver")
- set(version, "")
resourcedetection:
detectors: [env]
env:
resource_attributes:
host.name:
enabled: true
batch:
timeout: 30s
send_batch_size: 2048
send_batch_max_size: 4096
attributes/cardinality_reduction:
actions:
- key: process.pid
action: delete
- key: process.parent_pid
action: delete
transform/metadata_nullify:
metric_statements:
- context: metric
statements:
- set(description, "")
- set(unit, "")
exporters:
otlphttp:
endpoint: ${env:NEWRELIC_OTLP_ENDPOINT}
headers:
api-key: ${env:NEWRELIC_LICENSE_KEY}
compression: gzip
timeout: 30s
retry_on_failure:
enabled: true
initial_interval: 5s
max_interval: 30s
max_elapsed_time: 300s
service:
pipelines:
metrics/elasticsearch:
receivers: [prometheus/elasticsearch]
processors:
- memory_limiter
- metricstransform/prom_to_otel
- filter/allowed_metrics
- transform/rename_node_name
- groupbyattrs/node
- transform/scope_override
- resourcedetection
- resource/cluster_name_override
- attributes/cardinality_reduction
- cumulativetodelta
- transform/metadata_nullify
- batch
exporters: [otlphttp]

適用します:

bash
$
kubectl apply -f otel-collector-prometheus-es.yaml

設定パラメーター

次の表では、上記のConfigMapで使用される主要な設定パラメーターについて説明します。

パラメータ説明
targetselasticsearch_exporterサービスのアドレスです。エクスポーターのKubernetesサービスのアドレスと一致するように更新してください。
elasticsearch-cluster-name ( resource/cluster_name_override内)New Relicでこのクラスタを識別する一意の名前です。<elasticsearch-cluster-name>をアカウント全体で一意の名前に置き換えてください。
NEWRELIC_LICENSE_KEY上記の認証情報シークレットで設定された、New Relicのライセンスキー。
NEWRELIC_OTLP_ENDPOINT上記の認証情報シークレットで設定された、アカウントのリージョン用のNew Relic OTLPエンドポイント。New Relic OTLPエンドポイントを参照してください。

コレクターをデプロイする

コレクターをデプロイします。OTel Collector ContribよりもNRDOTを優先する場合は、以下のimageフィールドをnewrelic/nrdot-collector:latestに更新してください。otel-collector-deployment.yamlとして保存し、kubectl apply -f otel-collector-deployment.yamlを使用して適用します:

apiVersion: apps/v1
kind: Deployment
metadata:
name: otel-collector-elasticsearch
namespace: monitoring
labels:
app: otel-collector-elasticsearch
spec:
replicas: 1
selector:
matchLabels:
app: otel-collector-elasticsearch
template:
metadata:
labels:
app: otel-collector-elasticsearch
spec:
containers:
- name: otel-collector
image: otel/opentelemetry-collector-contrib:latest
args:
- "--config=/etc/otel/config.yaml"
env:
- name: NEWRELIC_LICENSE_KEY
valueFrom:
secretKeyRef:
name: newrelic-credentials
key: NEWRELIC_LICENSE_KEY
- name: NEWRELIC_OTLP_ENDPOINT
valueFrom:
secretKeyRef:
name: newrelic-credentials
key: NEWRELIC_OTLP_ENDPOINT
volumeMounts:
- name: config
mountPath: /etc/otel
resources:
requests:
memory: "128Mi"
cpu: "100m"
limits:
memory: "256Mi"
cpu: "500m"
volumes:
- name: config
configMap:
name: otel-collector-prometheus-es

インストールの確認

デプロイメントを適用してから約5分以内に、New Relicでこのクエリを実行して、データが流れていることを確認します(<elasticsearch-cluster-name>をクラスタ名に置き換えます):

FROM Metric SELECT count(*)
WHERE metricName LIKE 'elasticsearch.%'
AND elasticsearch.cluster.name = '<elasticsearch-cluster-name>'
SINCE 10 minutes ago

ヒント

コレクター自体を確認することもできます:ポッドが実行中であり(kubectl get pods -n monitoring -l app=otel-collector-elasticsearch)、ポッドのログに接続エラーがないはずです(kubectl logs -n monitoring -l app=otel-collector-elasticsearch -f)。

約5分経過してもデータが表示されない場合は、Kubernetesのトラブルシューティングをご覧ください。

データを探す、使う

New Relicがデータを収集すると、New Relic UIを通じてElasticsearchの監視にアクセスできるようになります。

New RelicでElasticsearchダッシュボードを見つけるには:

  1. one.newrelic.com > Integrations & Agentsに移動します。
  2. AllタブでDashboardsをクリックし、Elasticsearch (OpenTelemetry Collector)を検索してダッシュボードを表示します。

または、左側のナビゲーションから:

  1. Dashboardsをクリックします。
  2. Elasticsearch (OpenTelemetry Collector)ダッシュボードを検索して表示します。

Elasticsearchの監視を設定した後は、次のことができます:

ヒント

APMとElasticsearchの関連付け:APMアプリケーションとElasticsearchクラスタを接続するには、APMメトリクスにリソース属性es.cluster.name="your-cluster-name"を含めてください。これにより、New RelicでAPMとElasticsearchのデータを一緒に表示できるようになります。

Copyright © 2026 New Relic株式会社。

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