自動ポッド検出機能を備えたOpenTelemetry Collectorデプロイすることで、 KubernetesのElasticsearchクラスタを監視します。 この統合では、 elasticsearchreceiverとreceivercreatorを使用して、手動設定なしでElasticsearch自動的に検出および監視します。
まず、Kubernetes環境に最適なコレクターディストリビューションを選択してください。
You can choose between three collector options:
- NRDOT: OpenTelemetryのNew Relicディストリビューション
- OTel Collector Contrib:コミュニティ提供のコンポーネントを備えた標準のOpenTelemetry Collector
- Prometheus Receiver: For environments already running a Prometheus Elasticsearch exporter
インストールオプション
ニーズに合ったコレクターの分配方法を選択してください。
あなたが始める前に
Before deploying the NRDOT collector on Kubernetes, ensure you have:
必要なアクセス権限:
あなたのNew Relic
Kubernetesクラスターへのkubectlアクセス
monitorまたはmanage権限を持つElasticsearchクラスタ管理者権限 (詳細については、 Elasticsearchセキュリティ権限のドキュメントを参照してください)システム要件:
Elasticsearchバージョン 7.16 以降- この統合には最新のElasticsearchクラスタが必要です
Kubernetesクラスター- Elasticsearchがデプロイされている稼働中のKubernetesクラスター
ネットワーク接続- New RelicのOTLP取り込みエンドポイントへのHTTPSアウトバウンド接続(ポート443)
Elasticsearch要件:
ポッド ラベル (必須) - 自動検出が機能するには、各Elasticsearchにラベル
app: elasticsearchが必要です。 このラベルがないと、コレクターはポッドを検出または監視できません。重要
Elasticsearchにラベルを追加する方法:
Elasticsearchに StatefulSet またはデプロイメントを使用している場合は、ポッド テンプレートにラベルを追加します。
apiVersion: apps/v1kind: StatefulSetmetadata:name: elasticsearchspec:template:metadata:labels:app: elasticsearch # Required for auto-discoveryspec:containers:- name: elasticsearchimage: docker.elastic.co/elasticsearch/elasticsearch:8.x.xラベルのない既存のポッドの場合は、StatefulSet/デプロイメントを更新し、ポッドを再起動します。
bash$kubectl label pods -l <your-existing-selector> app=elasticsearch -n <namespace>ラベルが正しく設定されているかどうかを確認できます。
bash$kubectl get pods -n <namespace> --show-labels
設置方法をお選びください
You can install the NRDOT Collector using Kubernetes manifests or Helm charts. Choose the method that best fits your workflow:
Manifest install:
More control over individual Kubernetes resources
Requires completing the base Kubernetes OpenTelemetry manifest installation first
Best for customized deployments
Helm install:
Simpler deployment with single command
Easier to manage and upgrade
Best for standard deployments
Proceed to the next step for detailed instructions for your chosen method.
Install and configure NRDOT Collector
デプロイメントとデータ収集を検証する
Verify that the NRDOT collector is running and collecting Elasticsearch data:
コレクターポッドが稼働していることを確認してください。
bash$kubectl get pods -n newrelic --watchFor manifest install: You should see pods with names like
nr-k8s-otel-collector-deployment-<hash>in aRunningstate.For Helm install: You should see pods with names like
elasticsearch-nrdot-collector-<hash>in aRunningstate.コレクターログにエラーがないか確認してください。
For manifest install:
bash$kubectl logs -n newrelic -l app.kubernetes.io/name=nr-k8s-otel-collector -fFor Helm install:
bash$kubectl logs -n newrelic -l app.kubernetes.io/name=opentelemetry-collector -fElasticsearchとNew Relicへの接続が成功していることを確認してください。 エラーが表示された場合は、トラブルシューティングガイドを参照してください。
New RelicでNRQL実行して、データが到着していることを確認します (
elasticsearch-clusterクラスタ名に置き換えます)。FROM MetricSELECT *WHERE metricName LIKE 'elasticsearch.%'AND instrumentation.provider = 'opentelemetry'AND k8s.cluster.name = 'elasticsearch-cluster'SINCE 10 minutes ago
あなたが始める前に
KubernetesにOTel Collector Contribをデプロイする前に、以下のものを用意してください。
必要なアクセス権限:
あなたのNew Relic
Kubernetesクラスターへのkubectlアクセス
monitorまたはmanage権限を持つElasticsearchクラスタ管理者権限 (詳細については、 Elasticsearchセキュリティ権限のドキュメントを参照してください)システム要件:
Elasticsearchバージョン 7.16 以降- この統合には最新のElasticsearchクラスタが必要です
Kubernetesクラスター- Elasticsearchがデプロイされている稼働中のKubernetesクラスター
Helm 3.0以降- システムにHelmがインストールされていること
ネットワーク接続- New RelicのOTLP取り込みエンドポイントへのHTTPSアウトバウンド接続(ポート443)
Elasticsearch要件:
ポッド ラベル (必須) - 自動検出が機能するには、各Elasticsearchにラベル
app: elasticsearchが必要です。 このラベルがないと、コレクターはポッドを検出または監視できません。重要
Elasticsearchにラベルを追加する方法:
Elasticsearchに StatefulSet またはデプロイメントを使用している場合は、ポッド テンプレートにラベルを追加します。
apiVersion: apps/v1kind: StatefulSetmetadata:name: elasticsearchspec:template:metadata:labels:app: elasticsearch # Required for auto-discoveryspec:containers:- name: elasticsearchimage: docker.elastic.co/elasticsearch/elasticsearch:8.x.xラベルのない既存のポッドの場合は、StatefulSet/デプロイメントを更新し、ポッドを再起動します。
bash$kubectl label pods -l <your-existing-selector> app=elasticsearch -n <namespace>ラベルが正しく設定されているかどうかを確認できます。
bash$kubectl get pods -n <namespace> --show-labels
資格情報用のKubernetesシークレットを作成する
New Relicの認証情報を安全に保存するためのKubernetesシークレットを作成します。
ネームスペースを作成します。
bash$kubectl create namespace newrelic秘密を作り出す:
bash$kubectl create secret generic newrelic-licenses \>--from-literal=NEWRELIC_LICENSE_KEY=YOUR_LICENSE_KEY_HERE \>--from-literal=NEWRELIC_OTLP_ENDPOINT=https://otlp.nr-data.net:4318 \>--from-literal=NEW_RELIC_MEMORY_LIMIT_MIB=100 \>-n newrelic値を更新します:
YOUR_LICENSE_KEY_HERE実際の New Relic ライセンスキーに置き換えてください。https://otlp.nr-data.net:4318地域のエンドポイントに置き換えます (OTLP エンドポイントのドキュメントを参照してください)。100コレクターの希望するメモリ制限値(MiB単位)に置き換えてください(デフォルト:100 MiB)。環境のニーズに合わせて調整してください
Elasticsearchの監視を設定する
Elasticsearchの監視用にOpenTelemetry Collectorを設定するためのvalues.yamlファイルを作成します。
ヒント
環境に合わせてカスタマイズしてください。設定ファイル内の以下の値を更新してください。
必要な変更点:
ポッド ラベル ルール- ルール
labels["app"] == "elasticsearch"はポッド ラベルと一致する必要があります。 Elasticsearchポッドが異なるラベル(例:app: es-cluster)を使用している場合は、ルールをそれに応じて更新してください。rule: type == "pod" && labels["app"] == "es-cluster"Cluster名- New Relicでクラスターを識別するために、
elasticsearch-cluster一意の名前に置き換えます。 この名前は、New Relic UI で Elasticsearch エンティティを作成および識別するために使用されます。New Relicアカウント全体で一意の名前を選択してください(例:prod-es-k8s、staging-elasticsearch)。オプションの変更点:
ポート- Elasticsearchが別のポートで実行されている場合は、
9200を更新してください。認証- Elasticsearch クラスターが保護されている場合は、認証情報を追加してください。
mode: deployment
image: repository: otel/opentelemetry-collector-contrib pullPolicy: IfNotPresent
command: name: otelcol-contrib
resources: limits: cpu: 500m memory: 512Mi requests: cpu: 200m memory: 256Mi
extraEnvs: - name: NEWRELIC_LICENSE_KEY valueFrom: secretKeyRef: name: newrelic-licenses key: NEWRELIC_LICENSE_KEY - name: NEWRELIC_OTLP_ENDPOINT valueFrom: secretKeyRef: name: newrelic-licenses key: NEWRELIC_OTLP_ENDPOINT - name: NEW_RELIC_MEMORY_LIMIT_MIB valueFrom: secretKeyRef: name: newrelic-licenses key: NEW_RELIC_MEMORY_LIMIT_MIB - name: K8S_CLUSTER_NAME value: "elasticsearch-cluster"
clusterRole: create: true rules: - apiGroups: [""] resources: ["pods", "nodes", "nodes/stats", "nodes/proxy"] verbs: ["get", "list", "watch"] - apiGroups: ["apps"] resources: ["replicasets"] verbs: ["get", "list", "watch"]
config: extensions: health_check: endpoint: 0.0.0.0:13133 k8s_observer: auth_type: serviceAccount observe_pods: true observe_nodes: true
receivers: receiver_creator/elasticsearch: watch_observers: [k8s_observer] receivers: elasticsearch: rule: type == "pod" && labels["app"] == "elasticsearch" config: endpoint: 'http://`endpoint`:9200' collection_interval: 30s metrics: elasticsearch.os.cpu.usage: enabled: true elasticsearch.cluster.data_nodes: enabled: true elasticsearch.cluster.health: enabled: true elasticsearch.cluster.in_flight_fetch: enabled: true elasticsearch.cluster.nodes: enabled: true elasticsearch.cluster.pending_tasks: enabled: true elasticsearch.cluster.shards: enabled: true elasticsearch.cluster.state_update.time: enabled: true elasticsearch.index.documents: enabled: true elasticsearch.index.operations.merge.current: enabled: true elasticsearch.index.operations.time: enabled: true elasticsearch.node.cache.count: enabled: true elasticsearch.node.cache.evictions: enabled: true elasticsearch.node.cache.memory.usage: enabled: true elasticsearch.node.shards.size: enabled: true elasticsearch.node.cluster.io: enabled: true elasticsearch.node.documents: enabled: true elasticsearch.node.disk.io.read: enabled: true elasticsearch.node.disk.io.write: enabled: true elasticsearch.node.fs.disk.available: enabled: true elasticsearch.node.fs.disk.total: enabled: true elasticsearch.node.http.connections: enabled: true elasticsearch.node.ingest.documents.current: enabled: true elasticsearch.node.ingest.operations.failed: enabled: true elasticsearch.node.open_files: enabled: true elasticsearch.node.operations.completed: enabled: true elasticsearch.node.operations.current: enabled: true elasticsearch.node.operations.get.completed: enabled: true elasticsearch.node.operations.time: enabled: true elasticsearch.node.shards.reserved.size: enabled: true elasticsearch.index.shards.size: enabled: true elasticsearch.os.cpu.load_avg.1m: enabled: true elasticsearch.os.cpu.load_avg.5m: enabled: true elasticsearch.os.cpu.load_avg.15m: enabled: true elasticsearch.os.memory: enabled: true jvm.gc.collections.count: enabled: true jvm.gc.collections.elapsed: enabled: true jvm.memory.heap.max: enabled: true jvm.memory.heap.used: enabled: true jvm.memory.heap.utilization: enabled: true jvm.threads.count: enabled: true elasticsearch.index.segments.count: enabled: true elasticsearch.index.operations.completed: enabled: true elasticsearch.node.script.cache_evictions: enabled: false elasticsearch.node.cluster.connections: enabled: false elasticsearch.node.pipeline.ingest.documents.preprocessed: enabled: false elasticsearch.node.thread_pool.tasks.queued: enabled: false elasticsearch.cluster.published_states.full: enabled: false jvm.memory.pool.max: enabled: false elasticsearch.node.script.compilation_limit_triggered: enabled: false elasticsearch.node.shards.data_set.size: enabled: false elasticsearch.node.pipeline.ingest.documents.current: enabled: false elasticsearch.cluster.state_update.count: enabled: false elasticsearch.node.fs.disk.free: enabled: false jvm.memory.nonheap.used: enabled: false jvm.memory.pool.used: enabled: false elasticsearch.node.translog.size: enabled: false elasticsearch.node.thread_pool.threads: enabled: false elasticsearch.cluster.state_queue: enabled: false elasticsearch.node.translog.operations: enabled: false elasticsearch.memory.indexing_pressure: enabled: false elasticsearch.node.ingest.documents: enabled: false jvm.classes.loaded: enabled: false jvm.memory.heap.committed: enabled: false elasticsearch.breaker.memory.limit: enabled: false elasticsearch.indexing_pressure.memory.total.replica_rejections: enabled: false elasticsearch.breaker.memory.estimated: enabled: false elasticsearch.cluster.published_states.differences: enabled: false jvm.memory.nonheap.committed: enabled: false elasticsearch.node.translog.uncommitted.size: enabled: false elasticsearch.node.script.compilations: enabled: false elasticsearch.node.pipeline.ingest.operations.failed: enabled: false elasticsearch.indexing_pressure.memory.limit: enabled: false elasticsearch.breaker.tripped: enabled: false elasticsearch.indexing_pressure.memory.total.primary_rejections: enabled: false elasticsearch.node.thread_pool.tasks.finished: enabled: false
processors: memory_limiter: check_interval: 60s limit_mib: ${env:NEW_RELIC_MEMORY_LIMIT_MIB} cumulativetodelta: {} resource/cluster: attributes: - key: k8s.cluster.name value: "${env:K8S_CLUSTER_NAME}" action: insert resource/cluster_name_override: attributes: - key: elasticsearch.cluster.name value: "${env:K8S_CLUSTER_NAME}" action: upsert resourcedetection: detectors: [env, system] system: resource_attributes: host.name: enabled: true host.id: enabled: true os.type: enabled: true batch: timeout: 10s send_batch_size: 1024 attributes/cardinality_reduction: actions: - key: process.pid action: delete - key: process.parent_pid action: delete - key: k8s.pod.uid 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}"
service: extensions: [health_check, k8s_observer] pipelines: metrics/elasticsearch: receivers: [receiver_creator/elasticsearch] processors: [memory_limiter, resourcedetection, resource/cluster, resource/cluster_name_override, attributes/cardinality_reduction, cumulativetodelta, transform/metadata_nullify, batch] exporters: [otlphttp]ヒント
安全なElasticsearchクラスタの場合: Elasticsearchクラスタに認証が必要な場合は、受信側の設定に認証情報を追加します。
receiver_creator/elasticsearch: watch_observers: [k8s_observer] receivers: elasticsearch: rule: type == "pod" && labels["app"] == "elasticsearch" config: endpoint: 'https://`endpoint`:9200' username: "your_elasticsearch_username" password: "your_elasticsearch_password" tls: insecure_skip_verify: false認証情報は、値ファイルにハードコーディングするのではなく、Kubernetesのシークレットを使用して安全に保存してください。
Helmでインストール
values.yamlの設定を使用して Helm で OpenTelemetry Collector をインストールします。
$helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts$helm repo update$helm upgrade --install elasticsearch-otel-collector open-telemetry/opentelemetry-collector \> --namespace newrelic \> --create-namespace \> -f values.yamlデプロイメントとデータ収集を検証する
OpenTelemetry Collectorが実行され、Elasticsearchデータを収集していることを確認してください。
コレクターポッドが稼働していることを確認してください。
bash$kubectl get pods -n newrelic --watchRunning状態では、elasticsearch-otel-collector-<hash>のような名前のポッドが表示されるはずです。コレクターログにエラーがないか確認してください。
bash$kubectl logs -n newrelic -l app.kubernetes.io/name=opentelemetry-collector -fElasticsearchとNew Relicへの接続が成功していることを確認してください。 エラーが表示された場合は、トラブルシューティングガイドを参照してください。
New RelicでNRQL実行して、データが到着していることを確認します (
elasticsearch-clusterクラスタ名に置き換えます)。FROM MetricSELECT *WHERE metricName LIKE 'elasticsearch.%'AND instrumentation.provider = 'opentelemetry'AND k8s.cluster.name = 'elasticsearch-cluster'SINCE 10 minutes ago
Use this approach if you already have a Prometheus Elasticsearch exporter running in your Kubernetes cluster, or if you're migrating from a Prometheus-based monitoring stack.
ヒント
Recommended: If you don't already have a Prometheus exporter running, use the NRDOT Collector or OTel Collector Contrib tabs instead. They connect directly to the Elasticsearch API without needing an additional exporter component.
Deploy the Elasticsearch exporter
If you don't already have the exporter running, deploy it using Helm:
$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:9200Replace elasticsearch.default.svc.cluster.local:9200 with your Elasticsearch service address.
Verify the exporter is running:
$kubectl get pods -n monitoring -l app=prometheus-elasticsearch-exporterCreate the credentials Secret
$kubectl create secret generic newrelic-credentials \> --namespace monitoring \> --from-literal=NEWRELIC_LICENSE_KEY=YOUR_NEWRELIC_LICENSE_KEY \> --from-literal=NEWRELIC_OTLP_ENDPOINT=https://otlp.nr-data.net:4318YOUR_NEWRELIC_LICENSE_KEY に置き換えます。
ヒント
For EU accounts, use NEWRELIC_OTLP_ENDPOINT=https://otlp.eu01.nr-data.net:4318
Create the collector ConfigMap
Create a ConfigMap with the collector configuration. This works with both NRDOT (newrelic/nrdot-collector) and OTel Collector Contrib (otel/opentelemetry-collector-contrib) container images. The configuration scrapes metrics from the Elasticsearch exporter and translates Prometheus metric names to OpenTelemetry-compatible names that power the New Relic Elasticsearch dashboard.
Replace the following values in the configuration:
<elasticsearch-cluster-name>: Your Elasticsearch cluster nameelasticsearch-exporter-prometheus-elasticsearch-exporter.monitoring.svc.cluster.local:9114: Your exporter's Kubernetes service address
Deploy the collector
Deploy the collector using either the NRDOT or OTel Collector Contrib image. Update the image field below based on your choice:
NRDOT:
newrelic/nrdot-collector:latestOTel Collector Contrib:
otel/opentelemetry-collector-contrib:latestSave the following as
otel-collector-deployment.yamland apply withkubectl apply -f otel-collector-deployment.yaml:apiVersion: apps/v1kind: Deploymentmetadata:name: otel-collector-elasticsearchnamespace: monitoringlabels:app: otel-collector-elasticsearchspec:replicas: 1selector:matchLabels:app: otel-collector-elasticsearchtemplate:metadata:labels:app: otel-collector-elasticsearchspec:containers:- name: otel-collectorimage: otel/opentelemetry-collector-contrib:latestargs:- "--config=/etc/otel/config.yaml"env:- name: NEWRELIC_LICENSE_KEYvalueFrom:secretKeyRef:name: newrelic-credentialskey: NEWRELIC_LICENSE_KEY- name: NEWRELIC_OTLP_ENDPOINTvalueFrom:secretKeyRef:name: newrelic-credentialskey: NEWRELIC_OTLP_ENDPOINTvolumeMounts:- name: configmountPath: /etc/otelresources:requests:memory: "128Mi"cpu: "100m"limits:memory: "256Mi"cpu: "500m"volumes:- name: configconfigMap:name: otel-collector-prometheus-es
Verify the deployment
Check the collector pod is running:
bash$kubectl get pods -n monitoring -l app=otel-collector-elasticsearchCheck collector logs:
bash$kubectl logs -n monitoring -l app=otel-collector-elasticsearch -fVerify data in New Relic:
FROM Metric SELECT count(*)WHERE metricName LIKE 'elasticsearch.%'AND elasticsearch.cluster.name = '<elasticsearch-cluster-name>'SINCE 10 minutes ago
ヒント
APMとElasticsearchを関連付ける: APMアプリケーションとElasticsearchを接続するには、 APMメトリクスにリソース プロパティes.cluster.name="your-cluster-name"を含めます。 これにより、New Relic 内でのサービス間の可視性とトラブルシューティングの高速化が可能になります。
トラブルシューティング
インストール中に問題が発生した場合、またはNew Relicにデータが表示されない場合は、一般的な問題に対する段階的な解決策についての包括的なトラブルシューティング ガイドを参照してください。
ポッド検出、RBAC 権限、ネットワーク接続などのKubernetes固有の問題については、Kubernetesトラブルシューティング」セクションを参照してください。