New to Kestra?
Use blueprints to kickstart your first workflows.
Push batch job duration and success metrics from Kestra to the Prometheus Pushgateway. Failed runs push job_success 0 and alert Slack.
Prometheus is built around scraping long-running services, which leaves batch jobs invisible unless they push their own telemetry. This blueprint makes batch jobs first-class citizens in Prometheus monitoring. The flow runs a piece of work, then io.kestra.plugin.prometheus.Push records job_duration_seconds and job_success in the Pushgateway, labeled with the Kestra namespace and flow id. When the work fails, the errors block pushes job_success with value 0 and alerts Slack, so a single PromQL alert rule such as job_success == 0 covers every batch job that adopts the pattern.
run_batch_job (io.kestra.plugin.core.debug.Return) stands in for the real workload. Swap it for a Python script, a warehouse query, or a subflow call without touching the rest of the flow.push_success_metrics (io.kestra.plugin.prometheus.Push) sends two metrics to the Pushgateway under the job name {{ flow.id }} and instance kestra. The duration is computed in Pebble as the difference between now() and execution.startDate in epoch seconds, and job_success is pushed as 1.errors block runs push_failure_metric, pushing job_success 0 with the same labels, then alert_failure posts the flow and execution id to Slack.Schedule trigger runs the job nightly at 02:00.job_success == 0, instead of a bespoke alert per job.{{ flow.namespace }} and {{ flow.id }}, so copies of this flow never collide in the Pushgateway.Instrumenting a batch script by hand means writing Pushgateway HTTP calls, remembering to push a failure marker in every error path, and repeating that in every job. Kestra separates the concerns declaratively. The workload task stays clean, the Push task handles the metric protocol, and the errors block guarantees the failure marker and the Slack alert fire no matter which task broke.
username and password properties if your Pushgateway sits behind one.PUSHGATEWAY_URL: base URL of the Pushgateway, e.g. http://pushgateway:9091.SLACK_WEBHOOK_URL: Slack incoming webhook URL.PUSHGATEWAY_URL and SLACK_WEBHOOK_URL secrets to your Kestra namespace.job_success{flow="prometheus-batch-job-metrics"} in Prometheus to confirm the push arrived.run_batch_job with your real workload and set disabled: false on the nightly trigger.metrics from task outputs.time() - push_time_seconds to catch jobs that stopped running entirely.io.kestra.plugin.core.flow.Subflow between the push tasks.