All Products
Search
Document Center

Database Autonomy Service:SetEventSubscription

Last Updated:Apr 25, 2024

Configures the event subscription settings for a database instance.

Operation description

Before you call this operation, take note of the following items:

  • If you use Alibaba Cloud SDK or Database Autonomy Service (DAS) SDK to call this operation, we recommend that you use the latest version of the SDK.
  • If you use an SDK to call operations of DAS, you must set the region ID to cn-shanghai.
  • The database instance that you want to manage is connected to DAS.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
hdm:SetEventSubscriptionWrite
  • All Resources
    *
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
InstanceIdstringYes

The instance ID.

rm-2ze8g2am97624****
EventContextstringNo

The supported event scenarios. You can set the value to AllContext, which indicates that all scenarios are supported.

AllContext
LangstringNo

The language of event notifications. You can set the value to zh-CN, which indicates that event notifications are sent in Chinese.

zh-CN
MinIntervalstringNo

The minimum interval between consecutive event notifications. Unit: seconds.

60
ContactNamestringNo

The name of the contact who receives alert notifications. Separate multiple names with commas (,).

Default contact
ChannelTypestringNo

The notification method. Valid values:

  • hdm_alarm_sms: text message.
  • dingtalk: DingTalk chatbot.
  • hdm_alarm_sms_and_email: text message and email.
  • hdm_alarm_sms,dingtalk: text message and DingTalk chatbot.
hdm_alarm_sms,dingtalk
ContactGroupNamestringNo

The name of the contact group that receives alert notifications. Separate multiple names with commas (,).

Default contact group
LevelstringNo

The risk level of the events. Valid values:

  • Notice: events that trigger notifications, including events at the Notice, Optimization, Warn, and Critical levels.
  • Optimization: events that trigger optimizations, including events at the Optimization, Warn, and Critical levels.
  • Warn: events that trigger warnings, including events at the Warn and Critical levels.
  • Critical: events that trigger critical warnings.

The following content describes the events at each level in detail:

  • Notice: events that are related to database exceptions for which no suggestions are generated.
  • Optimization: events for which optimization suggestions are generated based on the status of the database.
  • Warn: events that may affect the running of the database.
  • Critical: events that affect the running of the database.
Optimization
ActivestringNo

Specifies whether to enable the event subscription feature. Valid values:

  • 0: disables the event subscription feature.
  • 1: enables the event subscription feature.
1
SeveritystringNo

The alert severity based on the event type.

Specify this parameter in the following format: {"Event type 1":"Alert severity", "Event type 2":"Alert severity"}.

Valid values of event types:

  • AutoScale: auto scaling event.
  • SQLThrottle: throttling event.
  • TimeSeriesAbnormal: event for detecting time series anomalies.
  • SQLOptimize: SQL optimization event.
  • ResourceOptimize: storage optimization event.

Valid values of alert severities:

  • info
  • noticed
  • warning
  • critical
{"AutoScale":"critical","SQLThrottle":"info","TimeSeriesAbnormal":"warning"}
DispatchRulestringNo

The notification rules based on the event type. If you leave this parameter empty, the values of MinInterval and ChannelType prevail.

Specify this parameter in the following format: {"silenced": {"Event type 1":Specifies whether to enable adaptive silence, "Event type 2":Specify whether to enable adaptive silence},"min_interval": {"Event type 1":Minimum interval between event notifications, "Event type 2":Minimum interval between event notifications},"alert_type": {"Event type 1":"Notification method", "Event type 2":"Notification method"}}.

  • silenced: specifies whether to enable adaptive silence. After you enable adaptive silence, the interval between consecutive alert notifications for an event is the greater one of the minimum interval specified by min_interval and one third of the event duration. Valid values:

    • 1: enables adaptive silence.
    • 2: disables adaptive silence.
  • min_interval: the minimum interval between event notifications. Unit: seconds.

  • alert_type: the notification method. Valid values:

    • hdm_alarm_sms: text message.
    • dingtalk: DingTalk chatbot.
    • hdm_alarm_sms_and_email: text message and email.
    • hdm_alarm_sms,dingtalk: text message and DingTalk chatbot.
{"silenced": {"AutoScale":1, "SQLThrottle":0, "TimeSeriesAbnormal": 1}, "min_interval": {"AutoScale":300, "SQLThrottle":360, "TimeSeriesAbnormal": 120}, "alert_type": {"AutoScale":"hdm_alarm_sms", "SQLThrottle":"hdm_alarm_sms_and_email", "TimeSeriesAbnormal": "hdm_alarm_sms,dingtalk"}}

Response parameters

ParameterTypeDescriptionExample
object

The response parameters.

RequestIdstring

The request ID.

097F0C56-B252-515A-B602-FC56EF93EF8A
Messagestring

The returned message.

Note If the request was successful, Successful is returned. If the request failed, an error message such as an error code is returned.
Successful
Dataobject

The detailed information.

userIdstring

The user ID.

1088760496****
instanceIdstring

The instance ID.

rm-2ze8g2am97624****
eventContextstring

The supported event scenarios. Only AllContext is returned for this parameter, which indicates that all scenarios are supported.

AllContext
langstring

The language of event notifications. Only zh-CN is returned for this parameter, which indicates that event notifications are sent in Chinese.

zh_CN
activeinteger

Indicates whether the event subscription feature is enabled. Valid values:

  • 0: The event subscription feature is disabled.
  • 1: The event subscription feature is enabled.
1
minIntervalinteger

The minimum interval between consecutive event notifications. Unit: seconds.

60
contactNamestring

The name of the contact who receives alert notifications. Multiple names are separated by commas (,).

Default contact
contactGroupNamestring

The name of the contact group that receives alert notifications. Multiple names are separated by commas (,).

Default contact group
channelTypestring

The notification method. Valid values:

  • hdm_alarm_sms: text message.
  • dingtalk: DingTalk chatbot.
  • hdm_alarm_sms_and_email: text message and email.
  • hdm_alarm_sms,dingtalk: text message and DingTalk chatbot.
hdm_alarm_sms,dingtalk
levelstring

The risk level of the events. Valid values:

  • Notice
  • Optimization
  • Warn
  • Critical
Optimization
Codestring

The HTTP status code returned.

200
Successstring

Indicates whether the request was successful. Valid values:

  • true
  • false
true

Examples

Sample success responses

JSONformat

{
  "RequestId": "097F0C56-B252-515A-B602-FC56EF93EF8A",
  "Message": "Successful",
  "Data": {
    "userId": "1088760496****",
    "instanceId": "rm-2ze8g2am97624****",
    "eventContext": "AllContext",
    "lang": "zh_CN",
    "active": 1,
    "minInterval": 60,
    "contactName": "Default contact",
    "contactGroupName": "Default contact group",
    "channelType": "hdm_alarm_sms,dingtalk",
    "level": "Optimization"
  },
  "Code": "200",
  "Success": "true"
}

Error codes

HTTP status codeError codeError message
400InvalidParamsThe request parameters are invalid.
403NoPermissionYou are not authorized to do this action.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2023-04-25The request parameters of the API has changedsee changesets
Change itemChange content
Input ParametersThe request parameters of the API has changed.
    Added Input Parameters: Severity
    Added Input Parameters: DispatchRule