Method
createMonitorAlert POST
Copy POST

Create a monitor alert for the given conditions and monitor. We can create monitor alert either for model monitor or real-time monitor.

Arguments:

REQUIRED KEY TYPE DESCRIPTION
Yes projectId str Unique string identifier for the project.
Yes alertName str Name of the alert.
Yes conditionConfig AlertConditionConfig Condition to run the actions for the alert.
KEY TYPE Description
alertType None None
Yes actionConfig AlertActionConfig Configuration for the action of the alert.
KEY TYPE Description
actionType None None
No modelMonitorId str Unique string identifier for the model monitor created under the project.
No realtimeMonitorId str Unique string identifier for the real-time monitor for the deployment created under the project.
Note: The arguments for the API methods follow camelCase but for Python SDK underscore_case is followed.

Response:

KEY TYPE DESCRIPTION
success Boolean true if the call succeeded, false if there was an error
result MonitorAlert
KEY TYPE Description
name str The user-friendly name for the alert.
monitorAlertId str The unique identifier of the monitor alert.
createdAt str Date and time at which the monitor alert was created.
projectId str The project this alert belongs to.
modelMonitorId str The monitor id that this alert is associated with
realtimeMonitorId str The realtime monitor id that this alert is associated with
conditionConfig dict The condition configuration for this alert.
actionConfig dict The action configuration for this alert.
conditionDescription str User friendly description of the condition
actionDescription str User friendly description of the action
alertType str The type of the alert
deploymentId str The deployment ID this alert is associated with
latestMonitorAlertVersion MonitorAlertVersion The latest monitor alert version.

Exceptions:

TYPE WHEN
DataNotFoundError

projectId is not found.

DataNotFoundError

modelMonitorId is not found.

DataNotFoundError

realtimeMonitorId is not found.

Language:

python

Request
client.create_monitor_alert(
    project_id='<id>',
    model_monitor_id='<id>',
    alert_name='test_alert',
    condition_config='{"alert_type":"AccuracyBelowThreshold","threshold":0.1}',
    action_config='{"action_type":"Email","email_recipients":["test@example.com"]}'
)

Response
MonitorAlert(name='test_alert',
  monitor_alert_id='<id>',
  created_at='2023-11-30T01:59:46+00:00',
  project_id='<id>',
  model_monitor_id='<id>',
  condition_config={'threshold': 0.1, 'alert_type': 'AccuracyBelowThreshold'},
  action_config={'action_type': 'Email', 'email_recipients': ['test@example.com']},
  condition_description='Accuracy Is Below 10.00%',
  action_description="Email: ['test@example.com']",
  alert_type='AccuracyBelowThreshold',
  latest_monitor_alert_version='<version>')