AlertRule
API reference for AlertRule
AlertRule
Alert rule for automated monitoring and alerting in ML systems.
An AlertRule defines conditions that automatically trigger notifications when ML model metrics exceed specified thresholds. Alert rules are essential for proactive monitoring of model performance, data drift, and operational issues.
Example
# Create feature drift alert
drift_alert = AlertRule(
name=”credit_score_drift”,
model_id=model.id,
metric_id=”drift_score”,
priority=Priority.HIGH,
compare_to=CompareTo.BASELINE,
condition=AlertCondition.GT,
bin_size=BinSize.HOUR,
critical_threshold=0.8,
warning_threshold=0.6,
baseline_id=baseline.id,
columns=[“credit_score”, “income”]
).create()
# Create performance degradation alert
perf_alert = AlertRule(
name=”accuracy_drop”,
model_id=model.id,
metric_id=”accuracy”,
priority=Priority.MEDIUM,
compare_to=CompareTo.TIME_PERIOD,
condition=AlertCondition.LT,
bin_size=BinSize.DAY,
critical_threshold=0.85,
compare_bin_delta=7 # Compare to 7 days ago
).create()
# Configure notifications
drift_alert.set_notification_config(
emails=[”[ml-team@company.com](mailto:ml-team@company.com)”, “[data-team@company.com](mailto:data-team@company.com)”],
pagerduty_services=[“ML_ALERTS”],
pagerduty_severity=”critical”
)Initialize an AlertRule instance.
Creates an alert rule configuration for automated monitoring of ML model metrics. The alert rule defines conditions that trigger notifications when thresholds are exceeded, enabling proactive monitoring of model performance and data quality.
Parameters
name
str
✗
None
Human-readable name for the alert rule. Should be descriptive and unique within the model context.
model_id
UUID | str
✗
None
UUID of the model this alert rule monitors. Must be a valid model that exists in the Fiddler platform.
metric_id
str | UUID
✗
None
ID of the metric to monitor (e.g., “drift_score”, “accuracy”, “precision”, “recall”, custom metric IDs).
priority
Priority | str
✗
None
Alert priority level (HIGH, MEDIUM, LOW). Determines urgency and routing of notifications.
compare_to
CompareTo | str
✗
None
Comparison method for threshold evaluation: BASELINE: Compare against a fixed baseline; TIME_PERIOD: Compare against previous time period; RAW_VALUE: Compare against absolute threshold
condition
AlertCondition | str
✗
None
Alert condition (GT, LT, OUTSIDE_RANGE). Defines when the alert should trigger relative to the threshold.
bin_size
BinSize | str
✗
None
Time aggregation window (HOUR, DAY, WEEK). Controls how data is grouped for metric calculation.
threshold_type
AlertThresholdAlgo | str
✗
None
Threshold calculation method (MANUAL or AUTO). MANUAL uses user-defined thresholds, AUTO calculates dynamic thresholds based on historical data.
auto_threshold_params
dict[str, Any] | None
✗
None
Parameters for automatic threshold calculation. Used when threshold_type is AUTO.
critical_threshold
float | None
✗
None
Critical alert threshold value. Triggers high-priority notifications when exceeded.
warning_threshold
float | None
✗
None
Warning alert threshold value. Triggers medium-priority notifications when exceeded.
columns
list[str] | None
✗
None
List of feature columns to monitor. For feature-specific drift alerts. If None, monitors all features.
baseline_id
UUID | str | None
✗
None
UUID of the baseline to compare against. Required when compare_to is BASELINE.
segment_id
UUID | str | None
✗
None
UUID of the data segment to monitor. For segment-specific monitoring (optional).
compare_bin_delta
int | None
✗
None
Number of time bins to compare against. Used with TIME_PERIOD comparison (e.g., 7 for week-over-week).
evaluation_delay
int
✗
None
Delay in minutes before evaluating alerts. Helps avoid false positives from incomplete data.
category
str | None
✗
None
Custom category for organizing alerts. Useful for grouping related alerts in dashboards.
Example
# Feature drift alert with baseline comparison
drift_alert = AlertRule(
name=”income_drift_detection”,
model_id=model.id,
metric_id=”drift_score”,
priority=Priority.HIGH,
compare_to=CompareTo.BASELINE,
condition=AlertCondition.GT,
bin_size=BinSize.HOUR,
critical_threshold=0.8,
warning_threshold=0.6,
baseline_id=baseline.id,
columns=[“income”, “credit_score”],
evaluation_delay=15, # 15 minute delay
category=”data_quality”
)
# Performance monitoring with time comparison
perf_alert = AlertRule(
name=”weekly_accuracy_check”,
model_id=model.id,
metric_id=”accuracy”,
priority=Priority.MEDIUM,
compare_to=CompareTo.TIME_PERIOD,
condition=AlertCondition.LT,
bin_size=BinSize.DAY,
critical_threshold=0.85,
compare_bin_delta=7, # Compare to 7 days ago
category=”performance”
)classmethod get(id_)
Retrieve an alert rule by its unique identifier.
Fetches an alert rule from the Fiddler platform using its UUID. This method returns the complete alert rule configuration including thresholds, notification settings, and monitoring status.
Parameters
id – The unique identifier (UUID) of the alert rule to retrieve. Can be provided as a UUID object or string representation.
id_ (UUID | str)
Returns
The alert rule instance with all configuration and metadata populated from the server. Return type: AlertRule
Raises
NotFound – If no alert rule exists with the specified ID.
ApiError – If there’s an error communicating with the Fiddler API.
Example
# Retrieve alert rule by ID
alert_rule = AlertRule.get(id_=”550e8400-e29b-41d4-a716-446655440000”)
print(f”Alert: {alert_rule.name}”)
print(f”Metric: {alert_rule.metric_id}”)
print(f”Priority: {alert_rule.priority}”)
print(f”Critical threshold: {alert_rule.critical_threshold}”)
# Check notification configuration
notification_config = alert_rule.get_notification_config()
print(f”Email recipients: {notification_config.emails}”)classmethod list(model_id, metric_id=None, columns=None, baseline_id=None, ordering=None)
Get a list of all alert rules in the organization.
Parameters
model_id
UUID | str
✗
None
list from the specified model
metric_id
UUID | str | None
✗
None
list rules set on the specified metric id
columns
list[str] | None
✗
None
list rules set on the specified list of columns
baseline_id
UUID | str | None
✗
None
list rules set on the specified baseline_id
ordering
list[str] | None
✗
None
order result as per list of fields. [“-field_name”] for descending
Returns
paginated list of alert rules for the specified filters Return type: Iterator[AlertRule]
delete()
Delete an alert rule. Return type: None
create()
Create a new alert rule. Return type: AlertRule
update()
Update an existing alert rule. Return type: None
enable_notifications()
Enable notifications for an alert rule Return type: None
disable_notifications()
Disable notifications for an alert rule Return type: None
set_notification_config()
Set notification config for an alert rule
Parameters
emails
list[str] | None
✗
None
list of emails
pagerduty_services
list[str] | None
✗
None
list of pagerduty services
pagerduty_severity
str | None
✗
None
severity of pagerduty
webhooks
list[UUID] | None
✗
None
list of webhooks UUIDs
Returns
NotificationConfig object Return type: NotificationConfig
get_notification_config()
Get notifications config for an alert rule
Returns
NotificationConfig object Return type: NotificationConfig
Last updated
Was this helpful?