{"command":{"effect":"write","timeoutSeconds":30,"inputSchema":{"type":"object","description":"This PUT endpoint uses merge semantics. To update an alert rule, send a\nrequest to `/v2/insights/alert-rules/{id}` with a full `spec`. Omit\n`notification_channels` to keep existing bindings. Omit `status` or\n`re_alert_duration` to keep those existing values.\n","properties":{"path":{"type":"object","properties":{"id":{"type":"string","format":"uuid","examples":["a1b2c3d4-e5f6-7890-abcd-ef1234567890"],"description":"A unique identifier for an alert rule."}},"required":["id"],"additionalProperties":false},"body":{"$ref":"#/definitions/alert_rule_request","examples":[{"spec":{"name":"High CPU (renamed)","query":{"metric":"do.droplets.cpu_utilization","resource_urns":["do:droplet:12345","do:droplet:67890"]},"condition":{"window":"EVALUATION_WINDOW_15M"},"thresholds":{"critical":90,"operator":"THRESHOLD_OPERATOR_GREATER_THAN_OR_EQUAL"},"notification_channels":[{"notification_channel_id":"550e8400-e29b-41d4-a716-446655440000"}]},"status":"ALERT_RULE_STATUS_PAUSED"}]}},"required":["path","body"],"additionalProperties":false,"definitions":{"alert_rule_request":{"type":"object","description":"Create or update body for an alert rule. `spec` is required. `status` is\noptional; create defaults to `ALERT_RULE_STATUS_ACTIVE`, and update keeps the\nexisting status when omitted.\n","required":["spec"],"properties":{"spec":{"$ref":"#/definitions/alert_rule_spec"},"status":{"type":"string","description":"Desired alert rule status. Allowed values:\n\n- `ALERT_RULE_STATUS_ACTIVE` = active\n- `ALERT_RULE_STATUS_PAUSED` = paused\n","enum":["ALERT_RULE_STATUS_ACTIVE","ALERT_RULE_STATUS_PAUSED"],"examples":["ALERT_RULE_STATUS_ACTIVE"]}}},"alert_rule_spec":{"type":"object","description":"Spec for an Insights alert rule. On create, `name`, `query`, `thresholds`,\nand at least one `notification_channels` binding are required. On update,\nomit `notification_channels` to keep existing bindings; an explicit empty\nlist is rejected.\n","required":["name","query","thresholds"],"properties":{"name":{"type":"string","description":"A human-readable name for the alert rule.","examples":["High CPU"]},"query":{"$ref":"#/definitions/metrics_query"},"condition":{"$ref":"#/definitions/alert_condition"},"thresholds":{"$ref":"#/definitions/alert_thresholds"},"notification_channels":{"type":"array","description":"Notification channels to notify when the rule fires.","minItems":1,"items":{"$ref":"#/definitions/notification_channel_binding"}},"re_alert_duration":{"type":"string","description":"Minimum wait before re-notifying a still-firing alert. Defaults to\n`RE_ALERT_DURATION_4H` on create when omitted. Allowed values:\n\n- `RE_ALERT_DURATION_30M` = `30m`\n- `RE_ALERT_DURATION_1H` = `1h`\n- `RE_ALERT_DURATION_4H` = `4h`\n- `RE_ALERT_DURATION_NEVER` = never\n","enum":["RE_ALERT_DURATION_30M","RE_ALERT_DURATION_1H","RE_ALERT_DURATION_4H","RE_ALERT_DURATION_NEVER"],"examples":["RE_ALERT_DURATION_4H"]}}},"metrics_query":{"type":"object","description":"Metrics query that the alert rule evaluates. `metric` must be a dotted\nOpenTelemetry name (for example `do.droplets.cpu_utilization`). Underscored\nPrometheus-style names are rejected. When `resource_urns` is omitted or empty,\nthe rule is not scoped to specific resources.\n","required":["metric"],"properties":{"metric":{"type":"string","description":"Dotted OpenTelemetry metric name to evaluate\n(for example `do.droplets.cpu_utilization`).\n","examples":["do.droplets.cpu_utilization"]},"filters":{"type":"array","description":"Optional label filters applied to the metric series.","items":{"$ref":"#/definitions/query_filter"}},"resource_urns":{"type":"array","description":"Optional list of DigitalOcean resource URNs the rule applies to. Empty or\nomitted means the rule is not scoped to specific resources.\n","items":{"type":"string"},"examples":[["do:droplet:12345"]]},"tags":{"type":"array","description":"Optional resource tags used to select matching resources.","items":{"type":"string"},"examples":[["env:prod"]]}}},"alert_condition":{"type":"object","description":"Evaluation condition for the alert rule.","properties":{"window":{"type":"string","description":"Time window over which the metric is evaluated. Allowed values:\n\n- `EVALUATION_WINDOW_1M` = `1m`\n- `EVALUATION_WINDOW_5M` = `5m`\n- `EVALUATION_WINDOW_10M` = `10m`\n- `EVALUATION_WINDOW_15M` = `15m`\n- `EVALUATION_WINDOW_30M` = `30m`\n- `EVALUATION_WINDOW_1H` = `1h`\n","enum":["EVALUATION_WINDOW_1M","EVALUATION_WINDOW_5M","EVALUATION_WINDOW_10M","EVALUATION_WINDOW_15M","EVALUATION_WINDOW_30M","EVALUATION_WINDOW_1H"],"examples":["EVALUATION_WINDOW_5M"]}}},"alert_thresholds":{"type":"object","description":"Threshold configuration for the alert rule. At least one of `warning` or\n`critical` must be set.\n","required":["operator"],"anyOf":[{"required":["warning"]},{"required":["critical"]}],"properties":{"warning":{"type":"number","description":"Warning threshold value.","examples":[80]},"critical":{"type":"number","description":"Critical threshold value.","examples":[95]},"operator":{"type":"string","description":"Comparison operator applied to the aggregated metric value. Allowed\nvalues:\n\n- `THRESHOLD_OPERATOR_EQUAL` = equal\n- `THRESHOLD_OPERATOR_LESS_THAN_OR_EQUAL` = `less_than_or_equal`\n- `THRESHOLD_OPERATOR_LESS_THAN` = `less_than`\n- `THRESHOLD_OPERATOR_GREATER_THAN` = `greater_than`\n- `THRESHOLD_OPERATOR_GREATER_THAN_OR_EQUAL` = `greater_than_or_equal`\n- `THRESHOLD_OPERATOR_NOT_EQUAL` = `not_equal`\n","enum":["THRESHOLD_OPERATOR_EQUAL","THRESHOLD_OPERATOR_LESS_THAN_OR_EQUAL","THRESHOLD_OPERATOR_LESS_THAN","THRESHOLD_OPERATOR_GREATER_THAN","THRESHOLD_OPERATOR_GREATER_THAN_OR_EQUAL","THRESHOLD_OPERATOR_NOT_EQUAL"],"examples":["THRESHOLD_OPERATOR_GREATER_THAN"]}}},"notification_channel_binding":{"type":"object","description":"Binding from an alert rule to a notification channel. When `notify_on` is\nomitted or empty, the channel is notified for all severities.\n","required":["notification_channel_id"],"properties":{"notification_channel_id":{"type":"string","format":"uuid","description":"ID of an existing notification channel owned by the account.","examples":["550e8400-e29b-41d4-a716-446655440000"]},"notify_on":{"type":"array","description":"Severities that trigger this channel. Allowed values:\n\n- `SEVERITY_WARNING` = warning\n- `SEVERITY_CRITICAL` = critical\n","items":{"type":"string","enum":["SEVERITY_WARNING","SEVERITY_CRITICAL"]},"examples":[["SEVERITY_CRITICAL"]]}}},"query_filter":{"type":"object","description":"A filter applied to the metrics query.","required":["field","operator","value"],"properties":{"field":{"type":"string","description":"The metric label or field to filter on.","examples":["host_id"]},"operator":{"type":"string","description":"Comparison operator for the filter. Allowed values:\n\n- `FILTER_OPERATOR_EQUAL` = equal\n- `FILTER_OPERATOR_NOT_EQUAL` = `not_equal`\n- `FILTER_OPERATOR_LESS_THAN` = `less_than`\n- `FILTER_OPERATOR_LESS_THAN_OR_EQUAL` = `less_than_or_equal`\n- `FILTER_OPERATOR_GREATER_THAN` = `greater_than`\n- `FILTER_OPERATOR_GREATER_THAN_OR_EQUAL` = `greater_than_or_equal`\n","enum":["FILTER_OPERATOR_EQUAL","FILTER_OPERATOR_NOT_EQUAL","FILTER_OPERATOR_LESS_THAN","FILTER_OPERATOR_LESS_THAN_OR_EQUAL","FILTER_OPERATOR_GREATER_THAN","FILTER_OPERATOR_GREATER_THAN_OR_EQUAL"],"examples":["FILTER_OPERATOR_EQUAL"]},"value":{"type":"string","description":"Value compared against the field.","examples":["12345678"]}}}}},"name":"Update an Alert Rule","id":"digitalocean.insights_update_alertrule","example":{"path":{"id":"a1b2c3d4-e5f6-7890-abcd-ef1234567890"},"body":{"spec":{"name":"High CPU","query":{"metric":"do.droplets.cpu_utilization"},"thresholds":{"operator":"THRESHOLD_OPERATOR_GREATER_THAN","warning":80}}}},"maxRequests":1,"summary":false}}