All Products
Search
Document Center

Database Autonomy Service:SetEventSubscription

Last Updated:Dec 23, 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 an Alibaba Cloud SDK or a 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 the API operations of DAS, you must set the region ID to cn-shanghai.
  • Make sure that the database instance that you want to manage is connected to DAS.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

There is currently no authorization information disclosed in the API.

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.

Codestring

The HTTP status code returned.

200
Dataobject

The detailed information.

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
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
contactGroupNamestring

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

Default contact group
contactNamestring

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

Default contact
eventContextstring

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

AllContext
instanceIdstring

The instance ID.

rm-2ze8g2am97624****
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
levelstring

The risk level of the events. Valid values:

  • Notice
  • Optimization
  • Warn
  • Critical
Optimization
minIntervalinteger

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

60
userIdstring

The user ID.

1088760496****
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
RequestIdstring

The request ID.

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

Indicates whether the request was successful. Valid values:

  • true
  • false
true

Examples

Sample success responses

JSONformat

{
  "Code": "200",
  "Data": {
    "active": 1,
    "channelType": "hdm_alarm_sms,dingtalk",
    "contactGroupName": "Default contact group",
    "contactName": "Default contact",
    "eventContext": "AllContext",
    "instanceId": "rm-2ze8g2am97624****",
    "lang": "zh_CN",
    "level": "Optimization",
    "minInterval": 60,
    "userId": "1088760496****"
  },
  "Message": "Successful",
  "RequestId": "097F0C56-B252-515A-B602-FC56EF93EF8A",
  "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 changedView Change Details