Skip to content

Monitoring guide

Elasticsearch monitoring: cluster health and performance

Elasticsearch fails in recognisable ways: yellow or red status, heap pressure, rejected requests and disks crossing watermarks. Each has an API that shows it.

4 min read13 sectionsUpdated

On this page

Key points

  • Cluster status red means some data is unavailable.
  • JVM heap above ~75% leads to long GC and instability.
  • Thread pool rejections mean the cluster cannot keep up.
  • Disk watermarks stop shard allocation and then writes.

Health APIs

bash
curl -s localhost:9200/_cluster/health?pretty
curl -s "localhost:9200/_cat/shards?v&h=index,shard,prirep,state,unassigned.reason" | grep -v STARTED
curl -s "localhost:9200/_cat/nodes?v&h=name,heap.percent,cpu,load_1m,disk.used_percent"
curl -s "localhost:9200/_cat/thread_pool/search,write?v&h=node_name,name,active,queue,rejected"
curl -s localhost:9200/_cluster/allocation/explain?pretty     # why a shard is unassigned

What to watch

MetricWorry when
Cluster statusYellow for long, red at all
Unassigned shardsAbove 0 outside planned restarts
JVM heap percentSustained above ~75%
Search and indexing latencyp95 rising
Thread pool rejectedIncreasing on search or write
Disk used vs watermarks (85/90/95% defaults)Approaching the low watermark

Collecting metrics

otel-collector.yamlyaml
receivers:
  elasticsearch:
    endpoint: http://elasticsearch:9200
    username: otel_monitor
    password: ${env:ES_MONITOR_PASSWORD}
    collection_interval: 60s
exporters:
  otlphttp/vitalrix:
    encoding: json
    metrics_endpoint: ${env:VITALRIX_API}/api/v1/metrics/otlp/v1/metrics
    headers: { x-api-key: ${env:VITALRIX_KEY} }
service:
  pipelines:
    metrics: { receivers: [elasticsearch], exporters: [otlphttp/vitalrix] }

Elasticsearch monitoring with VitalRix

Collector metrics arrive over OTLP and can be charted on dashboards and used in alert rules. A TCP check confirms Elasticsearch accepts connections from the network your app uses, and APM traces show which requests wait on Elasticsearch and for how long, from the client spans your instrumented services create. An HTTP check on /_cluster/health with a body assertion that status is not "red" turns cluster health into an uptime alert.

Fixing the common states

  • Yellow on a single node: replicas cannot be placed; set number_of_replicas to 0 for that index or add a node.
  • Red: a primary shard is missing; check the allocation explain API, node availability and disk watermarks.
  • High heap: reduce shard count (many small shards cost heap), avoid huge aggregations, and check field data usage.
  • Write rejections: bulk requests too large or too many; tune bulk size and client concurrency.
  • Disk watermark reached: delete or roll over old indices, add disk, or add nodes; use index lifecycle policies.

Alerts to start with

  • Cluster status red, immediately; yellow for more than 30 minutes.
  • JVM heap above 85% for 10 minutes.
  • Search or write thread pool rejections increasing.
  • Disk above the low watermark on any data node.
  • Search p95 latency above target from your application traces.

The Elasticsearch metrics that matter

MetricAPIStarting alert
Cluster healthGET _cluster/healthYellow for more than 10 minutes, red at once
Unassigned shards_cluster/health, _cat/shardsAbove zero for 10 minutes
JVM heap usedGET _nodes/stats/jvmAbove 75% sustained
Disk use vs watermarksGET _cat/allocationApproaching the low watermark (85% by default); 90% high and 95% flood stage are the defaults
Search and indexing latencyGET _nodes/stats/indicesRising against the usual
Thread pool rejectionsGET _cat/thread_pool?vAny rejections on search or write
bash
curl -s localhost:9200/_cluster/health?pretty
# why is a shard unassigned?
curl -s localhost:9200/_cluster/allocation/explain?pretty
curl -s 'localhost:9200/_cat/thread_pool/search,write?v&h=node_name,name,active,queue,rejected'

What the incidents look like

  • Disk crosses the flood stage: Elasticsearch makes indices read-only to protect itself, and every write fails. Free space or add nodes, then clear the block.
  • Heap pressure and long GC pauses: nodes stop answering, get dropped from the cluster and shards relocate, which adds load. Usually too many shards per node or huge aggregations.
  • Rejections on the write pool during ingest bursts: senders must retry with backoff, or data is lost.
  • Yellow after a node restart while replicas recover: expected for a while, a problem if it lasts.

If Elasticsearch stores your logs, its own health is part of your observability: an incident in the log cluster is the moment you most need logs. Keep basic health checks and alerts on a separate system.

Frequently asked questions

Why is my cluster yellow?

Replica shards are unassigned, often because a single-node cluster cannot place replicas on another node, or a node is down. The allocation explain API says why.

How much heap should Elasticsearch get?

About half the machine’s RAM, and no more than roughly 30 GB so compressed object pointers stay enabled; the rest is used by the OS file cache.

Check it now, free

  • Java performance monitoring: Monitor Java and Spring applications: JVM heap and GC, thread pools, JDBC connection pools, request latency from traces.
  • Elasticsearch CircuitBreakingException: how to fix it: Fix Elasticsearch CircuitBreakingException Data too large: reduce fielddata and huge aggregations, size JVM heap correctly and check shard counts per node.
  • GC overhead limit exceeded in Java: how to fix it: Fix java.lang.OutOfMemoryError: GC overhead limit exceeded. Enable GC logs, take a heap dump, find what fills the heap and size the JVM for containers.
  • Elasticsearch cluster status red: how to fix it: Fix a red Elasticsearch cluster: use the allocation explain API to find unassigned primary shards, handle disk watermarks and restore lost shards safely.
  • GraphQL API monitoring: Monitor GraphQL APIs properly: errors hidden inside 200 responses, latency per operation, resolver tracing, query depth, and uptime checks that assert on data.
  • How to monitor a Next.js app: How to monitor a Next.js app in production: uptime checks, Core Web Vitals, server and edge errors, OpenTelemetry traces for SSR and API routes, and alerts.

Watch your own site and services with VitalRix

Uptime checks, APM, logs, real-user monitoring, alerts and status pages in one place. Every product has a free tier and no credit card is needed.