Detection and recovery policies¶
Metric alert builders can check fixed thresholds, repeated threshold violations, values combined over several time intervals, or changes from earlier values. A time interval, such as one hour or one day, is called a bucket. The following examples create separate configurations on a monitored agent obtained with client.get_agent("production", "support-agent"). See Managing alert configurations for client creation and configuration levels.
Alerting below a threshold¶
For metrics where low values are a problem, select AT_OR_BELOW. Uptime percentages use values from 0 to 100.
configuration = (
agent.new_alert_configuration(type="metric", name="Low daily uptime")
.with_metric("reliability.uptime_pct")
.with_time_bucket("DAY")
.with_thresholds(
warning=99,
critical=95,
breach_direction="AT_OR_BELOW",
)
.create()
)
Requiring repeated threshold violations¶
This example requires three consecutive hourly values that meet the threshold condition before an alert opens or becomes more severe. Warning and critical counts are tracked separately.
configuration = (
agent.new_alert_configuration(type="metric", name="Sustained errors")
.with_metric("reliability.interaction_error_rate_pct")
.with_time_bucket("HOUR")
.with_sustained_thresholds(
warning=5,
critical=10,
warning_breaches=3,
critical_breaches=3,
)
.create()
)
Alerting on a multi-bucket aggregate¶
This example compares the total estimated cost over three completed days with the thresholds.
configuration = (
agent.new_alert_configuration(type="metric", name="Three-day cost")
.with_metric("consumption.cost.total")
.with_time_bucket("DAY")
.with_multi_bucket_aggregate_thresholds(
warning=30,
critical=60,
buckets=3,
)
.create()
)
The calculation depends on the metric. Totals are added. Ratios and averages are calculated from the underlying data. Each distinct identity is counted once. aggregation="AVG" or "P95" is available for business KPIs only.
Comparing with historical values¶
This example detects a 20% or 50% increase in estimated daily cost compared with the immediately preceding day.
configuration = (
agent.new_alert_configuration(type="metric", name="Daily cost increase")
.with_metric("consumption.cost.total")
.with_time_bucket("DAY")
.with_historical_change(
warning=20,
critical=50,
baseline_buckets=1,
recent_buckets=1,
change_direction="INCREASE",
)
.create()
)
Thresholds are relative percentage changes. Totals are compared directly, even if the periods have different lengths. The calculation does not divide a total by the length of its period. Missing observations are not treated as zero.
Configuring recovery and acknowledgement¶
By default, alerts close when the observation returns to normal. Recovery can require several healthy buckets, a separate recovery threshold, or manual closure.
configuration = (
agent.new_alert_configuration(type="metric", name="Cost with recovery policy")
.with_metric("consumption.cost.total")
.with_time_bucket("DAY")
.with_thresholds(warning=10, critical=20)
.with_auto_close("SUSTAINED_BACK_TO_NORMAL", healthy_buckets=3)
.with_required_acknowledgement()
.create()
)
dataikuapi.agentmanagement.alerting.AlertConfigurationBuilder.with_required_acknowledgement() requires acknowledgment in addition to the recovery condition.
with_auto_close("NONE") selects manual closure. BACK_TO_NORMAL_WITH_HYSTERESIS uses a separate recovery_threshold. For alerts triggered by high values, this threshold must be lower than every trigger threshold. For alerts triggered by low values, it must be higher. Agent review configurations support immediate recovery or manual closure only.
Buckets use the global metrics timezone. By default, metric configurations evaluate completed buckets; with_time_bucket(..., include_current_bucket=True) also evaluates available data in the current bucket.
Reference documentation¶
Classes¶
|
Shared settings for metric and agent review alert builders. |
|
Builds a metric alert configuration for creation globally, on an platform, or on an agent. |
Functions¶
|
Creates the alert configuration on this builder's owner. |
|
Returns a handle to an agent. |
|
Initializes a new alert configuration builder owned by this agent. |
|
Configures automatic closure independently of the trigger. |
|
Alerts on percentage changes in a metric compared with its earlier history, rather than a fixed value. |
|
Selects the metric to evaluate. |
Applies fixed thresholds to an aggregate over the last completed buckets, rather than to each bucket separately. |
|
|
Requires human acknowledgement before automatic closure, in addition to the closure condition. |
|
Requires threshold breaches in consecutive completed buckets before opening or escalating an alert. |
|
Selects fixed-threshold detection. |
|
Selects a time bucket for Operational, Usage, Cost, Uptime, or Business KPI metrics. |
