Skip to main content
Metrics type: Supporting MetricsCategory: Cluster Health

At a glance

The number of cluster-state change tasks queued on the elected master node, read from GET /_cluster/pending_tasks. Every shard allocation, index create or delete, mapping update, and settings change flows through this single ordered queue. A healthy cluster drains it to zero within milliseconds. A persistently non-zero queue means the master is overloaded with cluster-state updates and cannot keep pace, which delays shard recovery, blocks new indices, and can cascade into a yellow or red cluster.

Calculation

The card reads the array returned by GET /_cluster/pending_tasks and counts its length. In Elasticsearch terms:
The headline number is the raw count. The card also surfaces the priority mix and the oldest time_in_queue_millis so you can tell a deep-but-fast-draining queue from a shallow-but-stuck one. Cluster-state updates are single-threaded on the elected master by design: this guarantees a consistent, ordered view of the cluster, but it also means the master is the bottleneck. When the count climbs and stays up, the master is either CPU-bound, GC-bound, or generating cluster states so large that publishing each one to the other nodes takes too long. The alert fires on > 10 sustained 5m so that genuine bursts (a rolling restart relocates many shards at once) do not page anyone, while a master that has truly fallen behind does.

Worked example

A platform team runs a 6-node Elasticsearch 8.x cluster (3 dedicated master-eligible nodes, 3 data nodes) backing product search and log analytics for a mid-size retailer. At 09:14 on 14 Apr 26 the on-call SRE sees the Pending Cluster Tasks card jump from its usual 0 to 47 and hold there. Drilling into the raw API response: The headline reads 47 pending tasks with the oldest at roughly 42 seconds in queue. Two URGENT shard-failed/shard-started pairs sit at the head, so the cluster is trying to recover shards but the master cannot publish the resulting cluster states fast enough. The SRE checks the master’s vitals and finds the symptom: JVM Heap Used % on the elected master is at 91% and GC Pause Time (5m total ms) shows 3,400ms of stop-the-world pauses in the last five minutes. The master is spending so long in garbage collection that it cannot drain its own task queue.
The fix is not to touch the queue (you cannot reorder it) but to relieve the master. The team confirms the master nodes are under-provisioned for heap, raises the dedicated-master heap from 4GB to 8GB during the next maintenance window, and in the immediate term throttles the reindex job that was generating the NORMAL put-mapping churn. Within 90 seconds of GC pressure easing, the queue drains to 0 and the cluster returns to green. Three takeaways:
  1. Pending tasks is a master-health signal, not a traffic signal. It moves because of cluster-state work, so always read it alongside master-node JVM heap and GC. A spiking queue with a calm master usually self-heals; a spiking queue with a hot master is the real incident.
  2. Read the priority mix and the oldest wait, not just the count. Fifty LOW reindex tasks draining steadily is fine. Two URGENT tasks stuck for 40 seconds is not.
  3. Dedicated master nodes earn their keep here. If master duties share a node with data and search load, this queue is the first thing to suffer under traffic.

Sibling cards

Reconciling against the source

Where to look in Elasticsearch itself:
GET /_cluster/pending_tasks is the canonical source; the card reads it verbatim. The human-friendly view is GET /_cat/pending_tasks?v, which prints insertOrder, timeInQueue, priority, and source as a table. GET /_cluster/health shows the downstream effect (status, unassigned_shards, initializing_shards). GET /_nodes/stats/jvm on the elected master shows the heap and GC pressure that usually drives a stuck queue. Identify the master with GET /_cat/master?v.
Why our number may legitimately differ from a manual API call: Cross-connector reconciliation:

Known limitations / FAQs

The queue spiked to 60 during a rolling restart but never alerted. Is the card broken? No, that is the design. A rolling restart relocates many shards at once, so a transient spike is expected and healthy. The alert only fires on > 10 sustained 5m. If the spike drained within a minute or two, the master kept up and there is nothing to act on. The card is protecting you from paging on normal maintenance. What is the difference between _cluster/pending_tasks and _tasks? _cluster/pending_tasks is the single, ordered queue of cluster-state updates on the elected master (shard allocation, index creation, mapping changes). _tasks is the per-node task-management framework that tracks in-flight operations like a long-running search or reindex. This card reads the former. A backed-up search will show in _tasks, not here. The count is high but every task is priority LOW. Should I worry? Less so. The master processes by priority, so URGENT and HIGH tasks (the ones that affect availability) jump the queue. A deep tail of LOW reindex or ILM tasks that is draining steadily is usually fine. Watch the oldest time_in_queue_millis: if even the URGENT tasks are aging, that is the problem, not the raw count. My queue is stuck but JVM heap looks fine. What else causes this? Oversized cluster states. If you have tens of thousands of shards or indices, each cluster-state publish is large and slow to serialise and send to every node, independent of heap. Check total shard count (aim for under ~20 shards per GB of heap as a rule of thumb), prune unused indices, and consolidate small indices. Network latency between master-eligible nodes during the two-phase publish can also stall the queue. Can I clear or reorder the pending-tasks queue manually? No. There is no API to flush or reprioritise it; the ordering and single-threaded processing are what give Elasticsearch a consistent cluster state. The only levers are relieving the master (heap, GC, CPU), reducing the rate of cluster-state changes (throttle reindex/ILM churn), and shrinking the cluster state (fewer shards/indices). Does a high queue mean I am losing data? Not directly. It means cluster-state changes are delayed, which can block new index creation and slow shard recovery, and that recovery delay is what risks availability (yellow/red). Ingestion already in flight to existing indices is largely unaffected unless the delay is severe enough to push the cluster red. Pair this card with Unassigned Shards to gauge real data-availability risk. Why is this single-threaded? Surely parallelising would help. Cluster-state updates must be applied in a strict, total order so every node agrees on the same view of the cluster. Parallel application would break that consistency guarantee. The trade-off is that the master is a serial bottleneck, which is exactly why this card matters and why dedicated, well-provisioned master nodes are recommended for any cluster of meaningful size.

Tracked live in Vortex IQ Nerve Centre

Pending Cluster Tasks is one of hundreds of KPI pulses Vortex IQ tracks across Elasticsearch and 70+ other ecommerce connectors. Nerve Centre runs the detection layer; Vortex Mind investigates the cause when something moves; Ask Viq lets you interrogate any number in plain English. Start for free or book a demo to see this metric running on your own data.