获取 Amazon RDS 的 CloudWatch Events 和 Amazon EventBridge 事件 - Amazon Relational Database Service
AWS 文档中描述的 AWS 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅中国的 AWS 服务入门

获取 Amazon RDS 的 CloudWatch Events 和 Amazon EventBridge 事件

您可以使用 Amazon CloudWatch Events 和 Amazon EventBridge 这两者自动执行您的 AWS 服务并自动响应系统事件,例如应用程序可用性问题或资源更改。AWS 服务中的事件将近实时传输到 CloudWatch Events 和 EventBridge。您可以编写简单规则来指示所关注的事件,并指示要在事件匹配规则时执行的自动化操作。

您可以设置接收 JSON 格式的事件的各种目标,例如 AWS Lambda 函数或 Amazon SNS 主题。有关更多信息,请参阅 Amazon CloudWatch Events 用户指南Amazon EventBridge 用户指南

例如,您可以将 Amazon RDS 配置为只要创建或删除数据库实例就向 CloudWatch Events 或 Amazon EventBridge 发送事件。

将 Amazon RDS 事件发送到 CloudWatch Events

您可以创建 CloudWatch Events 规则,以将 Amazon RDS 事件发送到 CloudWatch Events。

可以使用以下步骤创建对 AWS 服务发出的事件进行触发的 CloudWatch Events 规则。

创建对事件触发的规则:

  1. 通过以下网址打开 CloudWatch 控制台:https://console.amazonaws.cn/cloudwatch/

  2. 在导航窗格中的事件下,选择规则

  3. 选择 Create rule

  4. 对于 Event Source,执行以下操作:

    1. 选择 Event Pattern (事件模式)

    2. 对于服务名称,请选择 Relational Database Service (RDS)

    3. 对于事件类型,选择触发事件的 Amazon RDS 资源的类型。例如,如果数据库实例触发事件,请选择RDS 数据库实例事件

  5. 对于目标,选择添加目标,然后选择 CloudWatch 日志组

  6. 对于日志组,输入用于存储事件的日志组的名称。

  7. 选择 Configure details。对于 Rule definition,键入规则的名称和描述。

  8. 选择 Create rule

数据库实例事件

以下是数据库实例事件的示例。

{ "version": "0", "id": "68f6e973-1a0c-d37b-f2f2-94a7f62ffd4e", "detail-type": "RDS DB Instance Event", "source": "aws.rds", "account": "123456789012", "time": "2018-09-27T22:36:43Z", "region": "us-east-1", "resources": [ "arn:aws:rds:us-east-1:123456789012:db:my-db-instance" ], "detail": { "EventCategories": [ "failover" ], "SourceType": "DB_INSTANCE", "SourceArn": "arn:aws:rds:us-east-1:123456789012:db:my-db-instance", "Date": "2018-09-27T22:36:43.292Z", "SourceIdentifier": "rds:my-db-instance", "Message": "A Multi-AZ failover has completed." } }

数据库参数组事件

以下是数据库参数组事件的示例。

{ "version": "0", "id": "844e2571-85d4-695f-b930-0153b71dcb42", "detail-type": "RDS DB Parameter Group Event", "source": "aws.rds", "account": "123456789012", "time": "2018-10-06T12:26:13Z", "region": "us-east-1", "resources": [ "arn:aws:rds:us-east-1:123456789012:pg:my-db-param-group" ], "detail": { "EventCategories": [ "configuration change" ], "SourceType": "DB_PARAM", "SourceArn": "arn:aws:rds:us-east-1:123456789012:pg:my-db-param-group", "Date": "2018-10-06T12:26:13.882Z", "SourceIdentifier": "rds:my-db-param-group", "Message": "Updated parameter time_zone to UTC with apply method immediate" } }

数据库安全组事件

以下是数据库安全组事件的示例。

{ "version": "0", "id": "844e2571-85d4-695f-b930-0153b71dcb42", "detail-type": "RDS DB Security Group Event", "source": "aws.rds", "account": "123456789012", "time": "2018-10-06T12:26:13Z", "region": "us-east-1", "resources": [ "arn:aws:rds:us-east-1:123456789012:secgrp:my-security-group" ], "detail": { "EventCategories": [ "configuration change" ], "SourceType": "SECURITY_GROUP", "SourceArn": "arn:aws:rds:us-east-1:123456789012:secgrp:my-security-group", "Date": "2018-10-06T12:26:13.882Z", "SourceIdentifier": "rds:my-security-group", "Message": "Applied change to security group" } }

数据库快照事件

以下是数据库快照事件的示例。

{ "version": "0", "id": "844e2571-85d4-695f-b930-0153b71dcb42", "detail-type": "RDS DB Snapshot Event", "source": "aws.rds", "account": "123456789012", "time": "2018-10-06T12:26:13Z", "region": "us-east-1", "resources": [ "arn:aws:rds:us-east-1:123456789012:snapshot:rds:my-db-snapshot" ], "detail": { "EventCategories": [ "deletion" ], "SourceType": "SNAPSHOT", "SourceArn": "arn:aws:rds:us-east-1:123456789012:snapshot:rds:my-db-snapshot", "Date": "2018-10-06T12:26:13.882Z", "SourceIdentifier": "rds:my-db-snapshot", "Message": "Deleted manual snapshot" } }