Elasticsearch Cluster Health
ElasticOfficialCreated by elastic
- Skill
- Review and audit
- Cloud and DevOps
- Apache-2.0
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a structured, read-only diagnostic process for Elasticsearch clusters reporting yellow or red status. It guides operators through identifying the specific index and shard causing the issue, distinguishing between transient triggers and root-cause allocation deciders. By analyzing cluster health and allocation explanations, the skill helps operators differentiate between minor redundancy gaps and critical data loss scenarios, offering clear, actionable remediation paths without modifying the cluster state.
What it does
- Checks overall cluster health status to identify yellow or red states.
- Localizes issues to specific indices and shards for focused investigation.
- Analyzes allocation deciders to pinpoint the root cause of unassigned shards.
- Distinguishes between replica-related redundancy gaps and primary-related data loss.
- Provides specific remediation advice based on the identified decider class.
- Surfaces findings for operator action without executing state-mutating commands.
When to use it
- When an Elasticsearch cluster reports a yellow or red status.
- When there are unassigned shards or allocation failures in the cluster.
- Before performing deeper investigations or manual cluster interventions.
- To verify if a cluster is recovering on its own versus requiring manual intervention.
Advantages
- Ensures safe, read-only triage of cluster health issues.
- Prevents premature or incorrect remediation by identifying the true root cause.
- Educates operators on the distinction between primary and replica shard impacts.
- Provides clear, prioritized recovery paths for critical data loss scenarios.
Usage examples
- “My Elasticsearch cluster is yellow. How do I find out why?”
- The agent will run the health check, identify the index with unassigned replicas, explain the allocation decider (e.g., disk watermark), and suggest freeing disk space.
- “The cluster is red and I have unassigned primary shards. What should I do?”
- The agent will analyze the allocation failure, confirm if it is a no_valid_shard_copy scenario, and advise on restoring from a snapshot or bringing back the departed node.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/elastic/elasticsearch-cluster-health/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip elasticsearch-cluster-health.zip -d .agents/skills
Documentation by elastic
Diagnose Cluster Health
Triage a non-green Elasticsearch cluster read-only: localize the problem, classify the allocation decider, and report the single most likely cause with remediation. Never mutate cluster state — surface findings and let the operator act.
<!-- begin-partial: preamble -->
Environment Configuration
This skill executes Elasticsearch operations through the elastic CLI. If the
elastic CLI is not installed, tell the user what it is needed for. Do
not guess credentials, call the HTTP API directly, or attempt other workarounds.
This skill references operations in HTTP-shorthand form (e.g., GET /, GET /_cat/indices, GET /{index}/_mapping,
GET /{index}/_settings/index.mode, POST /_query). The Operations table at the end of this document
maps each shorthand to the equivalent elastic CLI command — always use the CLI rather than calling the HTTP API
directly.
<!-- end-partial: preamble -->
Process
Read the overall status. Call
GET /_cluster/health. Thestatusfield is the verdict:green— every primary and replica is assigned. Report healthy and stop.yellow— every primary is assigned but at least one replica is not. Data remains readable; redundancy is degraded. This is not data loss.red— at least one primary is unassigned. Data for that shard is unavailable; treat as urgent.
Also read
unassigned_shards,initializing_shards, andrelocating_shards. The decision: continue only when status is yellow or red. Ifinitializing_shards > 0andunassigned_shards == 0, the cluster is recovering on its own — callGET /_cat/recoveryto confirm progress, wait, and re-checkGET /_cluster/healthbefore escalating.Data needed: cluster-wide
statusand shard counters.Localize the problem to one index. Call
GET /_cluster/health?level=indicesand pick the index that drives the cluster-wide status:Any red index outranks every yellow index.
Among reds or yellows, prefer the index with the most
unassigned_shards.A red system index (
.security,.kibana*,.fleet-*) outranks application indices because the rest of the stack depends on it.
Optionally call
GET /_cat/shards/{index}?h=index,shard,prirep,state,unassigned.reasonto list every unassigned shard on that index and see whether failures are primaries (prirep=p) or replicas (prirep=r).The decision: focus the next steps on exactly one index — the one whose recovery unblocks the cluster.
Data needed: per-index
statusandunassigned_shards; shard role (primary vs replica) when available.Separate trigger from root cause. Call
POST /_cluster/allocation/explainwith no body so Elasticsearch selects an unassigned shard, or target the worst shard explicitly:{ "index": "<index>", "shard": <id>, "primary": <true|false> }Read these fields in order:
primary—falsemeans a replica is unassigned (typical yellow);truemeans a primary is unassigned (typical red).can_allocate— top-level allocation verdict (no,yes,throttled,no_valid_shard_copy, …).unassigned_info.reason— what triggered reassignment (e.g.NODE_LEFT,INDEX_CREATED). This is not the root cause whencan_allocateisno; it only explains why the shard became unassigned.allocate_explanation— human-readable summary; quote it verbatim in the report.node_allocation_decisions[].deciders[]— per-node decider results. Find deciders withdecision: "NO"; the decider name (e.g.disk_threshold,filter,awareness) is the root cause class.
The decision:
Yellow +
primary: false— impact is limited to replica redundancy; no data loss. Continue to step 4 to name the blocking decider (do not stop atNODE_LEFT).Red +
primary: true— data for that shard is missing. Continue to step 4; ifcan_allocateisno_valid_shard_copy, treat as potential data loss immediately.
Data needed: allocation-explain response for one representative unassigned shard on the chosen index.
Classify the decider. Map the blocking signal to a cause class. Prefer the decider with
decision: "NO"over theunassigned_info.reasontrigger.Signal Cause class Typical remediation (operator applies) decider: disk_threshold,decision: NODisk high/low watermark exceeded Free disk on the named node, add data-node capacity, or adjust cluster.routing.allocation.disk.watermark.*after confirming usage viaGET /_cat/allocationdecider: filterordecider: awareness,decision: NOAllocation filtering or zone awareness Add a node that satisfies index.routing.allocation.*/ awareness attributes, or adjust index/cluster allocation settingsdecider: throttlingor recovery in progressTransient recovery Wait; monitor GET /_cat/recoveryand re-checkGET /_cluster/healthcan_allocate: no_valid_shard_copy(often with emptynode_allocation_decisions)No surviving shard copy See step 5 — data loss scenario can_allocate: yesbut shard still unassignedDelayed allocation or cluster state catch-up Check unassigned_info.atdelay; wait and re-checkFor disk pressure (common yellow scenario after
NODE_LEFT): replicas relocate to remaining nodes; if a survivor is above the high watermark (cluster.routing.allocation.disk.watermark.high, default 90%), thedisk_thresholddecider blocks replica allocation even though primaries stay assigned. The fix is disk capacity or watermark relief — not deleting the index or forcing an empty primary.Data needed: decider name,
explanationtext, and affected node names fromnode_allocation_decisions.Recommend remediation — read-only triage ends here. Report the single most likely cause (decider class + verbatim
allocate_explanation) and one primary remediation path. Match urgency to color and shard role.Yellow / replica unassigned (no data loss):
State clearly: all primaries are assigned; only replicas are missing; no data loss.
Name the real decider (e.g. disk high watermark on
es-node-2), not merely “a node left”.Recommend: free disk space, expand storage, add data nodes, or adjust disk watermarks after reviewing
GET /_cat/allocation.Do not recommend: deleting the index,
allocate_empty_primary, force-allocating over a healthy primary, or restarting the entire cluster without evidence.
Red / primary unassigned with
no_valid_shard_copy(data loss risk):State clearly: a primary shard is unassigned; queries/routing for that shard fail; treat as urgent and localized to the named index.
Explain: the only copy was on the departed node; Elasticsearch cannot allocate a primary because no valid copy exists on any remaining node (
can_allocate: no_valid_shard_copy).Recovery paths in order:
Bring the departed node back if its data directory is intact — the shard copy returns.
Restore from snapshot into the index (or a new index followed by reindex) when snapshots exist.
Last resort only:
POST /_cluster/reroutewithallocate_empty_primary— this creates an empty primary and permanently loses all documents on that shard. State data loss explicitly; never present this as the first or casual fix.
Do not recommend: deleting the index without discussing data loss, or
allocate_empty_primarywithout the data-loss warning.
Self-healing in progress:
When deciders show throttling or active peer recovery, recommend waiting and re-checking read-only APIs above.
Do not execute reroutes, snapshot restores, or settings changes — surface cause and remediation only.
Guidelines
Read-only: Use only GET/POST explain APIs for triage. Remediation is advice; the operator performs writes.
Trigger ≠ cause:
unassigned_info.reason: NODE_LEFTexplains the event;node_allocation_decisionsdeciders explain why allocation still fails.Replica vs primary: Yellow +
primary: false= redundancy gap, not data loss. Red +primary: true= missing data for that shard.One index, one cause: Pick the highest-impact index and the strongest NO decider; avoid listing every shard.
Cat helpers: Use
GET /_cat/allocationfor disk percentages per node andGET /_cat/recoveryfor ongoing recoveries when the decider class is unclear or recovery is in progress.
Examples
Yellow — disk watermark after node departure. Health shows yellow with unassigned replicas on logs-2025-07.
Allocation explain returns primary: false, unassigned_info.reason: NODE_LEFT, but disk_threshold decider NO on
es-node-2 (“above the high watermark … 90%”). Report: no data loss; root cause is disk pressure on the receiving node;
remediate disk/watermark — not “node left” alone.
Red — primary with no valid copy. Health shows red on orders-2025 with one unassigned shard. Explain returns
primary: true, can_allocate: no_valid_shard_copy, last_allocation_status: no_valid_shard_copy. Report: urgent;
primary data missing; restore node or snapshot; mention allocate_empty_primary only as last resort with explicit data
loss.
Operations
| HTTP API (shorthand) | elastic CLI command |
|---|---|
GET /_cluster/health | elastic es cluster health |
GET /_cluster/health?level=indices | elastic es cluster health --level indices |
POST /_cluster/allocation/explain | elastic es cluster allocation-explain |
POST /_cluster/allocation/explain (specific shard) | elastic es cluster allocation-explain --index '<index>' --shard <id> --primary true (replica: false) |
GET /_cat/allocation | elastic es cat allocation |
GET /_cat/recovery | elastic es cat recovery |
GET /_cat/shards/{index}?h=index,shard,prirep,state,unassigned.reason | elastic es cat shards --index '<index>' --h index,shard,prirep,state,unassigned.reason |
POST /_cluster/reroute (last-resort empty primary — operator only) | elastic es cluster reroute --commands '<json>' |
Files
- ATTRIBUTION.mdAdded by AutoGineer1007 B
- LICENSELicence file added by AutoGineer11.1 KiB
- SKILL.md13.0 KiB
LICENSE
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2026 Elasticsearch BV
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs Node.js
The author says: Elasticsearch 8.x or 9.x, self-managed or Elastic Cloud Hosted; not applicable to Elastic Cloud Serverless, where cluster, shard, and allocation APIs are managed internally. Requires the `elastic` CLI ≥ 0.2 with `stack es` support.
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- elastic
- Publisher
- Elastic (Official)
- Source
- elastic/agent-skills · skills/elasticsearch/elasticsearch-cluster-health · commit 09d879d
- Licence
- Apache License 2.0 (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
- Also distributed in
- elastic/agent-skills
AutoGineer is not affiliated with or endorsed by elastic.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download elasticsearch-cluster-health.zip