Monitor models deployed elsewhere

Send predictions and actuals from a model you run outside mlflow and monitor it here.

You can serve a model on your own platform, for example with a container on a cloud service or a Kubernetes cluster (see Deploy anywhere), and still watch it in mlflow. Your serving code sends each prediction to mlflow. mlflow then applies the same monitoring as for its own endpoints: counts, drift checks, alerts and notifications. Later you can also send the real outcomes (the actuals) for the same predictions.

mlflow only receives records. It does not call your model and cannot retrain or promote a model that runs elsewhere.

Register an external deployment

You register an external deployment for a model candidate, so that mlflow knows which training data to compare against.

Open the model candidate

Open a run, then open the model you deployed from the leaderboard.

Open Monitor it

Select Deploy & export, then the Monitor it tab. The text there reminds you that you register the model to get an ingestion key.

Register

Enter a Name for the deployment, choose the Platform it runs on (for example Docker, AWS ECS, Kubernetes or Other) and select Register deployment. You need an editor role or higher in the project.

Copy the key

The card Copy this key now - you won't see this again. shows the Ingestion key, the Monitor URL, the Environment variables and a Python snippet. Copy what you need, then select I have saved the key.

Registered deployments are listed under Registered deployments for this model, with the platform, the key prefix and the number of records received.

The monitor key

The ingestion key is separate from your personal API keys. It starts with pcm_, works for one external deployment only, and can only send predictions and actuals. If it leaks, the worst that can happen is that someone adds false records to that one deployment, so store it in your serving environment's secret store.

  • The key is shown once. mlflow stores only a fingerprint of it.
  • Select Rotate key to get a new one. The old key stops working immediately, so update your serving environment right away.
  • Deleting the deployment (Delete deployment) removes the registration and every record sent for it, and the key stops working.

If a key is revoked or wrong, the ingestion address answers 401.

Send predictions and actuals

Call the REST API from any language with any HTTP client.

Set the two environment variables from the registration card in your serving environment, then post records from your predict function with any HTTP client:

python
import os
import requests

MONITOR_URL = os.environ["PYCARET_MONITOR_URL"]
HEADERS = {"X-PyCaret-Monitor-Key": os.environ["PYCARET_MONITOR_KEY"]}

def predict(row: dict):
    pred = model.predict(row)
    try:  # monitoring must never break your predictions
        requests.post(
            MONITOR_URL,
            headers=HEADERS,
            json={"records": [{"request_id": "order-123", "features": row, "prediction": pred}]},
            timeout=2,
        )
    except requests.RequestException:
        pass
    return pred

# Later, when the real outcome is known:
requests.post(
    MONITOR_URL.removesuffix("/predictions") + "/actuals",
    headers=HEADERS,
    json={"records": [{"request_id": "order-123", "actual": 1}]},
    timeout=5,
)

For high traffic, queue the records and send them in batches from a background worker so the call never sits on the prediction path.

A record has these fields:

FieldRequiredNotes
featuresYesAn object with the model's input columns and their values.
predictionYesWhat your model predicted.
probabilitiesNoAn object or list with the class probabilities.
actualNoThe real outcome, if you already know it.
request_idNoYour own ID, 1 to 64 characters. mlflow creates one if you omit it. Use it to attach actuals later.
timestampNoAn ISO 8601 time. Defaults to now. It cannot be more than 5 minutes in the future or older than 30 days.

Rules and limits:

  • Send up to 1,000 records per request. A request body can be up to 5 MB, and there is a limit on records per minute per deployment (12,000 by default). If you exceed it, you get 429 with a Retry-After time.
  • The features must match the columns the model was trained on. A record with missing or extra columns is rejected, and the answer says which.
  • NaN and infinity are not valid in JSON. Send null instead.
  • Sending the same request_id twice stores the record once, so retries are safe.

The answer tells you what happened: accepted, rejected, duplicates and a list errors with the index of each rejected record and the reason. One bad record does not block the others.

An actuals request needs request_id and actual for each record, and answers with how many predictions it updated.

Read the results

The registered deployment behaves like any other in the monitoring screens, even though it is not in your Deployments list.

  • On the registered row, select Monitoring to see the metrics and Drift to see the drift reports.
  • Select Drift alerts to set thresholds, run Check now and see the alerts. These work exactly as described in Drift and alerts.
  • Connection details shows the Monitor URL, the environment variables and the Python snippet again (the key itself is never shown again).

Records count as predictions, so Predictions goes up with each accepted record. Latency is not available, because mlflow does not see how long your model took. Drift checks compare your recent records with the first ones received, or with the training data while there are too few.

Actuals are stored, not scored

mlflow keeps the actuals you send next to each prediction. At the moment drift and alerts use the features; mlflow does not compute accuracy from the actuals for you.

Next steps

Learn the theory

Lessons on learning.mlflow.es that explain the ideas behind this page.

Updated 2026-11-22