New to Kestra?
Use blueprints to kickstart your first workflows.
Poll a CloudWatch backlog metric on a schedule and submit an EMR Serverless Spark job only when work is pending, with Slack alerts, from Kestra.
Run Spark on AWS EMR Serverless only when there is real work to process. This blueprint turns a CloudWatch backlog metric, such as an SQS queue depth, into a scaling signal: on a fixed schedule it samples the metric, and when datapoints show pending work it submits a Spark job to an existing EMR Serverless application, then reports the run to Slack. It solves the classic gap between a time based scheduler and demand based compute, so you stop paying for idle Spark capacity and stop running empty jobs on a clock that ignores the actual backlog.
every_15_min Schedule trigger (io.kestra.plugin.core.trigger.Schedule, cron */15 * * * *, shipped disabled) starts the flow on a cadence.read_backlog (io.kestra.plugin.aws.cloudwatch.Query) reads the AWS/SQS namespace metric named by backlog_metric, using the Maximum statistic over a PT15M window at 300 second periods.scale_if_backlog (io.kestra.plugin.core.flow.If) evaluates {{ outputs.read_backlog.count > 0 }} and only proceeds when the metric returned datapoints.start_spark_job (io.kestra.plugin.aws.emr.StartServerlessJobRun) submits the Spark job to the application_id you provide, assuming execution_role_arn, naming the run kestra-backlog-{{ execution.id }}, with entry_point pointing at your S3 script.notify (io.kestra.plugin.slack.notifications.SlackIncomingWebhook) posts the returned jobRunId to Slack.EMR Serverless scales executors within a job, but it has no native scheduler that inspects an external backlog before deciding whether to launch a job at all. Kestra fills that gap: the Schedule trigger drives the cadence, the If task gates submission on a live CloudWatch reading, retries and replays cover transient AWS errors, and every run is captured with full execution lineage and outputs. The whole pipeline is declarative YAML, so the scaling logic lives in source control rather than scattered across cron entries and Lambda glue.
ApproximateNumberOfMessagesVisible in AWS/SQS).AWS_ACCESS_KEY_ID: AWS access key.AWS_SECRET_ACCESS_KEY: AWS secret key.AWS_DEFAULT_REGION: AWS region.SLACK_WEBHOOK_URL: Slack incoming webhook URL.application_id, execution_role_arn, and entry_point as inputs.read_backlog at the namespace and metric that represent your queue depth.every_15_min trigger when you are ready to run on a schedule.AWS/SQS namespace and metric for any CloudWatch signal (Kinesis, custom metrics, application gauges).If condition past zero to require a minimum backlog before scaling.sparkSubmitParameters or job arguments to start_spark_job for tuned Spark configs.