---
title: Install and configure NRDOT on self-hosted Elasticsearch
source: https://docs.newrelic.com/docs/opentelemetry/integrations/elasticsearch/install-configure/self-hosted/nrdot
---

Use this guide to install and configure NRDOT 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](https://docs.newrelic.com/docs/opentelemetry/integrations/elasticsearch/advanced-configuration).

## Compatibility and requirements [#requirements]

### Supported

-   Elasticsearch 7.16 or later

### You need

-   A New Relic [license key](https://docs.newrelic.com/docs/apis/intro-apis/new-relic-api-keys/#ingest-license-key)
-   Root or sudo privileges on the host
-   Elasticsearch cluster admin privileges with `monitor` or `manage` cluster privilege (see [Elasticsearch security privileges](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-privileges.html))
-   Outbound HTTPS (port 443) connectivity to New Relic's [OTLP endpoint](https://docs.newrelic.com/docs/opentelemetry/best-practices/opentelemetry-otlp)
-   An Elasticsearch username and password (if your cluster requires authentication)

## Install NRDOT collector [#install]

Install the NRDOT collector and run it as a systemd service. See [Install NRDOT](https://docs.newrelic.com/docs/opentelemetry/nrdot/nrdot-collector/).

## Configure the NRDOT collector [#configure]

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/nrdot-collector/config.yaml /etc/nrdot-collector/config.yaml.backup
    sudo nano /etc/nrdot-collector/config.yaml
    ```

2.  Delete all existing content and replace it with the following configuration for Elasticsearch monitoring.

    ```yaml
    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: {}
      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: "<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: 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: [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]
    ```

### Configuration parameters [#configuration-parameters]

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

| Parameter                    | Description                                                                                                                                                            |
| ---------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `endpoint`                   | Your Elasticsearch cluster's URL.                                                                                                                                      |
| `collection_interval`        | The interval between metric scrapes. The default is 15s.                                                                                                               |
| `elasticsearch.cluster.name` | A unique name identifying this cluster in New Relic.                                                                                                                   |
| `NEW_RELIC_MEMORY_LIMIT_MIB` | The memory limit, in MiB, for the collector's `memory_limiter` processor, set to fit your environment.                                                                 |
| `NEWRELIC_LICENSE_KEY`       | Your New Relic license key.                                                                                                                                            |
| `NEWRELIC_OTLP_ENDPOINT`     | The New Relic OTLP endpoint for your account's region, per [New Relic OTLP endpoints](https://docs.newrelic.com/docs/opentelemetry/best-practices/opentelemetry-otlp). |

3.  Save the configuration file.

You can optionally add secured-cluster authentication, host metrics, log collection, or custom metadata tags. See [Advanced configuration](https://docs.newrelic.com/docs/opentelemetry/integrations/elasticsearch/advanced-configuration).

## Set the environment variables [#env-vars]

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

```bash
sudo mkdir -p /etc/systemd/system/nrdot-collector.service.d
cat <<EOF | sudo tee /etc/systemd/system/nrdot-collector.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 NRDOT collector [#restart]

Restart the collector to apply your changes:

```bash
sudo systemctl daemon-reload
sudo systemctl restart nrdot-collector.service
```

## Verify data collection [#verify]

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):

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

> #### 💡 TIP
>
> You can also check the collector itself: `nrdot-collector.service` should report `active (running)` (`sudo systemctl status nrdot-collector.service`), with no connection errors in the logs (`sudo journalctl -u nrdot-collector.service -f`).

If you don't see data within ~5 minutes, see [Elasticsearch troubleshooting](https://docs.newrelic.com/docs/opentelemetry/integrations/elasticsearch/troubleshooting).

## Find and use your data [#find-and-use]

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 NRDOT, you can:

-   [Create custom dashboards](https://docs.newrelic.com/docs/query-your-data/explore-query-data/dashboards/introduction-dashboards/) to visualize your Elasticsearch metrics
-   [Set up alerts](https://docs.newrelic.com/docs/alerts/create-alert/create-alert-condition/alert-conditions/) for critical cluster health and performance thresholds
-   [Explore your data](https://docs.newrelic.com/docs/query-your-data/explore-query-data/browse-data/introduction-data-explorer/) using New Relic query capabilities

> #### 💡 TIP
>
> **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.

## Related articles [#related-articles]

-   [Advanced configuration](https://docs.newrelic.com/docs/opentelemetry/integrations/elasticsearch/advanced-configuration)
-   [Correlate APM with Elasticsearch using distributed tracing](https://docs.newrelic.com/docs/opentelemetry/integrations/elasticsearch/distributed-tracing)
-   [Elasticsearch metrics reference](https://docs.newrelic.com/docs/opentelemetry/integrations/elasticsearch/metrics-reference)
-   [Elasticsearch troubleshooting](https://docs.newrelic.com/docs/opentelemetry/integrations/elasticsearch/troubleshooting)
