Script icon
Docker icon
If icon
SlackIncomingWebhook icon
Log icon
Return icon
Schedule icon

OpenSearch Indexing Backpressure and Threadpool Rejection Sentinel

Audits OpenSearch cluster metrics to detect write threadpool rejections, indexing backpressure, and JVM heap pressure before bulk writes fail.

Categories
DataInfrastructure

Audits OpenSearch distributed search and analytics clusters across enterprise logging environments to detect write threadpool rejections, indexing backpressure stalls, and memory exhaustion.

How it works

  1. A schedule trigger executes the OpenSearch cluster audit workflow every 15 minutes.
  2. The Python task queries the OpenSearch Prometheus exporter or node stats endpoint (opensearch-cluster:9200/_prometheus/metrics).
  3. The script extracts write threadpool rejection totals, bulk queue depths, JVM heap memory utilization, and indexing pressure events.
  4. An evaluation gate determines whether write rejections, queue backlogs, or memory usage breach operational tolerance bounds.
  5. When thresholds are breached, a high-priority Slack alert is dispatched to search platform engineering and logging SREs.
  6. When bulk indexing executes smoothly without rejected tasks, nominal telemetry is logged.
  7. A structured JSON audit manifest is emitted for search platform governance compliance logs and indexing SLA archives.

Architecture diagram

graph TD
    Trigger[Schedule Trigger: 15m] --> ScanMetrics[Python Script: Scrape OpenSearch Metrics]
    ScanMetrics --> EvalBreach{Write Rejections >= Threshold OR Queue > 50?}
    EvalBreach -- Yes --> SlackAlert[Slack: High-Urgency Search Alert]
    EvalBreach -- No --> LogNominal[Log: Nominal OpenSearch State]
    SlackAlert --> EmitManifest[Debug Return: OpenSearch Audit Manifest]
    LogNominal --> EmitManifest

Architecture components

  • Trigger: Automated schedule polling at 15-minute intervals.
  • Script Task: Scrapes OpenSearch Prometheus metrics endpoints using Docker container isolation.
  • Decision Gate: Evaluates whether write rejections or indexing backpressure exceeds stability safety limits.
  • Notification Task: Dispatches structured Slack alerts with cluster identity and rejection metrics.
  • Audit Manifest: Emits JSON execution payloads containing search engine health and timestamps.

Key capabilities

  • Continuous surveillance of OpenSearch bulk indexing queues and write threadpool executor saturation.
  • Rapid detection of shard unbalance and hot node bottlenecks causing EsRejectedExecutionException.
  • Early warning before upstream ingestion shippers (Fluentbit, Logstash, Vector) drop documents due to 429 errors.
  • Zero external dependency execution via isolated containerized Python runners.

What you get

  • Preemptive alerting on search cluster ingestion degradation before log and event data is lost.
  • Automated tracking of JVM heap utilization against the critical 85% circuit breaker threshold.
  • Real-time audit manifests capturing search platform health for SOC 2 data analytics compliance.
  • Configurable tolerance thresholds adaptable to high-throughput log indexing and latency-sensitive search clusters.

Who it's for

  • Search Platform Engineers and SREs maintaining OpenSearch and Elasticsearch clusters.
  • Observability team leads safeguarding central security logging and APM trace storage.
  • Cloud infrastructure administrators provisioning persistent disk IOPS and JVM memory limits.
  • DevOps engineers troubleshooting sporadic 429 Too Many Requests errors during batch reindexing.

Why orchestrate this with Kestra

  • Deterministic Scheduling: Guarantees regular search platform audits without fragile local crontab scripts.
  • Containerized Runners: Runs Python tasks inside isolated Docker containers without host library dependencies.
  • Condition Branching: Flowable If tasks route alerts and nominal logging cleanly without spaghetti code.
  • Enterprise Secret Safety: Securely injects Slack webhook credentials without plain-text exposure.

Use cases

  • Spike in Application Logging: Detects write queue saturation when production microservices enter verbose debug loops.
  • Hot Shard Imbalance: Alerts when uneven routing keys overload a single data node while others sit idle.
  • JVM Stop-the-World GC Pause: Identifies long old-gen garbage collection pauses freezing node write threads.
  • Segment Merge Disk Throttling: Surfaces indexing slowdowns caused by underlying cloud block storage IOPS depletion.

Inputs

Name Type Default Description
opensearch_metrics_url STRING http://opensearch-cluster.search.svc.cluster.local:9200 Base HTTP URL exposing OpenSearch Prometheus metrics.
cluster_name STRING opensearch-log-search-prod Target OpenSearch analytical cluster identifier under surveillance.
max_write_rejections_threshold INT 10 Maximum allowable rejected write tasks before alerting.
lookback_minutes INT 15 Lookback evaluation window in minutes for failure rates.
alert_on_opensearch_failures BOOL true Toggle Slack alert dispatch upon detecting threadpool rejections.

Expected outputs

  • {{ outputs.scan_opensearch_cluster_metrics.vars.write_threadpool_rejections_count }}: Count of write tasks rejected by threadpool.
  • {{ outputs.scan_opensearch_cluster_metrics.vars.write_threadpool_queue_size }}: Current depth of write queue awaiting executor slots.
  • {{ outputs.scan_opensearch_cluster_metrics.vars.jvm_heap_utilization_pct }}: Percentage of allocated JVM heap memory in use.
  • {{ outputs.scan_opensearch_cluster_metrics.vars.indexing_backpressure_events_count }}: Count of indexing backpressure triggers.
  • {{ outputs.scan_opensearch_cluster_metrics.vars.is_alerting }}: Boolean flag indicating whether failure thresholds were breached.
  • {{ outputs.emit_audit_manifest.value }}: Structured JSON audit manifest emitted for compliance archives.

Prerequisites

  • OpenSearch cluster deployed with Prometheus exporter plugin or metrics endpoint enabled.
  • Metrics port 9200 reachable from the Kestra worker execution environment.
  • Docker daemon running on the Kestra host to execute containerized Python tasks.

Secrets

  • SLACK_WEBHOOK_URL: Incoming webhook URL for the target Search SRE Slack alerting channel.

Quick start

  1. Ensure OpenSearch cluster exposes Prometheus metrics via prometheus-exporter plugin.
  2. Configure the SLACK_WEBHOOK_URL secret in your Kestra namespace settings.
  3. Specify your OpenSearch cluster name in cluster_name.
  4. Execute a manual test run via the Kestra UI to verify metric ingestion.
  5. Enable the periodic_opensearch_audit trigger to establish automated continuous surveillance.

Common pitfalls and troubleshooting

  • Bulk Size Sizing: Oversized bulk requests (>15MB) overwhelm worker threads; batch requests into 5-10MB chunks.
  • Heap Maximum Cap: Never set OpenSearch JVM heap above 31GB to preserve Compressed Object Pointers (Compressed OOPs).
  • Refresh Interval Tuning: Default 1s refresh interval creates excessive small segments; increase to 30s for heavy logs.
  • Security Plugin TLS: When internal admin certificates are required, pass client certs in the scraper task.

How to extend

  • Automated Shard Rebalance: Trigger a cluster reroute sub-flow to redistribute shards away from overloaded data nodes.
  • Dynamic Index Refresh Interval: Chain a task to increase index.refresh_interval to 60s during ingestion surges.
  • PagerDuty Escalation: Escalate to on-call search engineers if write rejections exceed 50 per minute.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.