New to Kestra?
Use blueprints to kickstart your first workflows.
Catch Fastly bill surprises mid-month with Kestra. Pull month-to-date usage, compute bandwidth in GB, and alert Slack when it crosses a threshold.
CDN bills surprise people because usage is invisible between invoices: a traffic spike, a misconfigured cache, or an unpurged asset loop can run for weeks before anyone sees a number. This blueprint checks the number that becomes the invoice while the month is still running. io.kestra.plugin.fastly.stats.MonthToDateUsage pulls the account's month-to-date rollup, io.kestra.plugin.fastly.stats.Usage with byService: true attaches the per-service breakdown, and a small Python step reduces the payload to one scalar, total bandwidth in GB, that an If task compares against your threshold. Over it, Slack gets a warning with the measured number while there is still time to react.
month_to_date (io.kestra.plugin.fastly.stats.MonthToDateUsage) fetches the account's usage rollup for the current billing month.usage_by_service (io.kestra.plugin.fastly.stats.Usage) fetches the window from the first of the month to today with byService: true, so the execution carries the answer to "which service is doing this" alongside the total.compute_bandwidth (io.kestra.plugin.scripts.python.Script on the io.kestra.plugin.core.runner.Process runner) receives the month-to-date data output as JSON through an environment variable, walks the structure summing every bandwidth field, converts bytes to GB, and emits the scalar through Kestra's outputs protocol as bandwidth_gb.check_threshold (io.kestra.plugin.core.flow.If) compares the scalar with the bandwidth_threshold_gb input. Over the threshold, alert_overage posts the measured number to Slack; under it, log_ok records a healthy check.errors block posts a Discord alert when the guard fails, because a dead cost check is indistinguishable from a cheap month.Schedule trigger runs the guard every Monday morning.Fastly exposes month-to-date usage through its API, but an API nobody polls prevents nothing. Kestra provides the loop around it: a schedule, retries on flaky calls, a Python step for the arithmetic with no infrastructure of its own thanks to the Process runner, a branch that separates alerting from logging, and an execution history that becomes a week-by-week record of the month's trajectory.
FASTLY_API_TOKEN: Fastly API token with stats read access.SLACK_WEBHOOK_URL: Slack incoming webhook URL.DISCORD_WEBHOOK_URL: Discord incoming webhook URL.bandwidth_threshold_gb a sensible margin above your normal month.disabled: false on the weekly trigger.usage_by_service output.