Elasticsearch Cluster Health logo

Elasticsearch Cluster Health

Organization
elastic
elasticsearch-cluster-health

Diagnose a non-green Elasticsearch cluster and surface the single most likely cause with remediation. Use when an operator reports yellow or red status, unassigned shards, allocation failures, or wants read-only triage before deeper investigation. Teaches replica-vs-primary impact, allocation decider classification, and data-loss awareness.

Overview

Publisherelastic
Repositoryagent-skills
Skill nameelasticsearch-cluster-health
Stars
589
Forks
53
Bundled files
Instructions only
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by elastic on GitHub. Read the source before you install it.

Installation

Install the Elasticsearch Cluster Health AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/elastic/agent-skills/tree/main/plugins/elasticsearch/skills/elasticsearch-cluster-health
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/elastic/agent-skills.git /tmp/agent-skills
mkdir -p .claude/skills
cp -r /tmp/agent-skills/plugins/elasticsearch/skills/elasticsearch-cluster-health .claude/skills/elasticsearch-cluster-health
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Elasticsearch Cluster Health in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Elasticsearch Cluster Health on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Elasticsearch Cluster Health is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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.

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.

Process

  1. Read the overall status. Call GET /_cluster/health. The status field 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, and relocating_shards. The decision: continue only when status is yellow or red. If initializing_shards > 0 and unassigned_shards == 0, the cluster is recovering on its own — call GET /_cat/recovery to confirm progress, wait, and re-check GET /_cluster/health before escalating.

    Data needed: cluster-wide status and shard counters.

  2. Localize the problem to one index. Call GET /_cluster/health?level=indices and 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.reason to 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 status and unassigned_shards; shard role (primary vs replica) when available.

  3. Separate trigger from root cause. Call POST /_cluster/allocation/explain with no body so Elasticsearch selects an unassigned shard, or target the worst shard explicitly:

    json
    { "index": "<index>", "shard": <id>, "primary": <true|false> }

    Read these fields in order:

    • primary — false means a replica is unassigned (typical yellow); true means 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 when can_allocate is no; 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 with decision: "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 at NODE_LEFT).
    • Red + primary: true — data for that shard is missing. Continue to step 4; if can_allocate is no_valid_shard_copy, treat as potential data loss immediately.

    Data needed: allocation-explain response for one representative unassigned shard on the chosen index.

  4. Classify the decider. Map the blocking signal to a cause class. Prefer the decider with decision: "NO" over the unassigned_info.reason trigger.

    SignalCause classTypical remediation (operator applies)
    decider: disk_threshold, decision: NODisk high/low watermark exceededFree disk on the named node, add data-node capacity, or adjust cluster.routing.allocation.disk.watermark.* after confirming usage via GET /_cat/allocation
    decider: filter or decider: awareness, decision: NOAllocation filtering or zone awarenessAdd a node that satisfies index.routing.allocation.* / awareness attributes, or adjust index/cluster allocation settings
    decider: throttling or recovery in progressTransient recoveryWait; monitor GET /_cat/recovery and re-check GET /_cluster/health
    can_allocate: no_valid_shard_copy (often with empty node_allocation_decisions)No surviving shard copySee step 5 — data loss scenario
    can_allocate: yes but shard still unassignedDelayed allocation or cluster state catch-upCheck unassigned_info.at delay; wait and re-check

    For 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%), the disk_threshold decider 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, explanation text, and affected node names from node_allocation_decisions.

  5. 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:
      1. Bring the departed node back if its data directory is intact — the shard copy returns.
      2. Restore from snapshot into the index (or a new index followed by reindex) when snapshots exist.
      3. Last resort only: POST /_cluster/reroute with allocate_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_primary without 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_LEFT explains the event; node_allocation_decisions deciders 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/allocation for disk percentages per node and GET /_cat/recovery for 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/healthelastic es cluster health
GET /_cluster/health?level=indiceselastic es cluster health --level indices
POST /_cluster/allocation/explainelastic 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/allocationelastic es cat allocation
GET /_cat/recoveryelastic es cat recovery
GET /_cat/shards/{index}?h=index,shard,prirep,state,unassigned.reasonelastic 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>'

Frequently asked questions

What does the Elasticsearch Cluster Health AI skill do?

Diagnose a non-green Elasticsearch cluster and surface the single most likely cause with remediation. Use when an operator reports yellow or red status, unassigned shards, allocation failures, or wants read-only triage before deeper investigation. Teaches replica-vs-primary impact, allocation decider classification, and data-loss awareness.

Why use Elasticsearch Cluster Health on TypingMind?

Because you install it once and use it with any model. Elasticsearch Cluster Health is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Elasticsearch Cluster Health in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/elastic/agent-skills/tree/main/plugins/elasticsearch/skills/elasticsearch-cluster-health. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Elasticsearch Cluster Health?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Elasticsearch Cluster Health?

As many as you like. As long as a model supports skills, you can use Elasticsearch Cluster Health with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Elasticsearch Cluster Health AI skill free?

Yes. It is published on GitHub by elastic under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇