-
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
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #32851 +/- ##
=======================================
Coverage 81.38% 81.38%
=======================================
Files 222 222
Lines 13695 13695
Branches 2412 2412
=======================================
Hits 11145 11145
Misses 2271 2271
Partials 279 279
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.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
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.
&& 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.
* | ||
* 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
* @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. |
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
.
/** | ||
* 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. |
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 👍
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