LinuxサーバーまたはVM上のセルフホスト型Elasticsearchクラスタをモニターするために、このガイドを使用してOpenTelemetry Collector Contribをインストールおよび設定してください。設定が完了すると、コレクターはElasticsearchクラスタのメトリクスをNew Relicにエクスポートします。ホストのメトリクス、ログ、カスタムタグについては、高度な設定をご覧ください。
互換性と要件
サポート対象
- Elasticsearch 7.16以降
必要なこと
- New Relicのライセンスキー
- ホスト上のrootまたはsudo権限
monitorまたはmanageのクラスタ権限を持つElasticsearchクラスタの管理者権限(Elasticsearchのセキュリティ権限を参照)- New RelicのOTLPエンドポイントへのアウトバウンドHTTPS(ポート443)接続
- Elasticsearchのユーザー名とパスワード(クラスタで認証が必要な場合)
OTel Collector Contribのインストール
OpenTelemetry Collector Contribをインストールし、systemdサービスとして実行します。公式の.deb/.rpmパッケージにより、サービスユニットが作成されます。
Elasticsearchの監視用にOTel Collector Contribを設定します。
Elasticsearchの監視を有効にするには、コレクターのデフォルト設定を更新してください。
コレクターのデフォルト設定をバックアップしてから、編集用に開いてください:
bash$sudo cp /etc/otelcol-contrib/config.yaml /etc/otelcol-contrib/config.yaml.backup$sudo nano /etc/otelcol-contrib/config.yaml既存のすべてのコンテンツを削除し、Elasticsearch監視用の以下の設定に置き換えてください。
receivers:elasticsearch:endpoint: "http://<YOUR_ELASTICSEARCH_HOST>:9200"collection_interval: 15smetrics:elasticsearch.os.cpu.usage:enabled: trueelasticsearch.cluster.data_nodes:enabled: trueelasticsearch.cluster.health:enabled: trueelasticsearch.cluster.in_flight_fetch:enabled: trueelasticsearch.cluster.nodes:enabled: trueelasticsearch.cluster.pending_tasks:enabled: trueelasticsearch.cluster.shards:enabled: trueelasticsearch.cluster.state_update.time:enabled: trueelasticsearch.index.documents:enabled: trueelasticsearch.index.operations.merge.current:enabled: trueelasticsearch.index.operations.time:enabled: trueelasticsearch.node.cache.count:enabled: trueelasticsearch.node.cache.evictions:enabled: trueelasticsearch.node.cache.memory.usage:enabled: trueelasticsearch.node.shards.size:enabled: trueelasticsearch.node.cluster.io:enabled: trueelasticsearch.node.documents:enabled: trueelasticsearch.node.disk.io.read:enabled: trueelasticsearch.node.disk.io.write:enabled: trueelasticsearch.node.fs.disk.available:enabled: trueelasticsearch.node.fs.disk.total:enabled: trueelasticsearch.node.http.connections:enabled: trueelasticsearch.node.ingest.documents.current:enabled: trueelasticsearch.node.ingest.operations.failed:enabled: trueelasticsearch.node.open_files:enabled: trueelasticsearch.node.operations.completed:enabled: trueelasticsearch.node.operations.current:enabled: trueelasticsearch.node.operations.get.completed:enabled: trueelasticsearch.node.operations.time:enabled: trueelasticsearch.node.shards.reserved.size:enabled: trueelasticsearch.index.shards.size:enabled: trueelasticsearch.os.cpu.load_avg.1m:enabled: trueelasticsearch.os.cpu.load_avg.5m:enabled: trueelasticsearch.os.cpu.load_avg.15m:enabled: trueelasticsearch.os.memory:enabled: truejvm.gc.collections.count:enabled: truejvm.gc.collections.elapsed:enabled: truejvm.memory.heap.max:enabled: truejvm.memory.heap.used:enabled: truejvm.memory.heap.utilization:enabled: truejvm.threads.count:enabled: trueelasticsearch.index.segments.count:enabled: trueelasticsearch.index.operations.completed:enabled: trueelasticsearch.node.script.cache_evictions:enabled: falseelasticsearch.node.cluster.connections:enabled: falseelasticsearch.node.pipeline.ingest.documents.preprocessed:enabled: falseelasticsearch.node.thread_pool.tasks.queued:enabled: falseelasticsearch.cluster.published_states.full:enabled: falsejvm.memory.pool.max:enabled: falseelasticsearch.node.script.compilation_limit_triggered:enabled: falseelasticsearch.node.shards.data_set.size:enabled: falseelasticsearch.node.pipeline.ingest.documents.current:enabled: falseelasticsearch.cluster.state_update.count:enabled: falseelasticsearch.node.fs.disk.free:enabled: falsejvm.memory.nonheap.used:enabled: falsejvm.memory.pool.used:enabled: falseelasticsearch.node.translog.size:enabled: falseelasticsearch.node.thread_pool.threads:enabled: falseelasticsearch.cluster.state_queue:enabled: falseelasticsearch.node.translog.operations:enabled: falseelasticsearch.memory.indexing_pressure:enabled: falseelasticsearch.node.ingest.documents:enabled: falsejvm.classes.loaded:enabled: falsejvm.memory.heap.committed:enabled: falseelasticsearch.breaker.memory.limit:enabled: falseelasticsearch.indexing_pressure.memory.total.replica_rejections:enabled: falseelasticsearch.breaker.memory.estimated:enabled: falseelasticsearch.cluster.published_states.differences:enabled: falsejvm.memory.nonheap.committed:enabled: falseelasticsearch.node.translog.uncommitted.size:enabled: falseelasticsearch.node.script.compilations:enabled: falseelasticsearch.node.pipeline.ingest.operations.failed:enabled: falseelasticsearch.indexing_pressure.memory.limit:enabled: falseelasticsearch.breaker.tripped:enabled: falseelasticsearch.indexing_pressure.memory.total.primary_rejections:enabled: falseelasticsearch.node.thread_pool.tasks.finished:enabled: falseprocessors:memory_limiter:check_interval: 60slimit_mib: ${env:NEW_RELIC_MEMORY_LIMIT_MIB:-100}cumulativetodelta: {}resource/cluster_name_override:attributes:- key: elasticsearch.cluster.namevalue: "<YOUR_ELASTICSEARCH_CLUSTER_NAME>"action: upsertresourcedetection:detectors: [system]system:resource_attributes:host.name: { enabled: true }host.id: { enabled: true }os.type: { enabled: true }batch:timeout: 10ssend_batch_size: 1024attributes/cardinality_reduction:actions:- key: process.pidaction: delete- key: process.parent_pidaction: deletetransform/metadata_nullify:metric_statements:- context: metricstatements:- 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]
設定パラメーター
以下の表は、上記の設定で使用される主要な設定パラメーターについて説明しています:
| パラメータ | 説明 |
|---|---|
endpoint | ElasticsearchクラスタのURL。 |
collection_interval | メトリクスのスクレイプ間隔です。デフォルトは15秒です。 |
elasticsearch.cluster.name ( resource/cluster_name_override内) | New Relicでこのクラスタを識別する一意の名前です。<YOUR_ELASTICSEARCH_CLUSTER_NAME>をアカウント全体で一意の名前に置き換えてください。 |
NEW_RELIC_MEMORY_LIMIT_MIB | ご利用の環境に合わせて設定する、コレクターのmemory_limiterプロセッサのメモリ制限(MiB単位)です。 |
NEWRELIC_LICENSE_KEY | あなたのNew Relic ライセンスキー 。 |
NEWRELIC_OTLP_ENDPOINT | New Relic OTLPエンドポイントに基づく、アカウントのリージョンに対応するNew Relic OTLPエンドポイント。 |
- 設定ファイルを保存します。
オプションで、保護されたクラスタの認証、ホストのメトリクス、ログ収集、またはカスタムメタデータタグを追加できます。高度な設定をご覧ください。
環境変数を設定します。
コレクターがNew Relicにデータを送信するために必要な認証情報と接続の詳細を設定します。
$sudo mkdir -p /etc/systemd/system/otelcol-contrib.service.d$cat <<EOF | sudo tee /etc/systemd/system/otelcol-contrib.service.d/environment.conf$[Service]$Environment="NEWRELIC_OTLP_ENDPOINT=<YOUR_NEWRELIC_OTLP_ENDPOINT>"$Environment="NEWRELIC_LICENSE_KEY=<YOUR_NEWRELIC_LICENSE_KEY>"$Environment="NEW_RELIC_MEMORY_LIMIT_MIB=100"$EOFOTel Collector Contribを再起動してください。
変更を適用するには、コレクターを再起動してください:
$sudo systemctl daemon-reload$sudo systemctl restart otelcol-contrib.serviceデータ収集を確認する
コレクターを再起動してから約5分以内に、New Relicでこのクエリを実行して、データが到着していることを確認してください(<YOUR_ELASTICSEARCH_CLUSTER_NAME>をクラスタ名に置き換えます):
FROM Metric SELECT count(*)WHERE metricName LIKE 'elasticsearch.%'AND elasticsearch.cluster.name = '<YOUR_ELASTICSEARCH_CLUSTER_NAME>'SINCE 10 minutes agoヒント
コレクター自体を確認することもできます:otelcol-contrib.serviceはactive (running)(sudo systemctl status otelcol-contrib.service)を報告し、ログ(sudo journalctl -u otelcol-contrib.service -f)に接続エラーがないはずです。
約5分以内にデータが表示されない場合は、Elasticsearchのトラブルシューティングをご覧ください。
データを探す、使う
New Relicがデータを収集すると、New Relic UIを通じてElasticsearchの監視にアクセスできるようになります。
New RelicでElasticsearchダッシュボードを見つけるには:
- one.newrelic.com > Integrations & Agentsに移動します。
- AllタブでDashboardsをクリックし、Elasticsearch (OpenTelemetry Collector)を検索してダッシュボードを表示します。
または、左側のナビゲーションから:
- Dashboardsをクリックします。
- Elasticsearch (OpenTelemetry Collector)ダッシュボードを検索して表示します。
OTel Collector Contribを使用してElasticsearchの監視をセットアップした後は、次のことが可能です:
- Elasticsearchのメトリクスを可視化するためのカスタムダッシュボードを作成します
- クリティカルなクラスタのヘルスおよびパフォーマンスの閾値に対するアラートを設定します
- New Relicのクエリ機能を使用して、データを探索します
ヒント
APMとElasticsearchの関連付け:APMアプリケーションとElasticsearchクラスタを接続するには、APMメトリクスにリソース属性es.cluster.name="your-cluster-name"を含めてください。これにより、New RelicでAPMとElasticsearchのデータを一緒に表示できるようになります。