Updated on 2026-02-10 GMT+08:00

Updating a Notification Rule

Function

Updates notification rules of the corresponding metric. A notification is sent when the rules are met.

Debugging

You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.

Authorization Information

Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.

  • If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
  • If you are using identity policy-based authorization, the following identity policy-based permissions are required.

    Action

    Access Level

    Resource Type (*: required)

    Condition Key

    Alias

    Dependencies

    workspace:statistics:updateNotificationRules

    Write

    -

    -

    -

    smn:topic:get

URI

PUT /v2/{project_id}/statistics/notify-rules/{rule_id}

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID.

rule_id

Yes

String

Notification rule ID.

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

metric_name

No

String

Metric name. Currently, the value can only be desktop_idle_duration, which is fixed.

The rules of the same metric must be unique.

  • desktop_idle_duration - Desktop idle duration

threshold

No

Integer

Rule configuration – Threshold (day)

comparison_operator

No

String

Condition for comparing a metric statistical value with the threshold.

  • >= - Triggered when the metric statistical value is greater than or equal to the threshold.

  • > - Triggered when the metric statistical value is greater than the threshold.

  • = - Triggered when the metric statistical value is equal to the threshold.

  • <= - Triggered when the metric statistical value is less than or equal to the threshold.

  • < - Triggered when the metric statistical value is less than the threshold.

interval

No

Integer

Interval for sending the next notification after the notification is triggered. The default value is once a day.

enable

No

Boolean

Whether to enable or disable a rule. true: enable; false: disable.

notify_object

No

String

Notification object; uniform resource name (URN) of an SMN topic.

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

rule_id

String

Rule ID.

metric_name

String

Metric name. Currently, the value can only be desktop_idle_duration, which is fixed.

  • desktop_idle_duration - Desktop idle duration

threshold

Integer

Statistical period (days).

comparison_operator

String

Condition for comparing a metric statistical value with the threshold.

  • >= - Triggered when the metric statistical value is greater than or equal to the threshold.

  • > - Triggered when the metric statistical value is greater than the threshold.

  • = - Triggered when the metric statistical value is equal to the threshold.

  • <= - Triggered when the metric statistical value is less than or equal to the threshold.

  • < - Triggered when the metric statistical value is less than the threshold.

interval

Integer

Interval for sending the next notification after the notification is triggered. The default value is once a day.

enable

Boolean

Whether to enable or disable a rule. true: enable; false: disable.

notify_object

String

Notification object; uniform resource name (URN) of an SMN topic.

Status code: 400

Table 4 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 401

Table 5 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 500

Table 6 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Example Requests

{
  "metric_name" : "desktop_idle_duration",
  "threshold" : 30,
  "comparison_operator" : ">=",
  "interval" : 1,
  "enable" : true,
  "notify_object" : "urn:smn:REGION_ID:XXX-XXX-XXX:topicName"
}

Example Responses

Status code: 200

Succeeded.

{
  "rule_id" : "xxxx-xxxx-xxxx",
  "metric_name" : "desktop_idle_duration",
  "threshold" : 30,
  "comparison_operator" : "",
  "interval" : 1,
  "enable" : true,
  "notify_object" : "urn:smn:REGION_ID:XXX-XXX-XXX:topicName"
}

Status Codes

Status Code

Description

200

Succeeded.

400

Invalid request from the client.

401

Authentication failed.

500

Internal error.

Error Codes

See Error Codes.