GetProcessGroupStatus icon
If icon
StartProcessGroup icon
Log icon
OutputValues icon
SlackIncomingWebhook icon
Schedule icon

NiFi Process Group Restart Recovery Gate

Start a NiFi Process Group, verify activeThreadCount actually recovered, alert Slack if it did not, and log the result for data platform teams.

Categories
Infrastructure

Apache NiFi's Start API call tells you the request was accepted, not that the Process Group is actually processing anything again; a group can report 200 OK on start and still sit at zero active threads if the underlying stuck component was never really fixed. This blueprint treats the restart as unconfirmed until a fresh status read proves it, instead of trusting the API response alone.

This blueprint was created by Mohit Jeswani.

How it works

  1. probe_before (io.kestra.plugin.nifi.GetProcessGroupStatus) reads the current queuedCount and activeThreadCount before anything runs.
  2. route_confirm (io.kestra.plugin.core.flow.If) only calls io.kestra.plugin.nifi.StartProcessGroup when confirm_start is explicitly true; otherwise it logs the current state and changes nothing in NiFi.
  3. probe_after (io.kestra.plugin.nifi.GetProcessGroupStatus) re-reads status right after, regardless of which branch ran, so evaluate always has a current reading.
  4. evaluate (io.kestra.plugin.core.output.OutputValues) classifies DRY_RUN when nothing was started, CRITICAL when the post-start probe itself failed, RECOVERY_CONFIRMED when activeThreadCount reached min_active_threads_after_start, otherwise RECOVERY_NOT_CONFIRMED.
  5. route_result (io.kestra.plugin.core.flow.If):
    • compliant: logs DRY_RUN or RECOVERY_CONFIRMED with the current numbers.
    • alert: posts CRITICAL or RECOVERY_NOT_CONFIRMED to Slack.
  6. summary logs the final severity, closing the governance cycle.
  7. errors alerts Slack if the flow itself fails, for example an expired NiFi token.

What you get

  • A restart that is verified, not assumed: the Start API call succeeding and the group actually processing again are checked as two different things.
  • A safe default: confirm_start must be explicitly set to true for anything in NiFi to change, every other run is read-only.
  • A fully local test path against the official Apache NiFi Docker image, no NiFi cluster needed.

Who it's for

  • Data engineering and platform teams running Apache NiFi who restart a Process Group after fixing a stuck component and want proof it actually recovered, not just that the API call did not error.
  • Teams evaluating the NiFi plugin who want a worked example of StartProcessGroup paired with a verification probe, the companion half of this repo's existing NiFi backlog and stall sentinel, which stops a group but deliberately leaves starting it back up as a separate, explicit flow run, this one.

Why orchestrate this with Kestra

NiFi's Start API reports whether the request was accepted, not whether the fix actually worked; confirming that takes a second read and a human (or a flow) comparing the two. Kestra keeps confirm_start as an explicit flow input instead of a habit of trusting the API response, turns an unconfirmed restart into a Slack page naming the real numbers, and keeps a full execution history of every attempt.

Prerequisites

  • For local testing, the official Apache NiFi Docker image with single-user authentication:

    docker run --name nifi -d -p 8443:8443 \\
      -e SINGLE_USER_CREDENTIALS_USERNAME=admin \\
      -e SINGLE_USER_CREDENTIALS_PASSWORD="<a-password-at-least-12-characters>" \\
      apache/nifi:latest
    

    NiFi's single-user password must be at least 12 characters or the image generates a random one instead and logs it, check the container logs if login fails. The UI and REST API are both served over HTTPS on port 8443 with a self-signed certificate by default, which is why ssl_verify defaults to false here.

  • A Process Group already stopped (for example by this repo's backlog and stall sentinel, or manually in the NiFi canvas) to exercise confirm_start: true against.

  • For real NiFi, a user with permission to view and modify the target Process Group's state.

  • A Slack incoming webhook URL.

Secrets

  • NIFI_PASSWORD: password for nifi_username. In Kestra OSS, provide it as the base64-encoded environment variable SECRET_NIFI_PASSWORD.
  • SLACK_WEBHOOK_URL: used by alert and the errors block. In Kestra OSS, provide it as the base64-encoded environment variable SECRET_SLACK_WEBHOOK_URL.

Inputs

Input Default Purpose
process_group_id root Process Group to restart and verify
confirm_start false Must be true for start_process_group to actually run
min_active_threads_after_start 1 Minimum activeThreadCount required for RECOVERY_CONFIRMED

Outputs

  • {{ outputs.probe_before.queuedCount }} / .activeThreadCount: state before any action.
  • {{ outputs.probe_after.queuedCount }} / .activeThreadCount: state immediately after.
  • {{ outputs.evaluate.values.severity }}: DRY_RUN, RECOVERY_CONFIRMED, RECOVERY_NOT_CONFIRMED, or CRITICAL.

Pitfalls

  • probe_after reads status immediately after start_process_group returns; NiFi may take a few seconds to actually spin threads up on a group with many components, so a single RECOVERY_NOT_CONFIRMED immediately after a real start can be spin-up latency rather than a genuine failure. Rerun this flow a minute later before concluding the fix did not work.
  • StartProcessGroup starts every component in the targeted Process Group; if the stuck component itself still errors immediately after starting, activeThreadCount can still read 0 even though the API call succeeded, which is exactly the case this gate is built to catch.
  • This flow never stops a group; it only starts one and verifies the result. Use this repo's NiFi backlog and stall sentinel to detect and pause a stuck group in the first place.

Quick start

  1. Start the NiFi container above and add the NIFI_PASSWORD and SLACK_WEBHOOK_URL secrets.
  2. Stop a Process Group (via this repo's backlog sentinel, or manually in the NiFi canvas).
  3. Run this flow with confirm_start: false and confirm log_dry_run reports the stopped state without changing anything.
  4. Rerun with confirm_start: true and confirm compliant or alert reports RECOVERY_CONFIRMED or RECOVERY_NOT_CONFIRMED matching the real outcome.

How to extend

  • Loop this flow over a list of Process Group IDs with io.kestra.plugin.core.flow.Loop to restart and verify several groups fixed in the same maintenance window.
  • Chain this flow as a follow-up execution triggered from the backlog and stall sentinel's own Slack alert, once an operator confirms the stuck component is fixed.
  • Add a second, later-scheduled run with confirm_start: false to catch a group that showed RECOVERY_CONFIRMED immediately but stalled again shortly after.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.