-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(rds): support Database Insights for Aurora databases #32851
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #32851 +/- ##
=======================================
Coverage 80.83% 80.83%
=======================================
Files 236 236
Lines 14251 14251
Branches 2490 2490
=======================================
Hits 11520 11520
Misses 2446 2446
Partials 285 285
Flags with carried forward coverage won't be shown. Click here to find out more.
|
} | ||
|
||
// Database Insights is not supported for non-Aurora engines | ||
if (props.databaseInsightsMode && !props.engine.engineType.startsWith('aurora')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, DatabaseClusterEngine
only supports Aurora engines, but AWS::RDS::DBCluster
supports standard MySQL and PostgreSQL engines.
Database Insights only supports Aurora engines, so I added validation here, just in case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks 👍 Left comments for minor adjustments
if (enablePerformanceInsights && props.enablePerformanceInsights === false) { | ||
throw new Error('`enablePerformanceInsights` disabled, but `performanceInsightRetention` or `performanceInsightEncryptionKey` was set'); | ||
throw new Error('`enablePerformanceInsights` disabled, but `performanceInsightRetention` or `performanceInsightEncryptionKey` was set, or `databaseInsightsMode` was set to `DatabaseInsightsMode.ADVANCED`'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw new Error('`enablePerformanceInsights` disabled, but `performanceInsightRetention` or `performanceInsightEncryptionKey` was set, or `databaseInsightsMode` was set to `DatabaseInsightsMode.ADVANCED`'); | |
throw new Error('`enablePerformanceInsights` disabled, but `performanceInsightRetention` or `performanceInsightEncryptionKey` was set, or `databaseInsightsMode` was set to \'${DatabaseInsightsMode.ADVANCED}\'`'); |
Let's use the variable value for clarity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
&& props.performanceInsightRetention | ||
&& props.performanceInsightRetention !== PerformanceInsightRetention.MONTHS_15 | ||
) { | ||
throw new Error('`performanceInsightRetention` must be set to PerformanceInsightRetention.MONTHS_15 when `databaseInsightsMode` is set to DatabaseInsightsMode.ADVANCED'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw new Error('`performanceInsightRetention` must be set to PerformanceInsightRetention.MONTHS_15 when `databaseInsightsMode` is set to DatabaseInsightsMode.ADVANCED'); | |
throw new Error('`performanceInsightRetention` must be set to \'${PerformanceInsightRetention.MONTHS_15}\' when `databaseInsightsMode` is set to \'${DatabaseInsightsMode.ADVANCED}\''); |
Same as above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* | ||
* In advanced mode, Performance Insights must be enabled. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* | |
* In advanced mode, Performance Insights must be enabled. |
The current implementation is enabling insights automatically when DatabaseInsightsMode.ADVANCED
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @default - 7(PerformanceInsightRetention.DEFAULT) if `enablePerformanceInsights` is set, | ||
* 465(PerformanceInsightRetention.MONTHS_15) if DatabaseInsightsMode.ADVANCED is set for `databaseInsightsMode`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @default - 7(PerformanceInsightRetention.DEFAULT) if `enablePerformanceInsights` is set, | |
* 465(PerformanceInsightRetention.MONTHS_15) if DatabaseInsightsMode.ADVANCED is set for `databaseInsightsMode`. | |
* @default - 7 days if `enablePerformanceInsights` is set. 465 days (15 months) if `databaseInsightsMode` is set to DatabaseInsightsMode.ADVANCED. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw new Error('`enablePerformanceInsights` disabled, but `performanceInsightRetention` or `performanceInsightEncryptionKey` was set, or `databaseInsightsMode` was set to `DatabaseInsightsMode.ADVANCED`'); | ||
} | ||
if (props.databaseInsightsMode === DatabaseInsightsMode.ADVANCED | ||
&& props.performanceInsightRetention |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about this. Could automatically setting retention to 15 months cause unexpected billing to customers unaware of the longer period? If so, it may be better to enforce performanceInsightRetention
being set manually to PerformanceInsightRetention.MONTHS_15
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Certainly, we should avoid situations where there are unintended costs to the user.
28bab16
/** | ||
* The database insights mode. | ||
* | ||
* @default - DatabaseInsightsMode.STANDARD if Amazon Aurora engine is used, otherwise not set. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @default - DatabaseInsightsMode.STANDARD if Amazon Aurora engine is used, otherwise not set. | |
* @default - DatabaseInsightsMode.STANDARD when performance insights are enabled and Amazon Aurora engine is used, otherwise not set. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The standard mode of Database Insights is enabled by default for Aurora databases. | ||
|
||
You can enhance the monitoring of your Aurora databases by enabling the advanced mode of Database Insights. | ||
|
||
See [AWS docs](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Database-Insights.html) for more information about Database Insights. | ||
|
||
The following example shows enabling the advanced mode of Database Insights for a clustered database. | ||
|
||
```ts | ||
declare const vpc: ec2.Vpc; | ||
new rds.DatabaseCluster(this, 'Database', { | ||
engine: rds.DatabaseClusterEngine.AURORA, | ||
vpc: vpc, | ||
// If you enable the advanced mode of Database Insights, | ||
// Performance Insights is enabled and the retention period of Performance Insights data is set to 465(15 months). | ||
databaseInsightsMode: rds.DatabaseInsightsMode.ADVANCED, | ||
writer: rds.ClusterInstance.provisioned('Writer', { | ||
instanceType: ec2.InstanceType.of(ec2.InstanceClass.R7G, ec2.InstanceSize.LARGE), | ||
}), | ||
}); | ||
``` | ||
|
||
Note that settings regarding Database Insights are only possible at the cluster level. | ||
|
||
### Supported Engines | ||
|
||
Database Insights supports Amazon Aurora MySQL and Amazon Aurora PostgreSQL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The standard mode of Database Insights is enabled by default for Aurora databases. | |
You can enhance the monitoring of your Aurora databases by enabling the advanced mode of Database Insights. | |
See [AWS docs](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Database-Insights.html) for more information about Database Insights. | |
The following example shows enabling the advanced mode of Database Insights for a clustered database. | |
```ts | |
declare const vpc: ec2.Vpc; | |
new rds.DatabaseCluster(this, 'Database', { | |
engine: rds.DatabaseClusterEngine.AURORA, | |
vpc: vpc, | |
// If you enable the advanced mode of Database Insights, | |
// Performance Insights is enabled and the retention period of Performance Insights data is set to 465(15 months). | |
databaseInsightsMode: rds.DatabaseInsightsMode.ADVANCED, | |
writer: rds.ClusterInstance.provisioned('Writer', { | |
instanceType: ec2.InstanceType.of(ec2.InstanceClass.R7G, ec2.InstanceSize.LARGE), | |
}), | |
}); | |
``` | |
Note that settings regarding Database Insights are only possible at the cluster level. | |
### Supported Engines | |
Database Insights supports Amazon Aurora MySQL and Amazon Aurora PostgreSQL. | |
The standard mode of Database Insights is enabled by default for Aurora databases. | |
You can enhance the monitoring of your Aurora databases by enabling the advanced mode of Database Insights. | |
To control Database Insights mode, use the `databaseInsightsMode` property: | |
```ts | |
declare const vpc: ec2.Vpc; | |
new rds.DatabaseCluster(this, 'Database', { | |
engine: rds.DatabaseClusterEngine.AURORA, | |
vpc: vpc, | |
// If you enable the advanced mode of Database Insights, | |
// Performance Insights is enabled and the retention period of Performance Insights data is set to 465(15 months). | |
databaseInsightsMode: rds.DatabaseInsightsMode.ADVANCED, | |
writer: rds.ClusterInstance.provisioned('Writer', { | |
instanceType: ec2.InstanceType.of(ec2.InstanceClass.R7G, ec2.InstanceSize.LARGE), | |
}), | |
}); |
Note: Database Insights are only supported for Amazon Aurora MySQL and Amazon Aurora PostgreSQL clusters.
Visit CloudWatch Database Insights for more details.
Feel free to improve further 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lpizzinidev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
@sakurai-ryo can you fix the merge conflicts when available? I've approved this PR. |
@mergify update |
☑️ Nothing to do
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
This pull request has been removed from the queue for the following reason: The pull request can't be updated You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. If you want to requeue this pull request, you need to post a comment with the text: |
@Mergifyio requeue |
✅ The queue state of this pull request has been cleaned. It can be re-embarked automatically |
This pull request has been removed from the queue for the following reason: The pull request can't be updated You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. If you want to requeue this pull request, you need to post a comment with the text: |
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Comments on closed issues and PRs are hard for our team to see. |
Issue # (if applicable)
Closes #32680
Reason for this change
AWS announces Amazon CloudWatch Database Insights.
https://aws.amazon.com/about-aws/whats-new/2024/12/amazon-cloudwatch-database-insights
Description of changes
Database Insights has two modes: Standard and Advanced.
For Aurora databases, standard mode is enabled by default.
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-rds-dbcluster.html#aws-resource-rds-dbcluster-return-values
When using advanced mode, you must enable Performance Insights and set its data retention period to 465 days.
https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Database-Insights.html
Describe any new or updated permissions being added
Nothing.
Description of how you validated changes
Unit tests and integ-tests.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license