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

Hugging Face Inference Endpoint Health Sentinel

Check Hugging Face Inference Endpoints every 15 minutes, change nothing, and alert Slack when an endpoint fails, is stuck or is short of replicas.

Categories
AI

Teams that serve their own models on Hugging Face Inference Endpoints depend on each endpoint staying in the running state with its replicas ready. An endpoint can drop to failed after a bad image or out-of-memory error, sit in initializing because no GPU is available, or keep running with fewer ready replicas than targeted, and every downstream app, agent or RAG pipeline that calls it starts timing out. This blueprint turns a scheduled, read-only call to the Inference Endpoints API into a model-serving gate: io.kestra.plugin.core.http.Request lists the namespace's endpoints, one jq query finds failed, stuck and under-replicated ones, and the result routes to a quiet log or a Slack alert.

How it works

  1. list_endpoints (io.kestra.plugin.core.http.Request) calls GET /v2/endpoint/{namespace}?limit=100 with a bearer token. It is a read: no endpoint is paused, resumed, scaled 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_endpoints (io.kestra.plugin.core.debug.Return) first guards for a missing or non-200 response (UNREACHABLE). Otherwise one jq query reads each endpoint's status.state (pending, initializing, updating, updateFailed, running, paused, failed, scaledToZero): failed and updateFailed endpoints are listed with their error message; pending, initializing and updating endpoints whose status.updatedAt is older than stuck_minutes are listed as stuck; running endpoints with readyReplica below targetReplica are listed as short. Any failed endpoint is FAILED, any stuck or short one is DEGRADED, otherwise HEALTHY. Paused and scaled-to-zero endpoints are counted, not alerted.
  3. route_by_endpoint_health (io.kestra.plugin.core.flow.Switch) branches on that classification: HEALTHY logs quietly, DEGRADED posts a Slack message, FAILED 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 health_check trigger runs every 15 minutes, shipped disabled: true.

What you get

  • A read-only model-serving check across every endpoint in a namespace, with no custom scripting and no extra plugin to install.
  • A status output (HEALTHY / DEGRADED / FAILED / UNREACHABLE) other flows can gate on, for example to route an agent to a fallback model while the primary endpoint is down.
  • Slack messages that name each affected endpoint with its state, replica count or error message.
  • An audit line on every run, separate from Slack.

Who it's for

  • ML and platform teams serving open models (LLMs, embeddings, rerankers) on Hugging Face Inference Endpoints.
  • Teams whose agents or RAG pipelines in Kestra call those endpoints and need to know when the model behind them is unhealthy.
  • Anyone paying for GPU endpoints who wants to notice a stuck deployment before the bill or the users do.

Why orchestrate this with Kestra

The Inference Endpoints console shows state when someone opens it, and its notifications cover a few events. Kestra turns a plain, read-only API call into a scheduled, typed classification across the whole namespace with retries, a failure path and an execution history, right next to the AI flows that depend on those endpoints.

Prerequisites

  • A Hugging Face account or organization with at least one Inference Endpoint.
  • A fine-grained access token with read access to Inference Endpoints for that namespace.
  • A Slack incoming webhook for the DEGRADED, FAILED, UNREACHABLE and flow-failure alerts.

Secrets

  • HF_NAMESPACE: the user or organization name that owns the endpoints.
  • HF_TOKEN: Hugging Face access token with Inference Endpoints read permission.
  • 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_HF_NAMESPACE=$(echo -n 'my-org' | base64), and read back with {{ secret('HF_NAMESPACE') }}. Use the Enterprise secrets backend for encryption at rest and access control.

Quick start

  1. Create a small CPU Inference Endpoint (for example a sentence-transformers model) from the Model Catalog.
  2. Add HF_NAMESPACE, HF_TOKEN and SLACK_WEBHOOK as secrets.
  3. Run the flow while the endpoint is initializing and again once it is running, and compare the logged states with the console.
  4. Enable health_check.

How to extend

  • Follow nextCursor when the namespace has more than 100 endpoints.
  • Add a Request to GET /v2/endpoint/{namespace}/{name}/logs for each failed endpoint and attach the last log lines to the Slack message.
  • Filter with the tags query parameter to watch only production endpoints.
  • Store the last status per endpoint in a KV store and alert only on changes.

Inputs

  • stuck_minutes: type INT, default 30.

Outputs

  • status: one of HEALTHY, DEGRADED, FAILED, UNREACHABLE.
  • Example path: {{ fromJson(outputs.summarize_endpoints.value).failed }} for the failed endpoints and their error messages.

Links

Pitfalls

  • "Stuck" is measured from status.updatedAt in UTC; a large model on a scarce GPU can legitimately take longer than 30 minutes to initialize, so raise stuck_minutes for those.
  • An endpoint that scales to zero on purpose shows scaledToZero and is not an alert; the first request after that wakes it up with a cold-start delay.
  • Only the first 100 endpoints are read unless you add cursor paging.
  • This flow only reads; it never pauses, resumes, scales or deletes an endpoint.
See How

New to Kestra?

Use blueprints to kickstart your first workflows.