Webhook icon
Schedule icon
WorkingDirectory icon
Commands icon
Docker icon
Script icon
Loop icon
If icon
Log icon
SlackIncomingWebhook icon

Catch Wazuh Agents and Detection Rules Going Dark

Grade a Wazuh manager snapshot for agent check-in lag and silent detection rules, loop every agent, and page Slack when the fleet goes dark.

Categories
Infrastructure

An agent that stops checking in leaves a hole in the coverage map and a rule that stops firing leaves a second one, but Wazuh only shows both to whoever opens the dashboard. This blueprint takes one manager state report, grades every agent and every rule in a shared workspace, walks the graded agents for the execution record and escalates through Slack the moment the fleet goes dark, all with the verdict published as outputs.

How it works

  1. post_manager_state (io.kestra.plugin.core.trigger.Webhook, keyed with the WAZUH_WEBHOOK_KEY secret) accepts the state JSON after each check-in cycle; hourly_health_sweep (io.kestra.plugin.core.trigger.Schedule, cron 0 * * * *) ships disabled: true until an operator switches it on.
  2. checkin_workspace (io.kestra.plugin.core.flow.WorkingDirectory) opens one shared directory. write_state_snapshot (io.kestra.plugin.scripts.shell.Commands on the Docker runner, image python:3.12-slim) writes the posted body, or the manager_state input default on manual runs, into manager_state.json with a quoted heredoc, and grade_checkins (io.kestra.plugin.scripts.python.Script) reads exactly that file. Both children are scripts inside the workspace and every notification sits after the block, because default tasks are stateless and a temp dir is purged when a task completes.
  3. grade_checkins flags an agent as blind when its status is not active or its last check-in lag passes checkin_threshold_minutes, flags a rule as silent when its 24 hour fire count sits under expected_rule_fires, and prints healthy, blind_spots, or error with the counts as one ::{"outputs": ...}:: line.
  4. loop_agents (io.kestra.plugin.core.flow.Loop, runIf the graded agent list is non empty) walks every agent and log_agent_state (io.kestra.plugin.core.flow.If) records its lag and rule contribution under log_blind_agent or log_reporting_agent, so the history names the blind spot even when the gate passes.
  5. gate_fleet_health (io.kestra.plugin.core.flow.If) escalates blind_spots into alert_blind_spots (io.kestra.plugin.slack.notifications.SlackIncomingWebhook), an error run routes through check_state_error and alert_unreadable_state, and a clean fleet lands in log_fleet_healthy. The flow level errors handler reports any workspace or script failure with the execution id.

What you get

  • One gateable verdict, healthy, blind_spots, or error, that any parent flow or promotion pipeline can branch on.
  • Escalation where the team already works, a Slack alert naming the dark agents, the silent rules and the worst lag.
  • A fail safe posture, an unreadable manager state escalates instead of reading as a clean fleet.
  • An execution record that lists every agent's lag and rule contribution run over run, not just a summary count.
  • The blind agent names, the worst lag and the silent rules as typed outputs for evidence packs.

Who it's for

  • Detection engineers who own Wazuh coverage and need silent rules surfaced before an audit does.
  • Platform and SRE teams that run Wazuh agents across mixed fleets and want dark agents paged, not noticed.
  • Security leads who need a dated record that the fleet was checked, agent by agent, on every run.

Why orchestrate this with Kestra

Wazuh reports state but never pages anyone about it, so the check-in gap and the dead rule wait for a human to open the app. Kestra supplies the keyed webhook for the manager sidecar, two typed thresholds as inputs, a shared workspace where the snapshot and the grade read one file, a loop that records every agent in the history, a verdict branch that separates the all clear from the page, and Slack routing from one declarative file. A cron job on the manager gives you none of that, it only prints to a log nobody reads.

Prerequisites

  • A worker with Docker access, both workspace children run in python:3.12-slim.
  • A reporter step that POSTs manager state shaped as a manager name plus an agents array carrying name, status, last_checkin_minutes and rules_fired_24h, and a rules array carrying name and fired_24h, for example assembled from the Wazuh API agent summary and the rule fire counters.
  • A Slack incoming webhook for the blind spot alert, the unreadable state alert and the failure handler.

Secrets

  • WAZUH_WEBHOOK_KEY: key guarding the state webhook URL, anyone holding it can post fleet state.
  • SLACK_WEBHOOK_URL: Slack incoming webhook URL used by the blind spot alert and the errors handler.

Quick start

  1. Add the two secrets to your Kestra namespace.
  2. Run the flow once with the default inputs and confirm verdict is blind_spots, the fixture carries the never connected k8s-edge-007 and the silent Local Rootkit Detection.
  3. POST an all active state body to the webhook and watch verdict flip to healthy with blind_count at 0 in the outputs.
  4. Point a manager sidecar at /api/v1/{tenant}/executions/webhook/{namespace}/wazuh-agent-checkin-rule-health-gate/{WAZUH_WEBHOOK_KEY} and enable hourly_health_sweep once the sidecar is live.

How to extend

  • Pull live inventory before grading by adding an io.kestra.plugin.core.http.Request task in front of the workspace that reads the Wazuh API agent summary with a WAZUH_API_TOKEN secret.
  • Fan the grade across managers with io.kestra.plugin.core.flow.ForEachItem over a manager list, each subflow posting its own state.
  • Keep the previous verdict in the Kestra KV store and page only when a healthy fleet turns blind, so a standing blind spot does not re-page every hour.
  • Turn a blind spot into a red run by adding io.kestra.plugin.core.execution.Fail under gate_fleet_health.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.