Managing alert configurations

Metric alert configurations can be defined at four levels: global, scope, platform, and agent. Agent review alert configurations can only be defined at agent level.

In the following examples, client is an AgentManagementClient created as described in The main AgentManagementClient class.

Configuration levels

Choose the level according to the agents you want to monitor:

Level

Agents monitored

How to create a configuration

Global

All applicable agents.

client.new_alert_configuration()

Scope

Agents in the selected scope.

Agent Management UI; see Creating a metric alert at scope level. Existing scope configurations are returned as AlertConfigurationListItem objects.

Platform

Agents on the selected platform.

platform.new_alert_configuration()

Agent

One selected agent.

agent.new_alert_configuration()

Configurations at different levels are evaluated independently. Thresholds are checked separately for each applicable agent.

The Python examples below use a builder. Calling dataikuapi.agentmanagement_client.AgentManagementClient.new_alert_configuration() creates the builder in Python; calling create() saves the configuration on the server. Configurations are enabled by default. Metric evaluation requires a time bucket and at least one threshold. The metric identifier is fixed after creation.

Creating a metric alert at global level

Call dataikuapi.agentmanagement_client.AgentManagementClient.new_alert_configuration() directly on client. This requires instance administration rights. The following configuration checks each agent’s daily estimated cost against warning and critical thresholds of 10 and 20, in the configured currency. Agents need cost monitoring data.

configuration = (
    client.new_alert_configuration(type="metric", name="Daily estimated cost")
    .with_metric("consumption.cost.total")
    .with_time_bucket("DAY")
    .with_thresholds(warning=10, critical=20)
    .create()
)
print(configuration.id)

Creating a metric alert at scope level

Create scope alert configurations in the Agent Management UI. The current Python client does not provide a creation method at scope level.

Open the scope, then its Alerting page. Create a metric alert configuration, choose its metric, time bucket, and thresholds, then save it. The configuration applies to the agents in that scope. You need permission to edit the scope.

Use agent.list_applicable_alert_configurations() to retrieve scope configurations that apply to an agent, as shown below.

Creating a metric alert at platform level

Get a platform handle, then call new_alert_configuration() on that handle. This example checks each agent’s daily interaction count on the selected platform.

platform = client.get_platform("production")
configuration = (
    platform.new_alert_configuration(type="metric", name="Daily interactions")
    .with_metric("activity.interactions")
    .with_time_bucket("DAY")
    .with_thresholds(warning=10000, critical=20000)
    .create()
)

Creating a metric alert at agent level

Get an agent handle, then call dataikuapi.agentmanagement.agent.Agent.new_alert_configuration() on that handle. This example checks daily estimated cost for the selected agent only. The agent must have cost monitoring data.

agent = client.get_agent("production", "support-agent")
configuration = (
    agent.new_alert_configuration(type="metric", name="Daily estimated cost")
    .with_metric("consumption.cost.total")
    .with_time_bucket("DAY")
    .with_thresholds(warning=10, critical=20)
    .create()
)
print(configuration.id)

Listing alert configurations

client.list_alert_configurations(), platform.list_alert_configurations(), and agent.list_alert_configurations() list configurations defined at their respective levels. To include configurations inherited by an agent from other levels, use list_applicable_alert_configurations().

for item in agent.list_alert_configurations():
    print(item.id, item.name, item.enabled)

for item in agent.list_applicable_alert_configurations():
    print(item.id, item.loc, item.latest_evaluation)

Each entry identifies where the configuration was defined and includes its latest evaluation, when available. The results also include configurations from scopes containing the agent. You can list these scope configurations with the Python client, but you must use the Agent Management UI to edit them.

Updating a configuration

Retrieve a configuration at the level where it is defined, then modify and save its settings.

configuration = agent.get_alert_configuration("configuration-id")
settings = configuration.get_settings()
settings.get_raw()["name"] = "Daily estimated cost limit"
settings.get_raw()["evaluationSettings"]["detectionPolicy"]["criticalThreshold"] = 25
settings.save()

This example assumes a fixed-threshold metric configuration. Keep its ID and subjectId unchanged. A concurrent edit causes saving to fail; retrieve the settings again before reapplying changes. To change the metric or linked review, create a new configuration.

Disabling or deleting a configuration

settings = configuration.get_settings()
settings.get_raw()["enabled"] = False
settings.save()

# To remove the configuration:
configuration.delete()

Creating an agent review alert

The review must already be linked to the monitored agent. This configuration triggers a critical alert after two consecutive completed review runs have failed.

configuration = (
    agent.new_alert_configuration(type="agent_review", name="Review failures")
    .with_agent_review("AGENTMONITORING", "review-id")
    .with_consecutive_failed_runs(2)
    .create()
)

Each run counts once, including eligible runs completed before the configuration was created. Evaluating the same run again does not increase the count. A successful run immediately satisfies the recovery condition. A missing review, an unlinked review, or a read error can trigger an alert without waiting for the required number of failed runs.

For metric detection and recovery choices, see Detection and recovery policies. For linked review configuration, see External agents and agent reviews.

Configuring AI alerts

AI alerts must be configured in the Agent Management UI.

Use the Python client to search for triggered AI alerts, read their details, acknowledge them, or close them. See Working with triggered alerts.

Reference documentation

Classes

dataikuapi.agentmanagement.alerting.AlertConfiguration(...)

An alert configuration owned by global settings, an platform, or an agent.

dataikuapi.agentmanagement.alerting.AlertConfigurationSettings(...)

Editable settings of an alert configuration.

dataikuapi.agentmanagement.alerting.AlertConfigurationListItem(...)

An alert configuration listing entry returned by list_alert_configurations or list_applicable_alert_configurations.

dataikuapi.agentmanagement.alerting.MetricAlertConfigurationBuilder(...)

Builds a metric alert configuration for creation globally, on an platform, or on an agent.

dataikuapi.agentmanagement.alerting.AgentReviewAlertConfigurationBuilder(...)

Builds an agent review alert configuration for creation on an agent only.

Functions

create()

Creates the alert configuration on this builder's owner.

delete()

Deletes this configuration and reconciles its alerts without affecting other configurations.

get_agent(platform_id, agent_id)

Returns a handle to an agent.

get_alert_configuration(configuration_id)

Returns a handle to an alert configuration owned on this agent.

get_platform(platform_id)

Returns a handle to an Agent Management platform.

get_raw()

Returns the mutable configuration settings.

get_settings()

Returns editable settings, including the metric or agent review, evaluation settings, and recovery policy.

list_alert_configurations([as_type])

Lists alert configurations owned on this agent, not configurations from other levels.

list_applicable_alert_configurations()

Lists global, platform, matching scope, and agent alert configurations applicable to this agent.

new_alert_configuration([type, name])

Initializes a new alert configuration builder owned by this client.

new_alert_configuration([type, name])

Initializes a new alert configuration builder owned by this platform.

new_alert_configuration([type, name])

Initializes a new alert configuration builder owned by this agent.

save()

Saves the complete configuration settings and refreshes them from the server response.

with_agent_review(project_key, agent_review_id)

Selects the agent review linked to this agent.

with_consecutive_failed_runs([count])

Requires consecutive completed failed runs before opening an alert.

with_metric(metric_id)

Selects the metric to evaluate.

with_thresholds([warning, critical, ...])

Selects fixed-threshold detection.

with_time_bucket([granularity, ...])

Selects a time bucket for Operational, Usage, Cost, Uptime, or Business KPI metrics.