New to Kestra?
Use blueprints to kickstart your first workflows.
Poll a Flink job via REST, alert Slack on a failed or unexpected terminal state, and log the result for streaming platform teams.
A Flink job that fails mid-stream does not page anyone on its own; the JobManager UI shows the state if someone opens it, and nothing in Flink itself compares that state against what you expected or notifies a channel. This blueprint polls the job's own REST status and treats reaching a terminal state outside your expected list as a governance event worth paging on, not a dashboard someone has to remember to check.
This blueprint was created by Mohit Jeswani.
job_terminal_watch (io.kestra.plugin.flink.MonitorJob) polls the JobManager REST API
every 30 seconds and fires exactly one execution the moment the job reaches a terminal
state (FINISHED, CANCELED, or FAILED). failOnError: false keeps the trigger firing
an execution on FAILED instead of failing the trigger itself before evaluate can run.evaluate (io.kestra.plugin.core.output.OutputValues) classifies the trigger's own
success flag and finalState: a state in expectedTerminalStates is OK, FAILED is
JOB_FAILED, anything else unexpected (for example an operator-initiated CANCELED that
was not expected) is UNEXPECTED_TERMINATION.route (io.kestra.plugin.core.flow.If):stateDetails to Slack.summary logs the final state and severity, closing the governance cycle.errors alerts Slack if the orchestration flow itself fails, separate from a Flink job
failure, which is handled by alert above.MonitorJob used as a
standing governance trigger, distinct from this repo's existing Flink blueprints, which use
Submit, SubmitSql, and TriggerSavepoint rather than terminal-state monitoring.Flink's REST API reports job state on request; it does not decide which terminal states are
expected, compare the actual state against that list, or notify a Slack channel when they
diverge. Kestra keeps expectedTerminalStates as trigger configuration, turns a state
mismatch into a Slack page naming the exact state and details, and keeps a full execution
history of every terminal event.
jobId of a job already submitted to that cluster (for example via this repo's
flink-stateful-job-savepoint-restart-drill blueprint, or flink run).This flow polls the Flink REST API directly; a local Flink cluster can be run via the
official flink:1.20 Docker image for an end-to-end local test, no managed Flink service
required.
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.This blueprint has no flow inputs; restUrl, jobId, and expectedTerminalStates are
trigger configuration, set directly on job_terminal_watch since a polling trigger has no
execution inputs to render from.
{{ trigger.jobId }} / .finalState / .stateDetails / .success: the terminal state
MonitorJob observed, available to every downstream task as trigger variables.{{ outputs.evaluate.values.severity }}: OK, JOB_FAILED, or UNEXPECTED_TERMINATION.restUrl and jobId are trigger-level configuration, not flow inputs; editing them means
editing the trigger block itself, not passing a different value at execution time.expectedTerminalStates defaults to ['FINISHED'] only; a job that is expected to be
manually CANCELED as part of normal operation needs CANCELED added to that list or
every such cancellation reports UNEXPECTED_TERMINATION.jobId) for the next run.SLACK_WEBHOOK_URL secret.flink:1.20 Docker image, or against a real cluster) and
note its jobId from the JobManager UI or REST API.restUrl and jobId on job_terminal_watch to that cluster and job.compliant or alert fires matching
the job's actual outcome.CANCELED to expectedTerminalStates for jobs that are routinely stopped manually as
part of a deploy, so a planned cancellation does not page as UNEXPECTED_TERMINATION.io.kestra.plugin.flink.Submit in the alert branch to automatically resubmit the
job from its last savepoint, gated behind an auto_restart input so the first version of
this flow stays alert-only.JOB_FAILED to an on-call paging channel and UNEXPECTED_TERMINATION to a lower-
urgency channel, since an unexpected cancel and an actual failure usually have different
owners.