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
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| Metric | Worry when |
|---|---|
| Cluster status | Yellow for long, red at all |
| Unassigned shards | Above 0 outside planned restarts |
| JVM heap percent | Sustained above ~75% |
| Search and indexing latency | p95 rising |
| Thread pool rejected | Increasing on search or write |
| Disk used vs watermarks (85/90/95% defaults) | Approaching the low watermark |
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_replicasto 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.
| Metric | API | Starting alert |
|---|---|---|
| Cluster health | GET _cluster/health | Yellow for more than 10 minutes, red at once |
| Unassigned shards | _cluster/health, _cat/shards | Above zero for 10 minutes |
| JVM heap used | GET _nodes/stats/jvm | Above 75% sustained |
| Disk use vs watermarks | GET _cat/allocation | Approaching the low watermark (85% by default); 90% high and 95% flood stage are the defaults |
| Search and indexing latency | GET _nodes/stats/indices | Rising against the usual |
| Thread pool rejections | GET _cat/thread_pool?v | Any rejections on search or write |
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.
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
- Response time checker: Measure TTFB with DNS, connect, TLS and server time.
Related reading
- 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.