> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fiddler.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 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.

## Attributes

**name**

Human-readable name for the alert rule

**model\_id**

UUID of the associated [`Model`](https://docs.fiddler.ai/sdk-api/python-client/model)

**metric\_id**

ID of the metric to monitor (drift\_score, accuracy, etc.)

**priority**

Alert priority level ([`Priority`](https://docs.fiddler.ai/sdk-api/python-client/priority))

**compare\_to**

Comparison method ([`CompareTo`](https://docs.fiddler.ai/sdk-api/python-client/compare-to))

**condition**

Alert condition ([`AlertCondition`](https://docs.fiddler.ai/sdk-api/python-client/alert-condition))

**bin\_size**

Time aggregation window ([`BinSize`](https://docs.fiddler.ai/sdk-api/python-client/bin-size))

**threshold\_type**

Threshold calculation method ([`AlertThresholdAlgo`](https://docs.fiddler.ai/sdk-api/python-client/alert-threshold-algo))

**auto\_threshold\_params**

Parameters for automatic threshold calculation

**critical\_threshold**

Critical alert threshold value

**warning\_threshold**

Warning alert threshold value

**columns**

List of feature columns to monitor (for feature-specific alerts)

**baseline\_id**

UUID of reference [`Baseline`](https://docs.fiddler.ai/sdk-api/python-client/baseline) (if applicable)

**segment\_id**

UUID of data segment to monitor (if applicable)

**compare\_bin\_delta**

Number of time bins to compare against

**evaluation\_delay**

Delay in minutes before evaluating alerts

**category**

Custom category for organizing alerts

**id**

Unique identifier assigned after creation

**project\_id**

UUID of the containing [`Project`](https://docs.fiddler.ai/sdk-api/python-client/project)

**created\_at**

Timestamp when alert rule was created

**updated\_at**

Timestamp when alert rule was last modified

## Example

```python theme={null}
# 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.LESSER,
    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"
)
```

> [!NOTE]
>
> Alert rules continuously monitor metrics and trigger notifications when
> thresholds are exceeded. Use appropriate evaluation delays to avoid
> false positives from temporary data fluctuations.

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` *required*

Human-readable name for the alert rule. Should be descriptive
and unique within the model context.

**model\_id** `UUID | str` *required*

UUID of the model this alert rule monitors. Must be a valid
model that exists in the Fiddler platform.

**metric\_id** `str | UUID` *required*

ID of the metric to monitor (e.g., "drift\_score", "accuracy",
"precision", "recall", custom metric IDs).

**priority** `Priority | str` *required*

Alert priority level (HIGH, MEDIUM, LOW). Determines urgency
and routing of notifications.

**compare\_to** `CompareTo | str` *required*

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` *required*

Alert condition (GT, LT, OUTSIDE\_RANGE). Defines when
the alert should trigger relative to the threshold.

**bin\_size** `BinSize | str` *required*

Time aggregation window (HOUR, DAY, WEEK). Controls how
data is grouped for metric calculation.

**threshold\_type** `AlertThresholdAlgo | str` (default: AlertThresholdAlgo.MANUAL)

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` (default: None)

Parameters for automatic threshold calculation.
Used when threshold\_type is AUTO.

**critical\_threshold** `float | None` (default: None)

Critical alert threshold value. Triggers high-priority
notifications when exceeded.

**warning\_threshold** `float | None` (default: None)

Warning alert threshold value. Triggers medium-priority
notifications when exceeded.

**columns** `list[str] | None` (default: None)

List of feature columns to monitor. For feature-specific
drift alerts. If None, monitors all features.

**baseline\_id** `UUID | str | None` (default: None)

UUID of the baseline to compare against. Required when
compare\_to is BASELINE.

**segment\_id** `UUID | str | None` (default: None)

UUID of the data segment to monitor. For segment-specific
monitoring (optional).

**compare\_bin\_delta** `int | None` (default: None)

Number of time bins to compare against. Used with
TIME\_PERIOD comparison (e.g., 7 for week-over-week).

**evaluation\_delay** `int` (default: 0)

Delay in minutes before evaluating alerts. Helps
avoid false positives from incomplete data.

**category** `str | None` (default: None)

Custom category for organizing alerts. Useful for grouping
related alerts in dashboards.

## Example

```python theme={null}
# 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.LESSER,
    bin_size=BinSize.DAY,
    critical_threshold=0.85,
    compare_bin_delta=7,  # Compare to 7 days ago
    category="performance"
)
```

> [!NOTE]
>
> After initialization, call create() to persist the alert rule to the
> Fiddler platform. Alert rules begin monitoring immediately after creation.

## *classmethod* get()

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\_** `UUID | str` *required*

The unique identifier (UUID) of the alert rule to retrieve.
Can be provided as a UUID object or string representation.

### Returns

The alert rule instance with all
configuration and metadata populated from the server.

### Raises

* **NotFound** – If no alert rule exists with the specified ID.
* **ApiError** – If there's an error communicating with the Fiddler API.

### Example

```python theme={null}
# 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}")
```

> [!NOTE]
>
> This method makes an API call to fetch the latest alert rule configuration
> from the server, including any recent threshold or notification updates.

## *classmethod* list()

Get a list of all alert rules in the organization.

### Parameters

**model\_id** `UUID | str` *required*

list from the specified model

**metric\_id** `UUID | str | None` (default: None)

list rules set on the specified metric id

**columns** `list[str] | None` (default: None)

list rules set on the specified list of columns

**baseline\_id** `UUID | str | None` (default: None)

list rules set on the specified baseline\_id

**ordering** `list[str] | None` (default: None)

order result as per list of fields. \["-field\_name"] for descending

### Returns

paginated list of alert rules for the specified filters

## delete()

Delete an alert rule.

## create()

Create a new alert rule.

### Returns

`AlertRule`

## update()

Update an existing alert rule.

## enable\_notifications()

Enable notifications for an alert rule

## disable\_notifications()

Disable notifications for an alert rule

## set\_notification\_config()

Set notification config for an alert rule

### Parameters

**emails** `list[str] | None` (default: None)

list of emails

**pagerduty\_services** `list[str] | None` (default: None)

list of pagerduty services

**pagerduty\_severity** `str | None` (default: None)

severity of pagerduty

**webhooks** `list[UUID] | None` (default: None)

list of webhooks UUIDs

### Returns

NotificationConfig object

## get\_notification\_config()

Get notifications config for an alert rule

### Returns

NotificationConfig object
