Alerts for specific RDS event id

0

Hello, I have a necessity to be notified when RDS Storage autoscaler has triggered a pending scale storage task that will reach or exceed the maximum storage threshold. In this documentation I have found that event "RDS-EVENT-0224" will fits perfect for this purpose.

Now I have a question: How to receive an alert or notification for only this specific event ?

Clarifications: In RDS console there is only possible to chose an event type and event category, such as instance type and category "failure". But I would like to receive a notificattion only for one event_id which is RDS-EVENT-0224.

So maybe there some other way like set some alarms for specific event. Maybe there are also some examples of how to do this with terraform?

Thanks in advance!

3 Answers
1
Accepted Answer

You can use Amazon Eventbridge for this purpose. You can define the Eventbridge rule in such a way that it triggers when this event type occurs for this resource. Then you could use the rule to initiate the notification though available mechanisms like Amazon SNS. While defining the rule in EventBridge, you could use a filter pattern using SourceType, SourceIdentifier/SourceARN and Event_ID to narrow down the scope to the event of your choice. For the EventBridge target, you could use a number of destinations like CloudWatch, SNS, etc. You could even use the EventBridge rule to trigger an SSM document to accomplish the follow up tasks that you want to do automatically.

See EventBridge documentation https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-events.html for further details.

Hope this helps.

AWS
EXPERT
answered a year ago
EXPERT
reviewed a year ago
  • Thanks, I think this way is the best. Maybe you have some examples how to do this with terraform/terragrunt? Thanks in advance!

  • I do not have examples with terraform/terragrunt. But I am giving below a sample from one of the tasks I carried out recently. I wanted to manage a snapshot using a shell script on an EC2 instance whenever the snapshot is used for a restore operation. Maybe this will give you an idea how to use this process and then you should be able to apply in your environment.

    1. EVENT The full event when a DB snapshot is restored (dates & account numbers redacted):

    { "version": "0", "id": "abcd1234-08zz-bb22-1aa1-1234abcd3df6", "detail-type": "RDS DB Snapshot Event", "source": "aws.rds", "account": "123456789012", "time": "2032-66-55T21:18:24Z", "region": "us-east-1", "resources": ["arn:aws:rds:us-east-1:123456789012:snapshot:orcl-manual-2032099999"], "detail": { "EventCategories": ["restoration"], "SourceType": "SNAPSHOT", "SourceArn": "arn:aws:rds:us-east-1: 123456789012:snapshot:orcl-manual-2032099999", "Date": "2032-01-26T21:58:25.151Z", "Message": "Restored from snapshot orcl-manual-2032099999", "SourceIdentifier": "orcl-manual-2032019996", "EventID": "RDS-EVENT-0043", "Tags": { "auto-delete": "no" } } }

    The pattern I used for triggering the EventBridge rule (when the given snapshot is used for a restore operation):

    { "detail-type": ["RDS DB Snapshot Event"], "source": ["aws.rds"], "detail": { "SourceType": ["SNAPSHOT"], "SourceArn": "arn:aws:rds:us-east-1: 123456789012:snapshot:orcl-manual-2032099999"

  • "EventID": ["RDS-EVENT-0043"] } }

    1. Target action: A SSM Run command

    SSM Run Command: Target: EC2 Instance where the target-cmd.sh script is located and needs to be run [This can be furnished using tag values or the instance-id itself]

    Target input using an input transformer: Input Path: {"instance-id":"$.detail.SourceIdentifier"}

    Template: {"commands": ["su - oracle -c "/home/myuser/target-cmd.sh <instance-id>""]}

    Note: So, based on the above sample event, this input transformer would result in the followingoutput: {"commands": ["su - oracle -c "/home/myuser/target-cmd.sh orcl-manual-2032019996""]}

    1. Action:

    SSM: Run target-cmd.sh on the EC2 Given the sample output above, this will be the command executed on the target host: su - oracle -c "/home/myuser/target-cmd.sh orcl-manual-2032019996"

  • @Govardhanan_R, Maybe you know whether Lambda is needed for this setup? Or Eventbridge + SNS will be enough?

1

Here is an example of how to do it with Terraform https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/db_event_subscription

Try event category - low storage, this even triggers storage autoscaling

With storage autoscaling enabled, when Amazon RDS detects that you are running out of free database space it automatically scales up your storage. Amazon RDS starts a storage modification for an autoscaling-enabled DB instance when Free available space is less than or equal to 10 percent of the allocated storage.

DB instance events

Amazon RDS storage autoscaling

EXPERT
answered a year ago
EXPERT
reviewed 10 months ago
0

For this purpose you can utilize Lambda. A Lambda function could be triggered by RDS DB Instance events for storage modification. The Lambda could then query the DB Instance storage size and you can either write a custom metric value and set up an alarm or alert to SNS directly from there.

AWS
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions