Skip to content
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): enhanced monitoring configuration at the cluster level #32157

Merged
merged 15 commits into from
Nov 22, 2024

Conversation

badmintoncryer
Copy link
Contributor

@badmintoncryer badmintoncryer commented Nov 16, 2024

Issue # (if applicable)

None

Reason for this change

AWS RDS now supports the configuration of advanced monitoring at the cluster level.

https://aws.amazon.com/about-aws/whats-new/2024/09/amazon-rds-performance-insights-supports-aurora-cluster-level-configuration/?nc1=h_ls

This feature is essential for creating limitless database cluster. (#32151)

Description of changes

I added enableClusterLevelEnhancedMonitoring prop to ClusterProps.
If this prop enabled, monitoringInterval and monitoringRole is applied to not the instances but the cluster.

Enhanced monitoring configuration for the cluster and instances has some restrictions.

  • When setting the monitoringRoleArn for both the cluster and instances, the values must be identical.
  • When setting the monitoringInterval for both the cluster and instances, the values must be identical.
  • When the monitoringInterval or monitoringRoleArn is set at the cluster level, enhanced monitoring will be enabled even if the same values are not specified for the instances.

Based on the above, I decided to add a flag (enableClusterLevelEnhancedMonitoring) to switch the application of monitoringInterval and monitoringRole between the instance level and the cluster level to avoid breaking changes to the existing props.

Verification Results Memo

The value of the Enhanced Monitoring configuration must be the same for both the cluster level and the instance level.

  "DatabaseB269D8BB": {
   "Type": "AWS::RDS::DBCluster",
   "Properties": {
    ...,
    "Engine": "aurora-postgresql",
    "EngineVersion": "16.1",
    "MonitoringInterval": 5,
    "MonitoringRoleArn": {
     "Fn::GetAtt": [
      "DatabaseMonitoringRoleForCluster91F5067E",
      "Arn"
     ]
    },
  },
  "DatabasewriterInstanceEBFCC003": {
   "Type": "AWS::RDS::DBInstance",
   "Properties": {
    ...,
    "DBClusterIdentifier": {
     "Ref": "DatabaseB269D8BB"
    },
    "Engine": "aurora-postgresql",
    "MonitoringInterval": 1,
    "MonitoringRoleArn": {
     "Fn::GetAtt": [
      "DatabaseMonitoringRole576991DA",
      "Arn"
     ]
    },
  }
           | Database/writerInstance (DatabasewriterInstanceEBFCC003) Resource handler returned message: "MonitoringInterval conflicts with cluster level parameter. (Service: Rds, Status Code: 400, Request ID: 7c9d9023-fe2a-4b39-a939-22cec3595041)" (RequestToken: bc3e18eb-2daa-4f25-c205-11f1ec70fc15, HandlerErrorCode: InvalidRequest)

The monitoring role arn must be the same for both cluster and instance level.

 "DatabaseB269D8BB": {
   "Type": "AWS::RDS::DBCluster",
   "Properties": {
    ...,
    "Engine": "aurora-postgresql",
    "EngineVersion": "16.1",
    "MonitoringInterval": 5,
    "MonitoringRoleArn": {
     "Fn::GetAtt": [
      "DatabaseMonitoringRoleForCluster91F5067E",
      "Arn"
     ]
    },
  },
  "DatabasewriterInstanceEBFCC003": {
   "Type": "AWS::RDS::DBInstance",
   "Properties": {
    ...,
    "DBClusterIdentifier": {
     "Ref": "DatabaseB269D8BB"
    },
    "Engine": "aurora-postgresql",
    "MonitoringInterval": 5,
    "MonitoringRoleArn": {
     "Fn::GetAtt": [
      "DatabaseMonitoringRole576991DA",
      "Arn"
     ]
    },
  }
Resource handler returned message: "MonitoringRoleArn conflicts with cluster level parameter. (Service: Rds, Status Code: 400, Request ID: 761a867d-409e-4208-a08e-5591607d0ed0)" (RequestToken: fb691324-f37c-405d-e5bd-447911f7664f, HandlerErrorCode: InvalidRequest)

Description of how you validated changes

Add both unit 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

@aws-cdk-automation aws-cdk-automation requested a review from a team November 16, 2024 06:30
@github-actions github-actions bot added p2 distinguished-contributor [Pilot] contributed 50+ PRs to the CDK labels Nov 16, 2024
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

Copy link

codecov bot commented Nov 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.17%. Comparing base (b3e39a9) to head (23078ed).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #32157   +/-   ##
=======================================
  Coverage   77.17%   77.17%           
=======================================
  Files         105      105           
  Lines        7169     7169           
  Branches     1315     1315           
=======================================
  Hits         5533     5533           
  Misses       1455     1455           
  Partials      181      181           
Flag Coverage Δ
suite.unit 77.17% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
packages/aws-cdk 77.17% <ø> (ø)
---- 🚨 Try these New Features:

@aws-cdk-automation aws-cdk-automation dismissed their stale review November 16, 2024 12:59

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@badmintoncryer badmintoncryer marked this pull request as ready for review November 16, 2024 13:58
@badmintoncryer badmintoncryer changed the title feat(rds): enhanced monitoring configuration for cluster level feat(rds): enhanced monitoring configuration for the cluster level Nov 16, 2024
@badmintoncryer badmintoncryer changed the title feat(rds): enhanced monitoring configuration for the cluster level feat(rds): enhanced monitoring configuration at the cluster level Nov 16, 2024
@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Nov 18, 2024
Copy link
Contributor

@GavinZZ GavinZZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some feedback, thanks for the contribution!

Comment on lines +1388 to +1393
new rds.DatabaseCluster(this, 'Cluster', {
engine: rds.DatabaseClusterEngine.auroraPostgres({ version: rds.AuroraPostgresEngineVersion.VER_16_1 }),
writer: rds.ClusterInstance.serverlessV2('writerInstance'),
vpc,
monitoringInterval: Duration.seconds(5),
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't see enableClusterLevelEnhancedMonitoring property set in this codeblock?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code block is an example of configuring enhanced monitoring at the instance level.

// Enable Enhanced Monitoring at instance level to all instances in the cluster
new rds.DatabaseCluster(this, 'Cluster', {
  engine: rds.DatabaseClusterEngine.auroraPostgres({ version: rds.AuroraPostgresEngineVersion.VER_16_1 }),
  writer: rds.ClusterInstance.serverlessV2('writerInstance'),
  vpc,
  monitoringInterval: Duration.seconds(5),
});

// Enable Enhanced Monitoring at the cluster level
new rds.DatabaseCluster(this, 'Cluster', {
  engine: rds.DatabaseClusterEngine.auroraPostgres({ version: rds.AuroraPostgresEngineVersion.VER_16_1 }),
  writer: rds.ClusterInstance.serverlessV2('writerInstance'),
  vpc,
  monitoringInterval: Duration.seconds(5),
  enableClusterLevelEnhancedMonitoring: true,
});

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see! The text above got me confused If you want to enable enhanced monitoring at the cluster level and I didn't notice the comment you. Looks good.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem! Thank you for your confirmation!

Comment on lines +861 to +862
monitoringInterval: props.enableClusterLevelEnhancedMonitoring ? undefined : props.monitoringInterval,
monitoringRole: props.enableClusterLevelEnhancedMonitoring ? undefined : this.monitoringRole,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to have a comment to explain that when enableClusterLevelEnhancedMonitoring is enabled, we already set interval and role at cluster level so no need to re-set it in instance level.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added such explanations to all the sections where instance-level enhanced monitoring settings are applied.

Comment on lines 1 to 15
{
"Resources": {
"Vpc8378EB38": {
"Type": "AWS::EC2::VPC",
"Properties": {
"CidrBlock": "10.0.0.0/16",
"EnableDnsHostnames": true,
"EnableDnsSupport": true,
"InstanceTenancy": "default",
"Tags": [
{
"Key": "Name",
"Value": "EnhancedMonitoringClusterTestStack/Vpc"
}
]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this integ.temp.js test? I don't see any integration testss attach to it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry.. I've removed it.

packages/aws-cdk-lib/aws-rds/README.md Outdated Show resolved Hide resolved
packages/aws-cdk-lib/aws-rds/README.md Outdated Show resolved Hide resolved
@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Nov 21, 2024
@mergify mergify bot dismissed GavinZZ’s stale review November 22, 2024 02:22

Pull request has been modified.

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Nov 22, 2024
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 23078ed
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

mergify bot commented Nov 22, 2024

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).

@mergify mergify bot merged commit 01f2dcd into aws:main Nov 22, 2024
20 checks passed
Copy link

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 22, 2024
@badmintoncryer badmintoncryer deleted the enhanced-monitoring branch November 22, 2024 03:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
distinguished-contributor [Pilot] contributed 50+ PRs to the CDK p2 pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants