Schedule icon
Request icon
Return icon
Switch icon
SlackIncomingWebhook icon
Log icon

OpenSearch Cluster Health and Unassigned Shard Sentinel

Audit OpenSearch cluster health, detect degraded yellow or red states, and alert Slack on unassigned shard accumulation before search outages occur.

Categories
Infrastructure

Production search and log analytics clusters running OpenSearch can degrade silently before applications experience total outages. When a node restarts, disk watermarks trip, or index shards fail to allocate, OpenSearch transitions from green to yellow (missing replica shards) or red (missing primary shards). Without proactive monitoring, engineers often only discover these issues after users report slow search queries or indexing operations fail.

This blueprint provides an automated sentinel that proactively monitors OpenSearch cluster health and shard allocation on a scheduled basis. It checks both cluster-level status and underlying shard allocation diagnostics, classifies cluster operational state, and dispatches context-aware Slack alerts.

How it works

  1. A disabled-by-default io.kestra.plugin.core.trigger.Schedule triggers the workflow every 15 minutes, or upon manual execution by platform engineers.
  2. probe_cluster_health (io.kestra.plugin.opensearch.Request) queries _cluster/health with allowFailure: true to retrieve the current cluster status (green, yellow, red), active shards count, and unassigned shards count.
  3. probe_cluster_allocation (io.kestra.plugin.opensearch.Request) queries _cluster/allocation/explain with allowFailure: true to capture diagnostic explanations when shard allocation issues occur.
  4. classify_health_status (io.kestra.plugin.core.debug.Return) evaluates probe outputs using Pebble expressions, categorizing cluster state into PROBE_FAILED, CLUSTER_RED, CLUSTER_YELLOW, or HEALTHY.
  5. route_by_health_status (io.kestra.plugin.core.flow.Switch) routes downstream actions:
    • On CLUSTER_RED: Dispatches a critical incident alert to Slack indicating missing primary shards.
    • On CLUSTER_YELLOW: Dispatches a warning alert to Slack flagging unassigned replica shards.
    • On PROBE_FAILED: Dispatches an unreachable cluster or authentication failure alert.
    • On HEALTHY: Emits an operational confirmation log with active shard counts.
  6. log_audit_summary (io.kestra.plugin.core.log.Log) records an immutable audit log entry with execution ID, cluster status, and shard counts.
  7. A top-level errors handler catches unexpected orchestration faults and notifies Slack.

What you get

  • Automated cluster health monitoring evaluating primary and replica shard availability.
  • Tiered Slack alerts differentiating between catastrophic red states and degraded yellow states.
  • Early warning detection for unassigned shard accumulation before disk watermarks trigger write blocks.
  • An immutable audit trail of cluster health metrics across every scheduled execution.

Who it's for

  • Platform Engineers and Site Reliability Engineers managing OpenSearch or Elasticsearch clusters.
  • Data Infrastructure teams responsible for centralized log analytics and search clusters.
  • DevOps teams maintaining containerized search backends.

Why orchestrate this with Kestra

Monitoring distributed search clusters with cron scripts often leads to silent monitoring failures, unmanaged credentials, and unformatted alerts that lack diagnostic context. Kestra provides native OpenSearch tasks, declarative secret management, robust conditional branching via Pebble, and built-in Slack alerting within a single maintainable, auditable workflow.

Prerequisites

  • A running OpenSearch cluster (e.g., standard Docker image opensearchproject/opensearch:2.14.0).
  • Network connectivity from the Kestra worker to the OpenSearch HTTP REST API.
  • A Slack incoming webhook URL for alerting.

Secrets

  • OPENSEARCH_USERNAME: Username for OpenSearch HTTP basic authentication (required).
  • OPENSEARCH_PASSWORD: Password for OpenSearch HTTP basic authentication (required).
  • SLACK_WEBHOOK: Slack Incoming Webhook URL used for dispatching alert notifications (required).

Quick start

  1. Configure OPENSEARCH_USERNAME, OPENSEARCH_PASSWORD, and SLACK_WEBHOOK in your Kestra namespace secrets.
  2. Start a local single-node OpenSearch container for testing if needed: docker run -d -p 9200:9200 -e "discovery.type=single-node" -e "OPENSEARCH_INITIAL_ADMIN_PASSWORD=AdminPassword123!" opensearchproject/opensearch:2.14.0
  3. Import this blueprint into Kestra and click Execute with default parameters.
  4. Verify the audit log output in the execution logs tab.
  5. Enable the every_15_minutes schedule trigger to establish automated monitoring.

How to extend

  • Add automated shard rerouting: wire an io.kestra.plugin.opensearch.Request task on CLUSTER_YELLOW to POST _cluster/reroute?retry_failed=true to automatically retry stuck shards.
  • Add disk watermark monitoring: add a probe for _nodes/stats/fs to detect disk space saturation before shards get blocked.
  • PagerDuty integration: replace or supplement Slack alerts with PagerDuty incidents for immediate on-call escalation during red cluster states.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.