OpenTelemetry Collectorサーバーまたは仮想マシンに直接インストールして、セルフホスト型Elasticsearchを監視します。 New Relicインフラストラクチャのセットアップと監視の要件に合わせた柔軟なデプロイメント オプションを提供します。
3つのコレクターオプションから選択できます:
- NRDOT: OpenTelemetryのNew Relicディストリビューション
- OTel Collector Contrib:コミュニティ提供のコンポーネントを備えた標準のOpenTelemetry Collector
- Prometheusレシーバー: すでにPrometheus Elasticsearchエクスポーターを実行している環境向け
インストールオプション
ニーズに合ったコレクターの分配方法を選択してください。
あなたが始める前に
NRDOTを使用してElasticsearch監視を設定する前に、以下が用意されていることを確認してください:
NRDOTコレクターがインストールされました:
- ホストにNRDOTコレクターがインストールされ、systemdサービスとして実行されている必要があります。
- インストールされていない場合は、公式のNRDOTインストレーションガイドに従って、systemdサービスを自動的にセットアップするパッケージマネージャ(DEB/RPM)を使用してコレクターをインストールしてください。
必要なアクセス権限:
- あなたのNew Relic
- ホストマシン上でroot権限またはsudo権限が必要です
monitorまたはmanage権限を持つElasticsearchクラスタ管理者権限 (詳細については、 Elasticsearchセキュリティ権限のドキュメントを参照してください)
システム要件:
- Elasticsearchバージョン 7.16 以降- この統合には最新のElasticsearchクラスタが必要です
- ネットワーク接続- New RelicのOTLP取り込みエンドポイントへのHTTPSアウトバウンド接続(ポート443)
設定値の準備ができました:
- Elasticsearchエンドポイント- ElasticsearchのURL (例:
http://localhost:9200) - Cluster名- New Relic内のクラスターの一意の識別子
Elasticsearchの監視を設定する
NRDOTコレクターがインストールされたら、コレクターのデフォルトの設定ファイルをElasticsearch監視設定に置き換えます。これにより、Elasticsearchメトリクスの収集が有効になります。ホストのメトリクスとログはオプションであり、別途追加できます。
設定ファイルは以下の場所にあります。 /etc/nrdot-collector/config.yaml
ヒント
デフォルト設定をバックアップする:設定ファイルを変更する前に、デフォルト設定を保持するためにバックアップコピーを作成してください。
$sudo cp /etc/nrdot-collector/config.yaml /etc/nrdot-collector/config.yaml.backupコレクターを設定するには:
root権限またはsudo権限を使用して、テキストエディタで設定ファイルを開きます。
bash$sudo nano /etc/nrdot-collector/config.yaml既存のコンテンツをすべて削除し、次のElasticsearch監視用の設定に置き換えます。
重要
endpointの値をElasticsearchクラスタのエンドポイントに置き換え、New Relicでクラスタを識別するための一意の名前でprocessorブロックのelasticsearch.cluster.nameを更新してください。この名前がElasticsearchで設定されたcluster.nameと一致していることを確認してください。
receivers: elasticsearch: endpoint: "http://localhost:9200" collection_interval: 15s 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: falseprocessors: memory_limiter: check_interval: 60s limit_mib: ${env:NEW_RELIC_MEMORY_LIMIT_MIB:-100} cumulativetodelta: {} attributes/cluster_state_aggregate: include: match_type: strict metric_names: - elasticsearch.cluster.state_update.time actions: - key: type action: delete - key: state action: delete filter/critical_operations: metrics: datapoint: # Filters to keep only: query, index, get, merge # Affects only 4 metrics: *.operations.completed and *.operations.time # All other metrics pass through unchanged - 'attributes["operation"] == "query" or attributes["operation"] == "index" or attributes["operation"] == "get" or attributes["operation"] == "merge" or attributes["operation"] == nil' resource/cluster_name_override: attributes: - key: elasticsearch.cluster.name value: "<elasticsearch-cluster-name>" action: upsert resourcedetection: detectors: [ system ] system: resource_attributes: host.name: enabled: true host.id: enabled: true os.type: 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: 300sservice: pipelines: metrics/elasticsearch: receivers: [elasticsearch] processors: [memory_limiter, resourcedetection, resource/cluster_name_override, attributes/cardinality_reduction, filter/critical_operations, attributes/cluster_state_aggregate, cumulativetodelta, transform/metadata_nullify, batch] exporters: [otlphttp](オプション)認証とSSLを使用したセキュアなElasticsearchの場合、受信側の設定を変更します。
receivers:elasticsearch:endpoint: "https://localhost:9200"username: "your_elasticsearch_username"password: "your_elasticsearch_password"tls:ca_file: "/etc/elasticsearch/certs/http_ca.crt"insecure_skip_verify: falsecollection_interval: 15s(オプション)ホストメトリクスを収集するには、hostmetricsレシーバーを追加します。
receivers:hostmetrics:collection_interval: 60sscrapers: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}process:metrics:process.cpu.utilization:enabled: trueさらに、サービスパイプラインに以下を追加します。
service:pipelines:metrics/host:receivers: [hostmetrics]processors: [memory_limiter, resourcedetection, batch]exporters: [otlphttp](オプション) Elasticsearchのログを収集するには、filelogレシーバーを追加します。コレクターサービス(nrdot-collector)を実行しているユーザーが、Elasticsearchのログファイルへの読み取りアクセス権を持っていることを確認してください:
Linux (ホスト) で Elasticsearch を実行している場合:
receivers:filelog:include:- /var/log/elasticsearch/elasticsearch.log- /var/log/elasticsearch/*.logDocker で Elasticsearch を実行している場合:
receivers:filelog:include:- /var/lib/docker/containers/*/*.logoperators:- type: movefrom: attributes.logto: bodyさらに、サービスパイプラインに以下を追加します。
service:pipelines:logs:receivers: [filelog]processors: [resource/cluster_name_override]exporters: [otlphttp](オプション)メトリクスにカスタムメタデータタグを追加するには、
resource/static_overrideプロセッサを使用します。processors:resource/static_override:attributes:- key: envvalue: "production"action: upsertservice:pipelines:metrics/elasticsearch:receivers: [elasticsearch]processors: [memory_limiter, resourcedetection, resource/cluster_name_override, resource/static_override, attributes/cardinality_reduction, cumulativetodelta, transform/metadata_nullify, batch]exporters: [otlphttp]設定ファイルを保存します。
環境変数を設定します。
systemd オーバーライド ディレクトリを作成します。
bash$sudo mkdir -p /etc/systemd/system/nrdot-collector.service.d環境設定ファイルを作成します。
bash$cat <<EOF | sudo tee /etc/systemd/system/nrdot-collector.service.d/environment.conf$[Service]$Environment="NEWRELIC_OTLP_ENDPOINT=https://otlp.nr-data.net:4318"$Environment="NEWRELIC_LICENSE_KEY=YOUR_LICENSE_KEY_HERE"$Environment="NEW_RELIC_MEMORY_LIMIT_MIB=100"$EOF設定をあなたの値で更新してください。
https://otlp.nr-data.net:4318リージョンのエンドポイントに置き換えますYOUR_LICENSE_KEY_HERE実際の New Relic ライセンスキーに置き換えてください。100コレクターの希望するメモリ制限値(MiB単位)に置き換えてください(デフォルト:100 MiB)。環境のニーズに合わせて調整してください
変更を適用するには、NRDOT コレクターを再起動します。
bash$sudo systemctl daemon-reload$sudo systemctl restart nrdot-collector.service
データ収集を確認する
NRDOTコレクターが実行されており、エラーなしでデータを収集していることを確認します:
コレクターサービスのステータスを確認してください。
bash$sudo systemctl status nrdot-collector.serviceエラーがないかコレクター ログを監視します。
bash$sudo journalctl -u nrdot-collector.service -fElasticsearchとNew Relicへの接続が正常に行われていることを確認してください。エラーが表示された場合は、トラブルシューティングガイドを参照してください。
あなたが始める前に
OTel Collector Contrib を設定する前に、以下のものを用意してください。
必要なアクセス権限:
- あなたのNew Relic
- ホストマシン上でroot権限またはsudo権限が必要です
monitorまたはmanage権限を持つElasticsearchクラスタ管理者権限 (詳細については、 Elasticsearchセキュリティ権限のドキュメントを参照してください)
システム要件:
- Elasticsearchバージョン 7.16 以降- この統合には最新のElasticsearchクラスタが必要です
- ネットワーク接続- New RelicのOTLP取り込みエンドポイントへのHTTPSアウトバウンド接続(ポート443)
設定値の準備ができました:
- Elasticsearchエンドポイント- ElasticsearchのURL (例:
http://localhost:9200) - Cluster名- New Relic内のクラスターの一意の識別子
重要
先に進む前に、ホストにOpenTelemetry Collector Contribがインストールされている必要があります。systemdサービスユニットが正しく作成されるように、公式パッケージ(.debまたは.rpm)を使用してインストールすることをお勧めします。
Elasticsearchの監視を設定する
OTel Collector Contribをインストールしたら、コレクターのデフォルト設定ファイルをElasticsearchの監視設定ファイルに置き換えてください。これにより、Elasticsearchのメトリクス収集が可能になります。ホストのメトリクスとログはオプションであり、個別に追加できます。
設定ファイルは以下の場所にあります。 /etc/otelcol-contrib/config.yaml
ヒント
デフォルト設定をバックアップする:設定ファイルを変更する前に、デフォルト設定を保持するためにバックアップコピーを作成してください。
$sudo cp /etc/otelcol-contrib/config.yaml /etc/otelcol-contrib/config.yaml.backupコレクターを設定するには:
root権限またはsudo権限を使用して、テキストエディタで設定ファイルを開きます。
bash$sudo nano /etc/otelcol-contrib/config.yaml既存のコンテンツをすべて削除し、次のElasticsearch監視用の設定に置き換えます。
重要
endpointの値をElasticsearchクラスタのエンドポイントに置き換え、New Relicでクラスタを識別するための一意の名前でprocessorブロックのelasticsearch.cluster.nameを更新してください。この名前がElasticsearchで設定されたcluster.nameと一致していることを確認してください。
receivers: elasticsearch: endpoint: "http://localhost:9200" collection_interval: 15s 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: falseprocessors: memory_limiter: check_interval: 60s limit_mib: ${env:NEW_RELIC_MEMORY_LIMIT_MIB:-100} cumulativetodelta: {} resource/cluster_name_override: attributes: - key: elasticsearch.cluster.name value: "<elasticsearch-cluster-name>" action: upsert resourcedetection: detectors: [ 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 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: pipelines: metrics/elasticsearch: receivers: [elasticsearch] processors: [memory_limiter, resourcedetection, resource/cluster_name_override, attributes/cardinality_reduction, cumulativetodelta, transform/metadata_nullify, batch] exporters: [otlphttp](オプション)認証とSSLを使用したセキュアなElasticsearchの場合、受信側の設定を変更します。
receivers:elasticsearch:endpoint: "https://localhost:9200"username: "your_elasticsearch_username"password: "your_elasticsearch_password"tls:ca_file: "/etc/elasticsearch/certs/http_ca.crt"insecure_skip_verify: falsecollection_interval: 15s(オプション)ホストメトリクスを収集するには、hostmetricsレシーバーを追加します。
receivers:hostmetrics:collection_interval: 60sscrapers: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}process:metrics:process.cpu.utilization:enabled: trueさらに、サービスパイプラインに以下を追加します。
service:pipelines:metrics/host:receivers: [hostmetrics]processors: [memory_limiter, resourcedetection, batch]exporters: [otlphttp](オプション) Elasticsearchのログを収集するには、filelogレシーバーを追加します。コレクターサービス(otelcol-contrib)を実行しているユーザーが、Elasticsearchのログファイルへの読み取りアクセス権を持っていることを確認してください。
Linux (ホスト) で Elasticsearch を実行している場合:
receivers:filelog:include:- /var/log/elasticsearch/elasticsearch.log- /var/log/elasticsearch/*.logDocker で Elasticsearch を実行している場合:
receivers:filelog:include:- /var/lib/docker/containers/*/*.logoperators:- type: movefrom: attributes.logto: bodyさらに、サービスパイプラインに以下を追加します。
service:pipelines:logs:receivers: [filelog]processors: [resource/cluster_name_override]exporters: [otlphttp](オプション)メトリクスにカスタムメタデータタグを追加するには、
resource/static_overrideプロセッサを使用します。processors:resource/static_override:attributes:- key: envvalue: "production"action: upsertservice:pipelines:metrics/elasticsearch:receivers: [elasticsearch]processors: [memory_limiter, resourcedetection, resource/cluster_name_override, resource/static_override, attributes/cardinality_reduction, cumulativetodelta, transform/metadata_nullify, batch]exporters: [otlphttp]設定ファイルを保存します。
環境変数を設定します。
systemd オーバーライド ディレクトリを作成します。
bash$sudo mkdir -p /etc/systemd/system/otelcol-contrib.service.d環境設定ファイルを作成します。
bash$cat <<EOF | sudo tee /etc/systemd/system/otelcol-contrib.service.d/environment.conf$[Service]$Environment="NEWRELIC_OTLP_ENDPOINT=https://otlp.nr-data.net:4318"$Environment="NEWRELIC_LICENSE_KEY=YOUR_LICENSE_KEY_HERE"$Environment="NEW_RELIC_MEMORY_LIMIT_MIB=100"$EOF設定をあなたの値で更新してください。
https://otlp.nr-data.net:4318リージョンのエンドポイントに置き換えますYOUR_LICENSE_KEY_HERE実際の New Relic ライセンスキーに置き換えてください。100コレクターの希望するメモリ制限値(MiB単位)に置き換えてください(デフォルト:100 MiB)。環境のニーズに合わせて調整してください
変更を適用するには、OTel Collector Contribを再起動してください。
bash$sudo systemctl daemon-reload$sudo systemctl restart otelcol-contrib.service
データ収集を確認する
OTel Collector Contribが実行され、エラーなくデータを収集していることを確認してください。
コレクターサービスのステータスを確認してください。
bash$sudo systemctl status otelcol-contrib.serviceエラーがないかコレクター ログを監視します。
bash$sudo journalctl -u otelcol-contrib.service -fElasticsearchとNew Relicへの接続が正常に行われていることを確認してください。エラーが表示された場合は、トラブルシューティングガイドを参照してください。
環境でPrometheus Elasticsearch exporterがすでに実行されている場合、またはPrometheusベースの監視スタックから移行する場合は、このアプローチを使用してください。
ヒント
推奨: Prometheusエクスポーターがまだ実行されていない場合は、代わりにNRDOT CollectorまたはOTel Collector Contribタブを使用してください。追加のエクスポーターコンポーネントを必要とせずに、Elasticsearch APIに直接接続します。
Elasticsearch エクスポーターをインストールして設定する
Prometheus Elasticsearch exporterは、ポート9114でPrometheus形式のElasticsearchメトリクスを公開します。
最新リリースをダウンロード:
bash$wget https://github.com/prometheus-community/elasticsearch_exporter/releases/download/v1.8.0/elasticsearch_exporter-1.8.0.linux-amd64.tar.gz$tar xzf elasticsearch_exporter-*.tar.gz$cd elasticsearch_exporter-*エクスポーターを起動します(Elasticsearchインスタンスを指定します):
bash$./elasticsearch_exporter --es.uri=http://localhost:9200ヒント
保護されたElasticsearchの場合は、次を使用します:
--es.uri=https://username:password@localhost:9200 --es.ssl-skip-verifyエクスポーターが実行中であることを確認します:
bash$curl http://localhost:9114/metrics | grep elasticsearch_cluster_healthelasticsearch_cluster_health_status、elasticsearch_cluster_health_number_of_nodesなどのPrometheus形式のメトリクスが表示されるはずです。
コレクターを構成する
この設定は、NRDOTとOTel Collector Contribの両方で機能します。コレクターの適切な設定場所に配置してください:
- NRDOT:
/etc/nrdot-collector/config.yaml - OTel Collector Contrib:
/etc/otelcol-contrib/config.yaml
まだコレクターをインストールしていない場合は、まず上のNRDOT CollectorまたはOTel Collector Contribタブのインストレーション手順に従い、その後ここに戻ってこの設定を適用してください。
この設定は、Elasticsearchエクスポーターからメトリクスをスクレイプし、New Relic Elasticsearchダッシュボードを機能させるOpenTelemetry互換のメトリクス名に変換します。
設定の以下の値を置き換えます:
<elasticsearch-cluster-name>:New Relicでクラスタを識別するために使用されるElasticsearchのクラスタ名。これをElasticsearchで設定されたcluster.nameに設定し、New Relicアカウント内で一意であることを確認してください。localhost:9114: 別のホストまたはポートで実行している場合のelasticsearch_exporterのアドレス。
環境変数を設定します
必要な環境変数を注入するために、systemdオーバーライドを作成します。<collector-service>をコレクターサービス名(nrdot-collectorまたはotelcol-contrib)に置き換えます:
$sudo mkdir -p /etc/systemd/system/<collector-service>.service.dファイル/etc/systemd/system/<collector-service>.service.d/environment.confを作成します:
[Service]Environment="NEWRELIC_OTLP_ENDPOINT=https://otlp.nr-data.net:4318"Environment="NEWRELIC_LICENSE_KEY=YOUR_NEWRELIC_LICENSE_KEY"Environment="NEW_RELIC_MEMORY_LIMIT_MIB=100"YOUR_NEWRELIC_LICENSE_KEY に置き換えます。
ヒント
EUアカウントの場合は、次を使用します NEWRELIC_OTLP_ENDPOINT=https://otlp.eu01.nr-data.net:4318
コレクターを起動する
<collector-service>をコレクターサービス名(nrdot-collectorまたはotelcol-contrib)に置き換えます:
$sudo systemctl daemon-reload$sudo systemctl enable <collector-service>$sudo systemctl restart <collector-service>コレクターのステータスを確認します:
$sudo systemctl status <collector-service>$sudo journalctl -u <collector-service> -fNew Relicでデータを検証する
数分後、データがNew Relicに送信されていることを確認します:
FROM Metric SELECT count(*)WHERE metricName LIKE 'elasticsearch.%'AND elasticsearch.cluster.name = '<elasticsearch-cluster-name>'SINCE 10 minutes agoAPMとElasticsearchを関連付ける
アプリケーションを呼び出し先のElasticsearchクラスタにリンクして、遅いトランザクションからそれを処理したクラスタに直接たどり着けるようにします。接続の深さを選択します:
| アプローチ | 何が得られるか | 設定内容 |
|---|---|---|
| ディストリビューティッド(分散)トレーシング(推奨) | エンドツーエンドのアプリからElasticsearchへのトレースと、自動的なサービスからクラスタへの関係 | アプリごとの変更なしで、Elasticsearchの組み込みトレースを有効にする |
| メトリクスのみ | クラスタは関連エンティティとして表示されます | APMアプリケーションとElasticsearchクラスタを接続するには、APMメトリクスにリソース属性es.cluster.name="your-cluster-name"を含めてください。これにより、New Relic内でのクロスサービスの可視性と、より迅速なトラブルシューティングが可能になります。 |
ステップバイステップのトレーシング設定については、「ディストリビューティッド(分散)トレーシングを使用してAPMをElasticsearchと関連付ける」をご覧ください。
Elasticsearchデータを表示する
コレクターが起動してデータ送信が開始されると、Elasticsearchのメトリクスを調べたり、カスタムクエリを作成したり、New Relicで監視ダッシュボードを設定したりできるようになります。
データへのアクセス、 NRQL書き込みの作成、およびアラートの構成の詳細については、 Elasticsearchデータの検索と書き込み」を参照してください。
トラブルシューティング
インストール中に問題が発生した場合、またはNew Relicにデータが表示されない場合は、一般的な問題に対する段階的な解決策についての包括的なトラブルシューティング ガイドを参照してください。