PutEventRule

更新时间:
复制 MD 格式

Creates or modifies an event-based alert rule by calling the PutEventRule operation.

Operation description

If the Event-triggered Alert Rule name does not exist, a new alert rule is created. If the Event-triggered Alert Rule name already exists, the existing alert rule is modified.

This topic provides an example of how to create an event-based alert rule named myRuleName for the Alibaba Cloud service ecs.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

cms:PutEventRule

create

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

RuleName

string

Yes

The name of the Event-triggered Alert Rule.

myRuleName

GroupId

string

No

The ID of the application group to which the Event-triggered Alert Rule belongs.

7378****

EventType

string

No

The type of the Event-triggered Alert Rule. Valid values:

  • SYSTEM: system event.

  • CUSTOM: custom event.

SYSTEM

Description

string

No

The description of the Event-triggered Alert Rule.

Event alert test

State

string

No

The status of the Event-triggered Alert Rule. Valid values:

  • ENABLED: enabled.

  • DISABLED: disabled.

ENABLED

EventPattern

array<object>

Yes

The pattern of the Event-triggered Alert Rule.

object

No

None.

EventTypeList

array

No

The type of the Event-triggered Alert Rule. Valid values of N: 1 to 50. Valid values:

  • StatusNotification: fault notification.

  • Exception: exception.

  • Maintenance: O&M.

  • *: unlimited.

Exception

string

No

The type of the Event-triggered Alert Rule. Valid values of N: 1 to 50. Valid values:

  • StatusNotification: fault notification.

  • Exception: exception.

  • Maintenance: O&M.

  • *: unlimited.

Exception

StatusList

array

No

The status of the Event-triggered Alert Rule. Valid values of N: 1 to 50.

Failed

string

No

The status of the Event-triggered Alert Rule. Valid values of N: 1 to 50.

Failed

Product

string

Yes

The Alibaba Cloud service type. Valid values of N: 1 to 50.

Note

For information about the Alibaba Cloud services supported by Event-triggered Alert Rules, see DescribeSystemEventMetaList.

ecs

LevelList

array

No

The level of the Event-triggered Alert Rule. Valid values of N: 1 to 50. Valid values:

  • CRITICAL: critical.

  • WARN: warning.

  • INFO: information.

  • *: all levels.

CRITICAL

string

No

The level of the Event-triggered Alert Rule. Valid values of N: 1 to 50. Valid values:

  • CRITICAL: critical.

  • WARN: warning.

  • INFO: information.

  • *: all levels.

CRITICAL

NameList

array

No

The name of the Event-triggered Alert Rule. Valid values of N: 1 to 50.

Agent_Status_Stopped

string

No

The name of the Event-triggered Alert Rule. Valid values of N: 1 to 50.

Agent_Status_Stopped

CustomFilters

string

No

The keyword for event filtering. When the event content contains this keyword, an alert is automatically triggered.

Stopping

SQLFilter

string

No

The SQL filter for events. When the event content meets the SQL condition, an alert is automatically triggered.

Note

The syntax of the SQL event filter is consistent with the query syntax of Simple Log Service (SLS).

192.168.XX.XX and Executed

SilenceTime

integer

No

The mute period. Unit: seconds.

86400

For more information about common request parameters, see Common parameters.

Response elements

Element

Type

Description

Example

object

Code

string

The status code.

Note

A value of 200 indicates success.

200

Message

string

The error message.

The Request is not authorization.

Data

string

The number of rows affected when the Event-triggered Alert Rule is created or modified.

1

RequestId

string

The request ID.

0B47C47B-E68A-4429-BB23-370E91889C7D

Success

boolean

Indicates whether the operation was successful. Valid values:

  • true: The operation was successful.

  • false: The operation failed.

true

Examples

Success response

JSON format

{
  "Code": "200",
  "Message": "The Request is not authorization.",
  "Data": "1",
  "RequestId": "0B47C47B-E68A-4429-BB23-370E91889C7D",
  "Success": true
}

Error codes

HTTP status code

Error code

Error message

Description

400 %s %s
500 InternalError The request processing has failed due to some unknown error.
403 %s %s

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.