This guide shows how to deploy NRDOT on Kubernetes using Helm 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
- Helm install method
You need
- A New Relic license key
kubectlaccess to your Kubernetes cluster- Helm 3.x installed
- 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 credentials and collector settings
Create the credentials the collector needs, then define its Elasticsearch monitoring configuration in a values.yaml file. You install the collector with this configuration in the next step.
Create the namespace and a secret for your New Relic credentials:
bash$kubectl create namespace newrelic$kubectl create secret generic newrelic-licenses \>--from-literal=NEWRELIC_LICENSE_KEY=YOUR_LICENSE_KEY_HERE \>--from-literal=NEWRELIC_OTLP_ENDPOINT=YOUR_NEWRELIC_OTLP_ENDPOINT \>--from-literal=NEW_RELIC_MEMORY_LIMIT_MIB=100 \>-n newrelicReplace the memory limit with what fits your environment.
Create a
values.yamlfile for the NRDOT collector: setruleto match your pod label, and setK8S_CLUSTER_NAMEto a unique name for this cluster:mode: deploymentimage:repository: newrelic/nrdot-collectortag: latestpullPolicy: IfNotPresentresources:limits:cpu: 500mmemory: 512Mirequests:cpu: 200mmemory: 256Miports: {}extraEnvs:- name: NEWRELIC_LICENSE_KEYvalueFrom:secretKeyRef:name: newrelic-licenseskey: NEWRELIC_LICENSE_KEY- name: NEWRELIC_OTLP_ENDPOINTvalueFrom:secretKeyRef:name: newrelic-licenseskey: NEWRELIC_OTLP_ENDPOINT- name: NEW_RELIC_MEMORY_LIMIT_MIBvalueFrom:secretKeyRef:name: newrelic-licenseskey: NEW_RELIC_MEMORY_LIMIT_MIB- name: K8S_CLUSTER_NAMEvalue: "elasticsearch-cluster"clusterRole:create: truerules:- apiGroups: [""]resources: ["pods", "nodes", "nodes/stats", "nodes/proxy"]verbs: ["get", "list", "watch"]- apiGroups: ["apps"]resources: ["replicasets"]verbs: ["get", "list", "watch"]config: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: "${env:K8S_CLUSTER_NAME}"action: insertresource/cluster_name_override:attributes:- key: elasticsearch.cluster.namevalue: "${env:K8S_CLUSTER_NAME}"action: upsertresourcedetection:detectors: [env, system]system:resource_attributes:host.name:enabled: truehost.id:enabled: trueos.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]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 values.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 K8S_CLUSTER_NAME) | 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 Helm
Deploy the NRDOT collector to your cluster. Helm applies the configuration from the values.yaml file you just created.
Add and update the OpenTelemetry Helm chart repository:
bash$helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts$helm repo updateDeploy the NRDOT collector:
bash$helm upgrade --install elasticsearch-nrdot-collector open-telemetry/opentelemetry-collector \>--namespace newrelic \>--create-namespace \>-f values.yaml
Verify 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 agoConseil
You can also check the collector itself: the pod should be in a Running state (kubectl get pods -n newrelic --watch), name like elasticsearch-nrdot-collector-<hash>, with no connection errors in the pod logs (kubectl logs -n newrelic -l app.kubernetes.io/name=opentelemetry-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
Conseil
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.