Based on the MLS-C01 exam guideReport an error
statistics.json and constraints.json) → schedule → constraint_violations.json → CloudWatch alarm → EventBridge → retraining.A deployed model depends on the patterns it learned at training time, but the real-world distribution starts moving from the very day you deploy.
| Cause of change | Example | Result |
|---|---|---|
| Change in user behavior | Seasonality, influx of a new segment, a crisis | The distribution of input X shifts |
| Change in data source | Sensor recalibration, upstream ETL fix, unit change | The same column holds values with a different meaning |
| Breakdown of the target relationship | Change in fraud tactics, policy change | Features stay the same but the correct answer differs |
| Schema change | Columns added or removed, type changes, sudden surge in missing values | Inference failures or silent performance degradation |
There is one key constraint. Ground truth arrives late or never arrives at all. That is why monitoring the input distribution without labels becomes the first line of alarm.
| Type | What changes | In formula terms | Labels needed? | Typical signal | Response |
|---|---|---|---|---|---|
| Data drift (covariate shift) | Input distribution P(X) | P(X) changes, P(Y|X) holds | Not needed | Average age 35→48, sudden surge in missing rate | Data Quality → retraining |
| Concept drift | Input→answer relationship P(Y|X) | P(X) holds, P(Y|X) changes | Needed (the hardest) | Input statistics look normal but only accuracy drops | Model Quality → retraining or redesign |
| Label drift (prior probability shift) | Distribution of answers P(Y) | P(Y) changes | Needed | Fraud ratio 0.5%→3% | Readjust the threshold and class weights |
[Data drift] [Concept drift] [Label drift]
░░▓▓▓░░ → ░░░▓▓▓ ●●●/○○○ boundary moves 0.5% ▓ → 3% ▓▓▓▓▓▓
Boundary unchanged, Input stats look normal Only the positive ratio
only the inputs move changes
→ detectable w/o labels → invisible w/o labels → readjust the thresholdThe answer to "Performance is dropping but labels arrive late. What do we watch?" is label-free input statistics. Drift in X is only an early-warning indicator of performance degradation and causation is not guaranteed, but it is the only signal you can act on today. Concept drift is the most dangerous, yet it cannot be observed without labels.
| Monitor | What it watches | Labels needed | Baseline output | Typical violation |
|---|---|---|---|---|
| Data Quality | Input feature statistics (missing values, type, range, distribution) | Not needed | statistics.json, constraints.json | Rising missing rate, type mismatch, distribution distance exceeded |
| Model Quality | Prediction quality (Accuracy, F1, AUC, RMSE, etc.) | Needed | Performance-metric threshold constraints | Accuracy falls below the threshold |
| Bias Drift | Fairness metrics between groups (Clarify) | Partially needed (depends on the metric) | Bias-metric baseline | Gap in prediction rates for a particular group widens |
| Feature Attribution Drift | Rank and magnitude of feature contributions (SHAP) | Not needed | Attribution baseline | Rank order of the top contributing features is reshuffled |
DefaultModelMonitor and ModelQualityMonitor.ModelBiasMonitor, ModelExplainabilityMonitor).The criterion for choosing among the four is effectively just one: "Does the question stem have ground-truth labels?" If there are no labels, choose Data Quality or Feature Attribution Drift; if there are, Model Quality; if the topic is fairness, Bias Drift.
① Training/validation data ─▶ suggest_baseline ─▶ statistics.json + constraints.json
│ (reference values)
[Client] ─request─▶ [Endpoint] ─response─▶ [Client] │
│ ② DataCaptureConfig │
▼ │
s3://.../datacapture/ ────────────────┤
▼
③ Schedule (min. 1 hour) ─▶ [Monitoring Execution]
│
┌─────────────────────────┴──────────────┐
▼ ▼
statistics.json (this window) constraint_violations.json
└────────────┬───────────────────────────┘
▼ ④ enable_cloudwatch_metrics=True
[CloudWatch metrics · alarms]
▼ ⑤ transition to ALARM
[Amazon EventBridge]
┌──────────────┼──────────────┐
▼ ▼ ▼
[SNS alert] [Lambda] [SageMaker Pipeline retraining]
▼
[Model Registry] new version → approval → redeployThe endpoint has to land real requests and responses in S3 before there is any source data to monitor.
from sagemaker.model_monitor import DataCaptureConfig
data_capture_config = DataCaptureConfig(
enable_capture=True,
sampling_percentage=100, # with heavy traffic, lower it to 20-50%
destination_s3_uri="s3://my-bucket/datacapture",
capture_options=["REQUEST", "RESPONSE"],
)
predictor = model.deploy(..., data_capture_config=data_capture_config)| Parameter | Role | Practical judgment |
|---|---|---|
enable_capture | Capture on/off | If off, the monitor has no data to look at in the first place |
sampling_percentage | Capture ratio (%) | 100% raises S3 cost. For high traffic, sample |
destination_s3_uri | Capture storage path | Stored partitioned by endpoint/variant/date/hour |
capture_options | Choose request/response | If you only need input statistics, REQUEST alone is enough |
eventId. This ID is the key for joining with ground-truth labels later.⚠️ Pitfall: After you turn capture on, files only accumulate if traffic actually flows. A scheduled run over a window with no invocations has nothing to compare and fails. This is the number one cause of "I set up monitoring but no results appear."
The baseline is a snapshot of "what is normal," extracted from the training and validation data.
from sagemaker.model_monitor import DefaultModelMonitor
from sagemaker.model_monitor.dataset_format import DatasetFormat
monitor = DefaultModelMonitor(
role=role, instance_count=1, instance_type="ml.m5.xlarge",
volume_size_in_gb=20, max_runtime_in_seconds=3600,
)
monitor.suggest_baseline(
baseline_dataset="s3://my-bucket/baseline/train.csv",
dataset_format=DatasetFormat.csv(header=True),
output_s3_uri="s3://my-bucket/baseline-results",
)
# Outputs: statistics.json, constraints.json| Output | What it contains | How the monitor uses it |
|---|---|---|
| statistics.json | Per-feature mean, sum, standard deviation, min, max, missing count, distribution summary | Compares numbers with the production-window statistics |
| constraints.json | Per-feature data type, completeness (tolerated missing rate), whether negatives are allowed, distribution-comparison settings | The rules that decide whether there is a violation |
monitoring_config of constraints.json you adjust the comparison thresholds and the distribution-comparison method. If the automatically suggested values are too tight, relax them here.from sagemaker.model_monitor import CronExpressionGenerator
monitor.create_monitoring_schedule(
monitor_schedule_name="data-quality-hourly",
endpoint_input=predictor.endpoint_name,
statistics=monitor.baseline_statistics(),
constraints=monitor.suggested_constraints(),
schedule_cron_expression=CronExpressionGenerator.hourly(),
enable_cloudwatch_metrics=True,
)| Cadence helper | Meaning | When to use |
|---|---|---|
CronExpressionGenerator.hourly() | Every hour | When fast detection is needed (the minimum unit) |
CronExpressionGenerator.daily() | Every day at a set time | Daily batch-style services, cost savings |
CronExpressionGenerator.daily_every_x_hours(x) | Every x hours | A middle compromise |
| Execution status | Meaning | Action |
|---|---|---|
Completed | Succeeded, no violations | None |
CompletedWithViolations | Succeeded, violations found | Check the violations file → classify the cause |
Failed | The execution itself failed | Check for missing capture data, permissions, schema mismatch |
Stopped | Halted, e.g., due to timeout | Raise the instance size or max_runtime |
Each execution leaves constraint_violations.json and the statistics.json for that window in S3, and if enable_cloudwatch_metrics=True it publishes per-feature metrics to CloudWatch so you can set alarms on them.
| Stage | Component | What it does |
|---|---|---|
| Detection | Monitoring Schedule | Judges violations, generates constraint_violations.json |
| Quantification | CloudWatch metrics | Publishes per-feature violation and statistics metrics |
| Decision | CloudWatch alarm | Transitions to ALARM when the threshold and evaluation period are exceeded |
| Routing | EventBridge | Receives the alarm state-change event and invokes the target |
| Execution | SageMaker Pipeline / Lambda | Retraining, re-evaluation, model registration |
| Control | Model Registry | Registers the new version, then an approval gate |
| Notification | SNS | Notifies the person in charge |
{
"violations": [
{ "feature_name": "age",
"constraint_check_type": "baseline_drift_check",
"description": "Baseline drift distance exceeded threshold" },
{ "feature_name": "income",
"constraint_check_type": "completeness_check",
"description": "Completeness dropped below required value" }
]
}⚠️ Pitfall: If you launch retraining immediately on every single violation, costs explode and the model gets unstable. Set an evaluation period (N consecutive violations) on the CloudWatch alarm to distinguish a momentary blip from persistent drift.
The Model Quality monitor only works when ground truth exists. So a step is needed first to join the later-arriving labels with the captured data.
[Captured prediction] eventId=abc pred=0.87 ─┐
├─▶ [Ground Truth Merge] ─▶ [Model Quality]
[Late-arriving truth] eventId=abc label=1 ─┘ (joined on eventId) Accuracy·F1·AUCeventId and computes performance metrics.| Label situation | First line of defense | Supplementary measure | What not to do |
|---|---|---|---|
| Arrive within hours | Model Quality (daily schedule) | Run Data Quality alongside | None |
| Delayed by weeks to months | Data Quality | Feature Attribution Drift, prediction-distribution monitoring | Leave it unmonitored while waiting for truth |
| Available only as a sample | Sample-based Model Quality | Continuous Data Quality monitoring | Treat sample accuracy as overall performance |
| Never available | Data Quality + Feature Attribution Drift | Business proxy metrics (conversion rate, etc.) | Try to adopt Model Quality |
Even without labels, Feature Attribution Drift looks at how much the rank and magnitude of "the features the model uses as its basis for decisions" have wobbled relative to the baseline. It catches the situation where the input means are unchanged but only the decision structure has changed, a signal that complements Data Quality.
[t0] Train on training set A → baseline(A) → deploy · monitor ✅ normal
[t1] Drift detected → retrain including new data B → redeploy
[t2] Baseline is still A → violations flood every run ❌ false positives
[t2'] Regenerate the baseline from B → quiet again ✅ correct answer| Clue in the stem | Answer to pick | Reason |
|---|---|---|
| "Ground-truth labels arrive days later / don't exist" | Data Quality monitoring | Judged from input statistics alone, no labels needed |
| "Want to know whether accuracy/F1 dropped, labels available" | Model Quality monitoring | A metric that only comes from comparing predictions with truth |
| "Monitor whether the SHAP attribution rank has changed" | Feature Attribution Drift | Clarify-based attribution drift monitoring |
| "The prediction gap for a particular group has widened" | Bias Drift | Clarify fairness-metric monitoring |
| "What comes first when setting up monitoring?" | Create a baseline | Without a reference, judging is impossible |
| "Must keep endpoint inputs and outputs in S3" | DataCaptureConfig | The step that creates the data to monitor |
| "On violation, start retraining without human intervention" | EventBridge → SageMaker Pipeline | Receives the alarm event and invokes the workflow |
| "Violations occur every time after retraining" | Regenerate the baseline | Redefine the new distribution as normal |
| "S3 capture cost/latency is a burden" | Lower sampling_percentage | Capture a sample instead of everything |
| "Delete the monitoring schedule / turn off capture" | Wrong option | It removes the monitoring rather than addressing the symptom |
In the next note we cover MLOps, which runs this retraining without human hands: SageMaker Pipelines, Model Registry, and CI/CD.
statistics.json and constraints.json.eventId so performance metrics can be computed.Click a choice to reveal the answer and explanation.
Question 1
In the input traffic of a production SageMaker endpoint, the mean and variance of a particular numeric feature have changed significantly from training time. The ground-truth labels will not be collected until several days later. Which Model Monitor type is MOST appropriate for detecting this change immediately?
Question 2
You want to set up Model Monitor data quality monitoring. Which step should be performed FIRST?
Question 3
You deliberately retrained the model to reflect a new data distribution. However, the existing monitoring publishes drift violations on every run. What is the MOST appropriate action?
Question 4
When a data quality violation occurs, you want to automatically start a retraining pipeline without human intervention. Which service is MOST appropriate for receiving the CloudWatch alarm and invoking a SageMaker Pipeline?
Question 5
Which is the MOST accurate description of the change that Feature Attribution Drift monitoring detects?