ETLMCPData Conveyance Works
Log in Start free
Docs

Recipe: alert on failed runs and broken sources

Poll the REST API for failed or partial runs and for sources that need reconnecting, and send the alert to your own chat or paging tool.

To get etlmcp failures into your own chat or paging tool, run a small job on a timer that asks the REST API two questions: has any source left the ok state, and did the newest run of any pipeline end as failed or partial? If either answer is yes, your job posts the alert. etlmcp sends failure notices only by email, so polling is how you route them anywhere else. Every check is an ordinary API request and counts toward your credential's limit of 120 requests a minute.

Why email is not enough

When a run ends as failed or partial after its last attempt, etlmcp emails the organization's owners, but only once per pipeline per UTC day, and for at most 20 pipelines of one organization a day. Owners also get an email when a login needs reconnecting or an account is lost. These emails reach owners only, not the team that watches the data. A poller sends the alert where that team looks, on your schedule. Every email etlmcp sends shows the emails themselves.

What to read

Sources. List sources returns every source in the workspace with a state field. It holds one of four values:

state What it means for your alert
ok The source is healthy. No alert.
needs_reconnect The login behind it no longer works. Every source on that login that is not already invalid is marked at once. Someone has to reconnect the login.
invalid The login still works, but it no longer lists this account, or lists it as one that cannot be picked. The source goes back to ok only when a later check of the login finds the account usable again.
disabled Someone switched the source off. Alert only if you did not expect it.

Alert whenever a source's state is anything other than ok, and put the source's id and name in the message so the person on call can find it.

Runs. List runs returns recent runs, newest first. Give it pipeline_id to see one pipeline, and limit to choose how many come back: from 1 to 200, and 50 when you leave it out. Each run has a trigger, either schedule or manual, and a status: queued, running, success, partial or failed. A partial run failed while delivering to the destination, after the data was pulled; treat it as a failure. When a run fails, its error field holds the reason. Fetch a single run with Get a run.

queued and running are not final. Before another attempt, etlmcp puts the run back to queued and writes the reason into error, starting with retrying:. An error on a queued run is not a failure yet: alert only on finished runs. Retries explains how many attempts a run gets.

Pipelines. List pipelines gives each pipeline's last_status and last_run_at, set when its latest run settles, plus paused_reason when the plan's limits have paused it. One request covers the whole workspace; call List runs only for the pipelines that look wrong, to read the error.

A check you can schedule

The example uses curl and jq with a key in $ETLMCP_API_KEY. Replace post_alert with the call to your own tool's incoming webhook.

API=https://app.etlmcp.com/api/v1
AUTH="Authorization: Bearer $ETLMCP_API_KEY"

# Sources that are not ok
curl -sf -H "$AUTH" "$API/sources" \
  | jq -r '.[] | select(.state != "ok") | "source \(.name) (\(.id)) is \(.state)"' \
  | while read -r line; do post_alert "$line"; done

# Pipelines whose latest run failed or was partial, or that are paused
curl -sf -H "$AUTH" "$API/pipelines" \
  | jq -r '.[] | select(.last_status == "failed" or .last_status == "partial" or .paused_reason != null)
           | "pipeline \(.name) (\(.id)): \(.last_status // "no run") \(.paused_reason // "")"' \
  | while read -r line; do post_alert "$line"; done

# Detail for one pipeline: its newest run and the error
curl -sf -H "$AUTH" "$API/runs?pipeline_id=PIPELINE_ID&limit=1" \
  | jq -r '.[0] | "\(.status) \(.trigger) run \(.id): \(.error // "")"'

Keep a note of what you already alerted on, such as the run id or the source's id and state, so a broken source does not page someone every few minutes. Clear the note when the source is back to ok or a newer run succeeds.

Stay inside the request limit

The limit is counted per credential over a one-minute window, and the REST API and MCP share it: requests from an AI assistant using the same key count too. The check above makes two requests, plus one for each pipeline you look into, so a check every minute uses only a few of the 120. If you go over, the API answers 429 with rate limit exceeded; retry later in its error field and a Retry-After header with the seconds to wait. Give the monitor its own key with only the read scope, so its traffic cannot crowd out other work; API keys covers creating one.

Related