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

Install and configure OTel Collector Contrib on self-hosted Elasticsearch

|View as Markdown (English)

Use this guide to install and configure OpenTelemetry Collector Contrib to monitor a self-hosted Elasticsearch cluster on a Linux server or VM. Once you configure it, the collector exports your Elasticsearch cluster metrics to New Relic. For host metrics, logs, and custom tags, see Advanced configuration.

Compatibility and requirements

Supported

  • Elasticsearch 7.16 or later

You need

Install OTel Collector Contrib

Install OpenTelemetry Collector Contrib and run it as a systemd service. Official .deb/.rpm packages create the service unit for you.

Configure the OTel Collector Contrib for Elasticsearch monitoring

Update the collector's default configuration to enable Elasticsearch monitoring.

  1. Back up the collector's default configuration, then open it for editing:

    bash
    $
    sudo cp /etc/otelcol-contrib/config.yaml /etc/otelcol-contrib/config.yaml.backup
    $
    sudo nano /etc/otelcol-contrib/config.yaml
  2. Delete all existing content and replace it with the following configuration for Elasticsearch monitoring.

    receivers:
    elasticsearch:
    endpoint: "http://<YOUR_ELASTICSEARCH_HOST>: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: false
    processors:
    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: "<YOUR_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]

Configuration parameters

The following table describes the key configuration parameters used in the configuration above:

ParameterDescription
endpointYour Elasticsearch cluster's URL.
collection_intervalThe interval between metric scrapes. The default is 15s.
elasticsearch.cluster.name (in resource/cluster_name_override)A unique name identifying this cluster in New Relic, replacing <YOUR_ELASTICSEARCH_CLUSTER_NAME> with a name that's unique across your account.
NEW_RELIC_MEMORY_LIMIT_MIBThe memory limit, in MiB, for the collector's memory_limiter processor, set to fit your environment.
NEWRELIC_LICENSE_KEYYour New Relic license key.
NEWRELIC_OTLP_ENDPOINTThe New Relic OTLP endpoint for your account's region, per New Relic OTLP endpoints.
  1. Save the configuration file.

You can optionally add secured-cluster authentication, host metrics, log collection, or custom metadata tags. See Advanced configuration.

Set the environment variables

Set the credentials and connection details the collector needs to send data to New Relic.

bash
$
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"
$
EOF

Restart the OTel Collector Contrib

Restart the collector to apply your changes:

bash
$
sudo systemctl daemon-reload
$
sudo systemctl restart otelcol-contrib.service

Verify data collection

Within ~5 minutes of restarting the collector, run this query in New Relic to confirm data is flowing (replace <YOUR_ELASTICSEARCH_CLUSTER_NAME> with your cluster's name):

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

ヒント

You can also check the collector itself: otelcol-contrib.service should report active (running) (sudo systemctl status otelcol-contrib.service), with no connection errors in the logs (sudo journalctl -u otelcol-contrib.service -f).

If you don't see data within ~5 minutes, see Elasticsearch troubleshooting.

Find and use your data

Once New Relic collects your data, you can access Elasticsearch monitoring through the New Relic UI.

To find your Elasticsearch dashboard in New Relic:

  1. Go to one.newrelic.com > Integrations & Agents.
  2. Under the All tab, click Dashboards, then search for Elasticsearch (OpenTelemetry Collector) to view the dashboard.

Or, from the left navigation:

  1. Click Dashboards.
  2. Search for the Elasticsearch (OpenTelemetry Collector) dashboard to view it.

After setting up Elasticsearch monitoring with OTel Collector Contrib, you can:

ヒント

Correlate APM with Elasticsearch: To connect your APM application and Elasticsearch cluster, include the resource attribute es.cluster.name="your-cluster-name" in your APM metrics. This lets you view APM and Elasticsearch data together in New Relic.

Copyright © 2026 New Relic株式会社。

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