Instructor: Okay, so now let's talk
about RDS Events and event subscriptions.
So RDS will keep a record of events related
to multiple events related to database instances,
to your snapshots, to changes made
to your parameter groups or your security groups, et cetera.
So what is an event?
Well, an event can be, for example,
that a database state changed from pending to running.
So we're going to have RDS Event subscriptions,
and to be alerted of these events,
and it could be an SNS topic, to get notified
of some events or old events,
and you can specify the event source,
and even category, if you wanted
to have a more granular type of event sent to SNS.
But also, it's possible for you to get these events coming
out of EventBridge.
So it's possible for you to set up some rules.
And then the EventBridge will react to your RDS events.
So here's an example, for example, of an event.
So it could be a backup event of your DB instance
that would be sent to RDS Events,
which can, in turn, trigger a notification in SNS,
or it can trigger an event in EventBridge.
The second thing I want to talk to you about is
around database log files.
So your RDS database instance has some logs.
For example, general logs, audit logs,
error logs, slow query logs, that kind of things.
So you can send these logs into CloudWatch Logs,
and then you can apply, on top of CloudWatch Logs,
a metric filter.
For example, you can have a look
at the Error keyword, and in case it happens
too many times or too often,
then you can set up a CloudWatch Alarm on top of it.
So this allows you to do some log alerting.
And then this CloudWatch Alarm can send an alert,
for example, to an SNS topic,
and then this SNS topic can send a notification
to the database admin.
So this allows you to do some more alerting
and some more eventing on top of your RDS database,
based, this time, not on the database events,
but on the logs themselves.
So now let's go see, in the consoles,
how we can set things up.
So here you have, on the left-hand side,
the Events tab, and in the events,
you can see all the events that happened
within your account.
So I think you get 24 hours of data within the console.
And so the idea is that, you can see,
for example, that I created a database here.
Then some things were changed, a backup was initiated.
Then I deleted this database, and then I created a new one.
And so you can see all the messages right here.
So it could be instance-related type of events
or snapshots-related type of events,
or it could be security group or a parameter group.
And you can see the message of all these events right here.
So here, this is cool, because you see a log
of all the events that happened within the RDS databases,
and you can set up your event subscriptions.
You can create one.
Interesting, okay, I'll do a demo subscription.
And you could have a new topic to create,
or you can set up your own ARN topic
to send to, your notifications.
And then the source of these events.
So it could be your instances,
and you could say, okay, all instances,
or some instances only, and all event categories
or specific range of categories,
and you can be alerted based on all these ranges.
So it's quite handy.
And you could have instances, security group,
parameter groups, snapshot, cluster,
cluster snapshots, and custom engine version
as a source type of your event subscription.
So you can get very, very creative.
And the destination of that is going to be an SNS topic.
And alternately, you could go into CloudWatch Events
or EventBridge and set up your own events there, as well.
So if I go into my database, I can have a look
at the Logs & Events page.
And so we can see CloudWatch alarms related
to my database, recent events from a database,
and logs, and here we can have a look
at the logs available to us.
So we have the mysql-error-running.log,
the mysqlUpgrade log, and you can view,
watch, or download.
So you can view this one, for example,
and we get some information around what happened.
And we can refresh this,
and this will display approximately 1,000 lines of this log.
And if you wanted to send these logs
into CloudWatch Logs for analysis
and to create some metrics filter,
what you could do is that you could modify the database,
and here you can modify the settings.
Now we have to find the log-related settings.
So I will go ahead and scroll down,
when this is available.
So here we go.
And under additional configuration, right here,
I scroll down and I see that there is a logs export option.
So I can export the audit, error, general log,
and slow query logs.
And if I enable this, then this is going to publish
those automatically to CloudWatch Logs.
And then you could set up your own metrics
on top of those to do some alerting based
on some keywords, or whatever you wanna find,
or some analytics.
So that's it for the RDS Events and logging.
I hope you liked it, and I will see you in the next lecture.