Schedule icon
Request icon
Return icon
Switch icon
Log icon
SlackIncomingWebhook icon

Mux Asset Processing Failure Sentinel

Read recent Mux video assets every hour, change nothing, and alert Slack when assets error or stay preparing, with the most common Mux error.

Categories
Infrastructure

A video platform on Mux fails one upload at a time: a creator uploads a file that is not really video, a signed source URL expires before Mux fetches it, or a new client starts sending a format the encoder rejects. Each asset just ends with status: errored and an errors object, the player shows nothing, and support hears about it before engineering does. This blueprint turns a scheduled, read-only call to the Mux Video API into a processing health gate: io.kestra.plugin.core.http.Request reads recent assets, one jq query computes the error rate, the most common error and assets stuck in preparing, and the result routes to a quiet log or a Slack alert.

How it works

  1. list_assets (io.kestra.plugin.core.http.Request) calls GET /video/v1/assets?limit=100 with HTTP basic auth (access token ID and secret), which returns the most recent assets with their status, created_at (Unix seconds) and errors. It is a read: nothing is uploaded, re-encoded or deleted. Retries cover short network blips, and allowFailed plus allowFailure keep an API error from aborting the flow so it can be reported instead.
  2. summarize_assets (io.kestra.plugin.core.debug.Return) first guards for a missing or non-200 response (UNREACHABLE). Otherwise one jq query keeps assets created inside the lookback window, treats ready and errored as finished, computes the share that errored, groups errored assets by errors.type and errors.messages, and flags assets still preparing after stuck_minutes. At or above critical_error_rate is CRITICAL; at or above warning_error_rate, or any stuck asset, is WARNING; fewer than min_assets finished assets is LOW_VOLUME; otherwise HEALTHY.
  3. route_by_errors (io.kestra.plugin.core.flow.Switch) branches on that classification: HEALTHY and LOW_VOLUME log quietly, WARNING posts a Slack note, CRITICAL and UNREACHABLE page Slack. A defaults fallback logs anything unexpected.
  4. log_audit_result (io.kestra.plugin.core.log.Log) writes one audit line per run with the HTTP status and the full summary.
  5. The flow-level errors block pages Slack if the flow itself fails, and the hourly_check trigger runs at 35 minutes past every hour, shipped disabled: true.

What you get

  • An hourly, read-only check of video processing with no custom scripting and no extra plugin to install.
  • A status output (HEALTHY / WARNING / CRITICAL / LOW_VOLUME / UNREACHABLE) other flows can gate on, for example to pause a bulk import while uploads are failing.
  • Slack messages with the error rate, the number of stuck assets and the most common Mux error type and message, which usually points at the cause.
  • An audit line on every run, separate from Slack.

Who it's for

  • Product teams running video upload, course or social features on Mux.
  • Media engineers who ingest from storage buckets or partner URLs and want to hear about a broken source before users do.
  • Teams that already run their media pipelines and alerting in Kestra.

Why orchestrate this with Kestra

Mux sends a webhook per asset event, which is great for updating one record and poor at telling you that one upload in five failed today. Kestra turns a plain, read-only API call into a scheduled, typed classification with retries, a failure path and an execution history, and the status output lets your ingestion flows react automatically.

Prerequisites

  • A Mux account and an access token with Mux Video read permission (Settings > Access Tokens), for the environment you want to watch.
  • A Slack incoming webhook for the WARNING, CRITICAL, UNREACHABLE and flow-failure alerts.

Secrets

  • MUX_TOKEN_ID: the access token ID, used as the basic-auth username.
  • MUX_TOKEN_SECRET: the access token secret, used as the basic-auth password.
  • SLACK_WEBHOOK: Slack incoming webhook used for every alert branch and the flow-failure alert.

In Kestra OSS, secrets are supplied as environment variables prefixed SECRET_ and base64-encoded, for example SECRET_MUX_TOKEN_ID=$(echo -n 'your-token-id' | base64), and read back with {{ secret('MUX_TOKEN_ID') }}. Use the Enterprise secrets backend for encryption at rest and access control.

Quick start

  1. Upload a short video, plus a file that is not a video, to the Mux environment the token belongs to.
  2. Add MUX_TOKEN_ID, MUX_TOKEN_SECRET and SLACK_WEBHOOK as secrets.
  3. Run the flow manually with a low min_assets and compare the counts and the error in the logs with the Assets page in the Mux dashboard.
  4. Enable hourly_check.

How to extend

  • Follow next_cursor when more than 100 assets are created in the window, or shorten lookback_hours (the summary reports more_pages).
  • Split the rate by passthrough or meta to see which upload source or customer fails.
  • Store the IDs of errored assets in a KV store and alert only on new ones.
  • Add a second request to GET /video/v1/live-streams to watch live streams in the same run.

Inputs

  • lookback_hours: type INT, default 24.
  • warning_error_rate: type FLOAT, default 5.0 (percent).
  • critical_error_rate: type FLOAT, default 20.0 (percent).
  • min_assets: type INT, default 10.
  • stuck_minutes: type INT, default 60.

Outputs

  • status: one of HEALTHY, WARNING, CRITICAL, LOW_VOLUME, UNREACHABLE.
  • Example path: {{ fromJson(outputs.summarize_assets.value).top_error }} for the most common Mux error.

Links

Pitfalls

  • Only the first page (100 assets, newest first) is read; high-volume environments need next_cursor paging or a shorter window.
  • An access token belongs to one Mux environment; watch each environment (for example production and development) with its own token.
  • Long or high-resolution videos can legitimately stay in preparing for a while; raise stuck_minutes if you ingest large files.
  • This flow only reads; it never creates, updates or deletes an asset.
See How

New to Kestra?

Use blueprints to kickstart your first workflows.