id: searxng-engine-health-and-rate-limit-sentinel
namespace: company.ai
description: |
Continuously monitors SearXNG metasearch instance health and upstream search engine availability, detects provider rate-limiting and engine suspensions, and dispatches actionable Slack incident alerts to protect AI RAG pipelines.
inputs:
- id: searxng_host
type: STRING
displayName: SearXNG Instance Host
defaults: "http://searxng.internal:8080"
description: "Base HTTP URL of the target SearXNG metasearch server instance."
- id: test_query
type: STRING
displayName: Synthetic Validation Query
defaults: "kestra workflow orchestrator"
description: "Query string used by the probe task to evaluate metasearch
reachability and upstream response parsing."
- id: monitored_engines
type: STRING
displayName: Monitored Upstream Engines
defaults: "google,duckduckgo,bing,wikipedia"
description: "Comma-separated list of critical search engines that must remain
active and responsive."
- id: min_expected_results
type: INT
displayName: Minimum Expected Results
defaults: 1
description: "Minimum count of aggregated search results required for a probe to
be considered healthy."
- id: slack_channel
type: STRING
displayName: Operational Slack Channel
defaults: "#ai-ops"
description: "Target Slack channel or webhook destination for engine degradation
and incident alerts."
triggers:
- id: scheduled_sentinel_audit
type: io.kestra.plugin.core.trigger.Schedule
cron: "0 */4 * * *"
disabled: true
inputs:
searxng_host: "http://searxng.internal:8080"
test_query: "kestra workflow orchestrator"
monitored_engines: "google,duckduckgo,bing,wikipedia"
min_expected_results: 1
slack_channel: "#ai-ops"
tasks:
- id: probe_instance_health
type: io.kestra.plugin.core.http.Request
uri: "{{ inputs.searxng_host }}/healthz"
method: GET
headers:
Accept: application/json
timeout: PT15S
description: "Queries the SearXNG healthz endpoint to verify HTTP service
availability and process readiness."
- id: probe_synthetic_search
type: io.kestra.plugin.core.http.Request
uri: "{{ inputs.searxng_host }}/search?q={{ inputs.test_query | urlencode
}}&format=json"
method: GET
headers:
Accept: application/json
timeout: PT30S
description: "Executes a live synthetic query against SearXNG's JSON API to
measure upstream provider response latency and capture unresponsive
engines."
- id: route_engine_health_status
type: io.kestra.plugin.core.flow.Switch
value: >-
{% set search_data = outputs.probe_synthetic_search.body %} {% set
unresponsive = search_data.unresponsive_engines | default([]) %} {% set
result_count = search_data.number_of_results | default(0) %} {% set
critical_engines = inputs.monitored_engines | split(',') %} {% set
critical_down = [] %} {% for item in unresponsive %}
{% set engine_name = item[0] | default(item) %}
{% if engine_name in critical_engines %}
{% set _ = critical_down.add(engine_name) %}
{% endif %}
{% endfor %} {% if result_count < inputs.min_expected_results %}
SEARCH_EMPTY
{% elseif critical_down | length > 0 %}
DEGRADED
{% else %}
COMPLIANT
{% endif %}
cases:
COMPLIANT:
- id: log_compliant_status
type: io.kestra.plugin.core.log.Log
message: "SearXNG metasearch instance '{{ inputs.searxng_host }}' is healthy.
Aggregated {{ outputs.probe_synthetic_search.body.number_of_results
| default(0) }} results with zero critical engine outages."
DEGRADED:
- id: alert_engine_degraded_slack
type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook
url: "{{ secret('SLACK_WEBHOOK_URL') }}"
payload: |
{
"attachments": [
{
"color": "#FFA726",
"title": "⚠️ SearXNG Engine Degradation Detected",
"text": "Upstream search engine rate-limiting or outages detected on `{{ inputs.searxng_host }}`.\n*Unresponsive Engines:* `{{ outputs.probe_synthetic_search.body.unresponsive_engines | default([]) }}`\n*Results Aggregated:* `{{ outputs.probe_synthetic_search.body.number_of_results | default(0) }}`\n*Synthetic Query:* `{{ inputs.test_query }}`",
"footer": "Kestra Sentinel | AI RAG Availability Gate"
}
]
}
- id: log_degraded_status
type: io.kestra.plugin.core.log.Log
message: "One or more monitored upstream engines are unresponsive on '{{
inputs.searxng_host }}'. Investigation required."
SEARCH_EMPTY:
- id: alert_search_empty_slack
type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook
url: "{{ secret('SLACK_WEBHOOK_URL') }}"
payload: |
{
"attachments": [
{
"color": "#E53935",
"title": "❌ SearXNG Zero Results Outage",
"text": "SearXNG returned 0 search results for query `{{ inputs.test_query }}` on `{{ inputs.searxng_host }}`. Upstream providers may be blocked by CAPTCHA or IP rate-limiting.\n*Unresponsive Engines:* `{{ outputs.probe_synthetic_search.body.unresponsive_engines | default([]) }}`",
"footer": "Kestra Sentinel | Metasearch Outage Alert"
}
]
}
- id: log_audit_summary
type: io.kestra.plugin.core.log.Log
message: "Completed SearXNG metasearch health audit on {{ inputs.searxng_host }}
at {{ now() }}. Number of results: {{
outputs.probe_synthetic_search.body.number_of_results | default(0) }}."
errors:
- id: alert_probe_failure_slack
type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook
url: "{{ secret('SLACK_WEBHOOK_URL') }}"
payload: |
{
"attachments": [
{
"color": "#D32F2F",
"title": "🚨 SearXNG Sentinel Probe Failure",
"text": "The SearXNG health probe encountered an unhandled network error or connection timeout connecting to `{{ inputs.searxng_host }}`.\n*Execution ID:* `{{ flow.executionId }}`\n*Error Message:* `{{ flow.errorMessage | default('Unknown execution error') }}`",
"footer": "Kestra Orchestrator | Automated Incident Management"
}
]
}