This guide shows how to deploy NRDOT on Kubernetes using a manifest install to automatically discover your Elasticsearch pods, collect cluster, node, and JVM metrics, and stream them to New Relic to monitor your cluster's health and performance.
Compatibility and requirements
Supported
- Elasticsearch 7.16 or later, running as pods in a Kubernetes cluster
- Manifest install method
You need
- A New Relic license key
kubectlaccess to your Kubernetes cluster- The base Kubernetes OpenTelemetry manifest installation already completed
- An Elasticsearch user with the
monitorormanagecluster privilege (see Elasticsearch security privileges) - Outbound HTTPS (port 443) connectivity to New Relic's OTLP endpoint
- An Elasticsearch username and password (if your cluster requires authentication)
Set up pod labels
Each Elasticsearch pod must have the label app: elasticsearch for automatic discovery to work. Without this label, the collector won't detect or monitor your pods.
If you're using a StatefulSet or Deployment for Elasticsearch, add the label in the pod template:
apiVersion: apps/v1kind: StatefulSetmetadata: name: elasticsearchspec: template: metadata: labels: app: elasticsearch # Required for auto-discovery spec: containers: - name: elasticsearch image: docker.elastic.co/elasticsearch/elasticsearch:8.x.xFor existing pods without the label, update your StatefulSet/Deployment and restart the pods:
$kubectl label pods -l <your-existing-selector> app=elasticsearch -n <namespace>You can verify labels are set correctly:
$kubectl get pods -n <namespace> --show-labelsPrepare the collector image and settings
Update the collector image, then define its Elasticsearch monitoring configuration in your local manifest files. You apply these changes to your cluster in the next step.
Update the collector image to NRDOT in both
deployment.yamlanddaemonset.yamlin your localrendereddirectory:image: newrelic/nrdot-collector:latestUpdate
deployment-configmap.yamlfor Elasticsearch monitoring: setruleto match your pod label, and set the cluster name in bothresource/clusterandresource/cluster_name_override. Then choose one of two options:Option 1: Replace all existing OpenTelemetry components (recommended for Elasticsearch-only monitoring). Replace the entire file's content with:
apiVersion: v1kind: ConfigMapmetadata:name: nr-k8s-otel-collector-deployment-configdata:config.yaml: |extensions:health_check:endpoint: 0.0.0.0:13133k8s_observer:auth_type: serviceAccountobserve_pods: trueobserve_nodes: truereceivers:jaeger: nullzipkin: nullprometheus: nullotlp: nullreceiver_creator/elasticsearch:watch_observers: [k8s_observer]receivers:elasticsearch:rule: type == "pod" && labels["app"] == "elasticsearch"config:endpoint: 'http://`endpoint`: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}cumulativetodelta: {}attributes/cluster_state_aggregate:include:match_type: strictmetric_names:- elasticsearch.cluster.state_update.timeactions:- key: typeaction: delete- key: stateaction: deletefilter/critical_operations:metrics:datapoint:- 'attributes["operation"] == "query" or attributes["operation"] == "index" or attributes["operation"] == "get" or attributes["operation"] == "merge" or attributes["operation"] == nil'resource/cluster:attributes:- key: k8s.cluster.namevalue: "elasticsearch-cluster"action: insertresource/cluster_name_override:attributes:- key: elasticsearch.cluster.namevalue: "elasticsearch-cluster"action: upsertresourcedetection:detectors: [env, system]system:resource_attributes:host.name:enabled: truehost.id:enabled: falseos.type:enabled: truebatch:timeout: 30ssend_batch_size: 2048send_batch_max_size: 4096attributes/cardinality_reduction:actions:- key: process.pidaction: delete- key: process.parent_pidaction: delete- key: k8s.pod.uidaction: deletetransform/metadata_nullify:metric_statements:- context: metricstatements:- set(description, "")- set(unit, "")exporters:otlp_http:endpoint: "${env:NEWRELIC_OTLP_ENDPOINT}"headers:api-key: "${env:NEWRELIC_LICENSE_KEY}"compression: gziptimeout: 30sretry_on_failure:enabled: trueinitial_interval: 5smax_interval: 30smax_elapsed_time: 300sservice:extensions: [health_check, k8s_observer]pipelines:traces: nulllogs: nullmetrics: nullmetrics/elasticsearch:receivers: [receiver_creator/elasticsearch]processors: [memory_limiter, resourcedetection, resource/cluster, resource/cluster_name_override, attributes/cardinality_reduction, filter/critical_operations, attributes/cluster_state_aggregate, cumulativetodelta, transform/metadata_nullify, batch]exporters: [otlp_http]Option 2: Merge with existing configuration (if monitoring multiple services). Add the Elasticsearch receiver and processors to your existing configuration, merging them with your current
deployment-configmap.yaml.You can optionally secure this cluster with authentication and SSL. See Advanced configuration.
Configuration parameters
The following table describes the key configuration parameters used in the deployment-configmap.yaml above:
| Parameter | Description |
|---|---|
rule | The pod-matching rule used for auto-discovery. Update labels["app"] == "elasticsearch" to match your pod labels. |
endpoint | The Elasticsearch endpoint scraped on each discovered pod. Update port 9200 if Elasticsearch runs on a different port, and use https for a secured cluster. |
collection_interval | The interval between metric scrapes. The default is 15s. |
elasticsearch-cluster (in resource/cluster / resource/cluster_name_override) | A unique name identifying this cluster in New Relic. Replace with a name that's unique across your account. |
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. See New Relic OTLP endpoints. |
Install and configure the NRDOT collector via kubectl
Apply the updated manifests to deploy the NRDOT collector to your cluster with the image and settings you just prepared.
$kubectl apply -n newrelic -R -f renderedRestart the NRDOT collector pods
Restart the deployment to apply your changes:
$kubectl rollout restart deployment nr-k8s-otel-collector-deployment -n newrelicVerify your install
Within ~5 minutes of installing, run this query in New Relic to confirm data is flowing (replace elasticsearch-cluster with your cluster's name):
FROM MetricSELECT *WHERE metricName LIKE 'elasticsearch.%' AND instrumentation.provider = 'opentelemetry' AND k8s.cluster.name = 'elasticsearch-cluster'SINCE 10 minutes agoTip
You can also check the collector itself: the pod should be in a Running state (kubectl get pods -n newrelic --watch), name like nr-k8s-otel-collector-deployment-<hash>, with no connection errors in the pod logs (kubectl logs -n newrelic -l app.kubernetes.io/name=nr-k8s-otel-collector -f).
If you don't see data within ~5 minutes, see Kubernetes 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:
- Go to one.newrelic.com > Integrations & Agents.
- Under the All tab, click Dashboards, then search for Elasticsearch (OpenTelemetry Collector) to view the dashboard.
Or, from the left navigation:
- Click Dashboards.
- Search for the Elasticsearch (OpenTelemetry Collector) dashboard to view it.
After setting up Elasticsearch monitoring with NRDOT, you can:
- Create custom dashboards to visualize your Elasticsearch metrics
- Set up alerts for critical cluster health and performance thresholds
- Explore your data 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.