Schedule icon
Request icon
If icon
SlackIncomingWebhook icon
Log icon

Audit Elasticsearch Cluster Health and Unassigned Shards

Audit Elasticsearch cluster health to detect unassigned shards, yellow or red status degradation, and node allocation failures with Slack alerts.

Categories
DataInfrastructure

How it works

This sentinel workflow automates Day 2 operational observability for distributed Elasticsearch clusters:

  1. Scheduled Audit Trigger: Periodically executes on a configurable cron schedule (0 */2 * * *, shipped disabled for safe onboarding) to inspect cluster status.
  2. Cluster Health API Probe: Uses native io.kestra.plugin.elasticsearch.Request to query GET /_cluster/health, capturing cluster status (green, yellow, red), unassigned shard counts, and active data nodes.
  3. Threshold & Status Evaluation: Evaluates cluster telemetry using Kestra's native io.kestra.plugin.core.flow.If task. If status is red (primary shards unassigned) or yellow (replica shards unassigned), the flow triggers the alert branch.
  4. Actionable Slack Alerting: Dispatches a color-coded Slack alert card detailing status severity, unassigned shard numbers, active nodes, and direct diagnostic runbook commands (/_cluster/allocation/explain).
  5. Failure Resilience: A top-level errors handler catches connection drops, SSL verification issues, or credential expirations and alerts engineers immediately.

What you get

  • Real-time visibility into Elasticsearch cluster degradation before search indexing stops.
  • Early warning when data node dropouts leave replica shards unassigned.
  • Full cluster health response metrics preserved in Kestra audit execution lineage.
  • Instant Slack alerts with exact curl commands for shard allocation diagnostics.

Who it's for

  • Search Platform Engineers: Maintaining high-availability Elasticsearch or OpenSearch clusters.
  • Site Reliability Engineers (SREs): Automating proactive cluster health guardrails across logging and analytics stacks.
  • DevOps Engineers: Ensuring search query latency and indexing throughput remain within strict SLA limits.

Why orchestrate this with Kestra

  • Native Elasticsearch Plugin: Leverage io.kestra.plugin.elasticsearch.Request with connection pooling, basic auth, and SSL configuration without writing custom wrapper daemons.
  • Secure Credential Isolation: Mask administrative passwords and webhook tokens using Kestra's encrypted secrets manager ({{ secret('...') }}).
  • Automated Remediation Chaining: Easily extend the workflow to trigger an automated POST /_cluster/reroute?retry_failed=true when transient disk watermarks clear.
  • Visual Observability: Inspect structured HTTP response payloads, task runtimes, and status outputs directly in the Kestra web interface.

Prerequisites

  • An accessible Elasticsearch cluster (7.x / 8.x) with HTTP API access from the Kestra worker.
  • An administrative or monitoring user with cluster monitor privileges.
  • A Slack Incoming Webhook URL.

Secrets

Configure the following secrets in your Kestra namespace or instance settings:

  • ELASTICSEARCH_USERNAME: Username for authenticating with the Elasticsearch cluster.
  • ELASTICSEARCH_PASSWORD: Password for the Elasticsearch user.
  • SLACK_WEBHOOK_URL: The incoming webhook URL for your designated search alerts channel.

Quick start

  1. Click Use Blueprint to install this flow in your Kestra instance.
  2. Add ELASTICSEARCH_USERNAME, ELASTICSEARCH_PASSWORD, and SLACK_WEBHOOK_URL to your Kestra secrets store.
  3. Adjust elasticsearch_url to match your cluster endpoint.
  4. Execute a manual test run to verify connectivity, then enable the schedule trigger.

How to extend

  • Shard Allocation Explainer: If unassigned shards exist, automatically invoke GET /_cluster/allocation/explain and embed the specific unassigned reason in the Slack payload.
  • Index-Level Grain: Chain with GET /_cat/shards to report the exact index names suffering from unassigned shards.
  • PagerDuty Escalation: Route alerts to PagerDuty if cluster status degrades to red.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.