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

Meilisearch Indexing Queue Staleness Sentinel

Audits Meilisearch search clusters for indexing task queue backlog and document processing stalls, delivering actionable alerts to engineering on Slack.

Categories
DataInfrastructure

Modern search-driven applications rely on Meilisearch for ultra-fast, typo-tolerant search experiences across product catalogs, knowledge bases, and user directories. Meilisearch processes document additions, updates, and schema modifications asynchronously in an internal task queue. Under heavy write spikes, unbatched document uploads, or disk I/O saturation, indexing tasks can stall or accumulate silently behind long-running schema updates. Because search query endpoints continue returning cached or stale results with HTTP 200 responses, standard black-box HTTP monitors fail to detect ingestion pipeline degradation. This sentinel inspects the Meilisearch Tasks API on a 10-minute cadence, tracks queued task volume and the age of in-flight mutations, and alerts platform engineers on Slack before search freshness regressions impact end users.

How it works

  1. Scheduled triggering: Executes every 10 minutes via automated cron trigger (*/10 * * * *) or runs on-demand via manual execution.
  2. Task queue enumeration: Queries the Meilisearch REST API endpoint /tasks with filters for enqueued and processing task statuses.
  3. Backlog and age evaluation: Measures the total pending task count and parses ISO timestamps to compute the exact age of the oldest active mutation.
  4. Threshold comparison: Verifies whether total pending tasks exceed max_enqueued_tasks_threshold or if any single task duration surpasses max_task_age_seconds_threshold.
  5. Conditional alerting: An io.kestra.plugin.core.flow.If flowable checks if the cluster is marked stalled and dispatches a Slack alert to #search-platform-alerts.
  6. Audit manifest export: Logs the operational summary and exports a structured diagnostic payload detailing task types and durations for observability platforms.

Architecture diagram

flowchart TD
  A[ten_minute_meilisearch_audit Schedule Trigger] --> B[evaluate_indexing_queue Python Script]
  B --> C[check_indexing_staleness Flowable If]
  C -- Queue Stalled --> D[notify_slack_indexing_stall Webhook]
  C -- Queue Nominal --> E[log_indexing_status Log]
  D --> E
  E --> F[export_indexing_manifest Return]

What you get

  • Continuous proactive monitoring of Meilisearch document ingestion queues without impacting search latency.
  • Automated detection of stuck tasks, unbatched bulk write saturation, and schema rebuild lockups.
  • Contextual Slack alerts containing exact backlog counts, oldest task age, and direct cluster endpoints.
  • Structured JSON manifests tracking indexing queue health over time.

Who it's for

  • Search Platform Engineers managing self-hosted or managed Meilisearch clusters.
  • Site Reliability Engineers maintaining low-latency e-commerce search infrastructure.
  • Data Engineers orchestrating high-throughput document ETL and sync pipelines into Meilisearch.

Why orchestrate this with Kestra

Meilisearch decouples search querying from indexing via an asynchronous single-threaded batch queue. While this architecture guarantees sub-50ms search query performance, it conceals indexing pipeline stalls behind HTTP 200 responses. Kestra provides scheduled orchestration with native container isolation, secret management for master API keys, conditional flow routing, and multi-channel alerting plugins. By running the sentinel in Kestra, teams avoid spinning up complex external cron runners while gaining full audit logs and execution history.

Use cases

  • E-Commerce Catalog Sync Protection: Detect when inventory, price, or product availability syncs are stalled behind huge bulk updates.
  • SaaS Knowledge Base Freshness: Ensure newly published articles and documentation edits are indexed promptly and made searchable for customers.
  • Multi-Tenant Search Health Verification: Monitor task queues across multiple distributed search nodes to ensure tenant isolation SLAs are respected.

Inputs

Name Type Default Description
meilisearch_host STRING https://search.internal.company.com:7700 Base HTTP endpoint of the Meilisearch cluster or cloud instance.
max_enqueued_tasks_threshold INT 100 Maximum allowable pending and processing indexing tasks before flagging an ingestion stall.
max_task_age_seconds_threshold INT 300 Maximum allowable duration in seconds for the oldest processing task before declaring a stuck pipeline.
target_index_uid STRING all Specific index UID to monitor, or all to audit all active indexes across the cluster.
alert_on_staleness BOOL true Whether to dispatch automated Slack notifications when indexing stalls or backlogs are detected.

Expected outputs

  • {{ outputs.evaluate_indexing_queue.vars.total_pending_tasks }}: Total number of pending and processing tasks currently in the Meilisearch queue.
  • {{ outputs.evaluate_indexing_queue.vars.oldest_task_age_seconds }}: Age in seconds of the oldest active indexing task.
  • {{ outputs.evaluate_indexing_queue.vars.is_stalled }}: Boolean flag indicating whether the indexing queue has breached configured thresholds.
  • {{ outputs.export_indexing_manifest.value }}: Structured dictionary containing the complete diagnostic manifest.

Prerequisites

  • Outbound HTTP or HTTPS network connectivity from Kestra workers to the Meilisearch instance.
  • A Meilisearch Master Key or API Key with read permissions for the /tasks route.
  • An incoming Slack webhook endpoint configured in Kestra secrets.

Secrets

  • MEILISEARCH_MASTER_KEY: Meilisearch API key or master key with permissions to query task statuses.
  • SLACK_WEBHOOK_URL: Slack Incoming Webhook URL used to dispatch incident notifications.

Quick start

  1. Register MEILISEARCH_MASTER_KEY and SLACK_WEBHOOK_URL in your Kestra secret manager.
  2. Import this blueprint into your Kestra instance under the company.search namespace.
  3. Set meilisearch_host to your internal Meilisearch endpoint and adjust max_enqueued_tasks_threshold to your workload.
  4. Run a manual execution to verify network reachability and confirm diagnostic output format.

Common pitfalls and troubleshooting

  • Master key permissions: Ensure the API key supplied in MEILISEARCH_MASTER_KEY has permission to inspect tasks across all index UIDs; restricted keys may return 403 Forbidden.
  • Batching document uploads: If tasks frequently breach the age threshold, ensure upstream ingest pipelines batch document mutations rather than sending individual document payloads.
  • Disk I/O bottlenecks: Meilisearch uses LMDB for memory-mapped storage. High disk latency can cause indexing task durations to spike significantly.

How to extend

  • Automated Task Cancellation: Add a downstream HTTP task to invoke DELETE /tasks?statuses=enqueued if runaway rogue tasks block the queue.
  • PagerDuty Escalation: Route critical staleness alerts to PagerDuty or Opsgenie if the search queue remains stalled across three consecutive runs.
  • Automated Index Dump and Backup: Trigger an automated snapshot or dump of the search index before clearing stuck queues.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.