Self-Healing
Pilot can automatically detect and repair cluster issues without manual intervention. Three independent healing loops run in the background, each targeting a different class of problem.
Healing Loops
Activity-Based Healing
Rebalances partitions based on throughput and activity to maintain even load distribution across brokers.
Activity healing uses the same measurement readiness, sustained-benefit and freshness checks as default manual application. The exact final plan must stay worth applying across three fresh, compatible measurements. Pilot rechecks that plan against current measurements before submission. See Reducing Unnecessary Movement and Recent Moves.
A skipped cycle with data_not_ready is waiting for measurement history, freshness or settling. benefit_unconfirmed means the plan’s sustained benefit has not been established. Finishing the settling period allows reevaluation; automatic application still requires the healing loop to run and pass its safety, time-window, cooldown, dry-run and license checks.
After Pilot’s own moves, activity healing waits before it acts again:
- Measurements must settle first, normally 5 to 30 minutes. See Settling After Moves.
- Partitions Pilot just moved stay out of balancing plans for 30 minutes, and activity healing waits until they are free (skip reason
partitions_in_cooldown). See Recent Moves.
Repairs do not wait for either. Every loop, repairs included, skips its cycles for 30 minutes after its own last apply (skip reason cooldown). A Pilot restart clears these waits. For HA mode, see Measurements after a failover.
PILOT_HEAL_ENABLED=false # Enable activity rebalancing
PILOT_HEAL_INTERVAL=30m # Check intervalCritical Fixes
Repairs under-replicated partitions (URPs) and rack-awareness violations. This is the most urgent healing loop.
PILOT_HEAL_CRITICAL_ENABLED=false # Enable critical fixes
PILOT_HEAL_CRITICAL_INTERVAL=5m # Check intervalReplication Factor Increases
Automatically increases replication factor for partitions below the configured target.
PILOT_HEAL_RF_ENABLED=false # Enable RF increases
PILOT_HEAL_RF_INTERVAL=15m # Check intervalSee Replication Factor for details on the target RF feature.
Common Settings
These settings apply to all three healing loops:
| Variable | Default | Description |
|---|---|---|
PILOT_HEAL_DRY_RUN | true | Simulate only - log what would be done without applying changes |
PILOT_HEAL_MAX_PARTITIONS_PER_RUN | 0 | Maximum partitions moved per healing cycle (0 = unlimited, set > 0 to cap) |
PILOT_HEAL_WINDOW_START | -1 | Allowed start hour (0-23, -1 = always) |
PILOT_HEAL_WINDOW_END | -1 | Allowed end hour (0-23, -1 = always) |
For activity healing, the per-run partition limit applies when the plan is calculated, so a limit may leave no worthwhile balance plan. Repairs can be applied in batches; they do not need to improve balance.
Time Windows
Restrict healing to specific hours of the day:
# Business hours only
PILOT_HEAL_WINDOW_START=8
PILOT_HEAL_WINDOW_END=17
# Overnight maintenance window
PILOT_HEAL_WINDOW_START=22
PILOT_HEAL_WINDOW_END=5
# Always (default)
PILOT_HEAL_WINDOW_START=-1
PILOT_HEAL_WINDOW_END=-1Overnight windows are supported - setting START=22 and END=5 means 22:00-05:59.
A heal has no time limit, so the window is what bounds it: when the window closes on a running heal, Pilot cancels the heal’s remaining moves and records selfheal.cancel. The heal then counts as an error, its proposal is marked failed, and it starts no cooldown. In HA mode, Pilot keeps the cancel in its operation journal, so after a failover the next leader finishes it. A leader that resumes a heal outside its window cancels the heal the same way. See Audit Log.
Recommended Rollout
- Enable with dry-run - set
PILOT_HEAL_DRY_RUN=trueand enable the desired loops - Monitor logs - review what Pilot would have done
- Enable critical fixes first -
PILOT_HEAL_CRITICAL_ENABLED=truewithPILOT_HEAL_DRY_RUN=false - Add activity healing -
PILOT_HEAL_ENABLED=trueafter validating critical fixes work correctly - Consider time windows - restrict healing to low-traffic periods if needed
Priority
When multiple healing loops want to act simultaneously, Pilot uses a priority system:
- Critical fixes - highest priority (URP repair, rack violations)
- RF increases - medium priority
- Activity rebalancing - lowest priority
A lower-priority loop is skipped if a higher-priority loop is actively running.
No loop interrupts a running execution. A critical or RF repair that comes due while another heal, a manual apply or a drain runs skips its cycle (skip reason higher_priority_running, active_reassignments or reassignment_in_progress) and tries again at its next interval. To end an execution that makes no progress, cancel it; see Execution Time.
Generated proposals also separate repairs from optional balancing. If repairs are needed, Pilot proposes those first and reassesses balance after they complete and measurements settle.
License Requirement
Self-healing requires a valid license to apply changes. Without one, each cycle is skipped with the license_invalid skip reason. When the license expires during a heal, no new moves go out; the moves Kafka already has finish, including their final leader election, and the heal waits until a valid license returns or someone cancels it; see Licensing. In dry-run mode with a valid license, cycles are skipped with dry_run after logging what would be applied.
Audit Log
Every submitted automatic apply is recorded in the audit log as selfheal.apply, attributed to pilot, with the proposal ID, the trigger (activity, critical or rf) and one row per partition.
- A heal that fails adds an event with status
500and marks its proposalfailed. - A heal cancelled by its time window is also recorded as
selfheal.cancel. - A heal a user cancels is recorded as
reassignments.cancel(in HA moderebalance.cancel_requested) and marks its proposalcancelled. - Dry runs and skipped cycles record nothing.
These events cannot be reverted from the audit log. See How Operations End for how a heal ends.
Prometheus Metrics
| Metric | Description |
|---|---|
pilot_selfhealing_runs_total | Total executions by type and result |
pilot_selfhealing_skipped_total | Skipped runs with reasons |
pilot_selfhealing_last_success_timestamp_seconds | End of the last successful run, or the start of self-healing before the first success; no series while the type is disabled or self-healing runs in dry run |
pilot_selfhealing_in_progress | 1 while a run of the type is in progress |
pilot_selfhealing_reassignments_applied_total | Partitions submitted by successful applies |
Alert when critical healing stops running while URPs exist:
(time() - pilot_selfhealing_last_success_timestamp_seconds{type="critical"} > 1800)
and ignoring(type) (pilot_cluster_under_replicated_partitions - pilot_cluster_urps_from_reassignments > 0)
unless ignoring(type) pilot_selfhealing_in_progress{type="critical"} == 1Use it with for: 15m, as in the example alert rules. Partitions that are under-replicated only because a reassignment is still copying their new replicas do not count; a real shrink during a long rebalance does, and then the alert reports that the critical heal cannot run.
See Prometheus Metrics for the full reference.