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

Added canary url and stepfunction monitoring with sns email and slack… #36

Closed
wants to merge 1 commit into from

Conversation

bshien
Copy link
Collaborator

@bshien bshien commented May 23, 2024

… integration

Description

Creates a Cloudwatch Synthetic Canary to monitor the metrics.opensearch.org url and monitors the step functions for failure. If either of these fail, a message will be published to SNS, and will send email and slack notifications.

Issues Resolved

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Copy link

codecov bot commented May 23, 2024

Codecov Report

Attention: Patch coverage is 83.33333% with 11 lines in your changes are missing coverage. Please review.

Project coverage is 74.04%. Comparing base (3e8f954) to head (9cb9873).

Files Patch % Lines
...ava/org/opensearchmetrics/dagger/CommonModule.java 0.00% 5 Missing ⚠️
...java/org/opensearchmetrics/lambda/SlackLambda.java 91.42% 2 Missing and 1 partial ⚠️
...org/opensearchmetrics/util/SecretsManagerUtil.java 85.71% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main      #36      +/-   ##
============================================
+ Coverage     73.40%   74.04%   +0.63%     
- Complexity      163      173      +10     
============================================
  Files            43       46       +3     
  Lines           959     1025      +66     
  Branches         47       49       +2     
============================================
+ Hits            704      759      +55     
- Misses          234      243       +9     
- Partials         21       23       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

… integration

Signed-off-by: Brandon Shien <bshien@amazon.com>
roleName: "OpenSearchSlackLambdaRole",
managedPolicies: [
ManagedPolicy.fromAwsManagedPolicyName('SecretsManagerReadWrite'),
]
Copy link
Member

Choose a reason for hiding this comment

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

Restrict this to specific secret.

}

export class SnsMonitors extends Construct {
private readonly region: string;
Copy link
Member

Choose a reason for hiding this comment

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

NIT: Try to see if you can seperate the stepFunctionSnsAlarms and canaryAlarms into new files and extend the common methods.

workflowComponent: openSearchMetricsWorkflowStack.workflowComponent,
lambdaPackage: Project.LAMBDA_PACKAGE
})
openSearchMetricsMonitoringStack.node.addDependency(openSearchMetricsWorkflowStack);
Copy link
Member

Choose a reason for hiding this comment

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

Test with removing the addDependency, CDK should infer this.

super(scope, id, props);

const secretsName = 'slack-creds';
const slackCredsSecrets = new secretsmanager.Secret(this, 'SlackApiCreds', {
Copy link
Member

Choose a reason for hiding this comment

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

Seperate the secrets into a new stack, so that the same secret can be used across the project, not only just for slack etc.

schedule: synthetics.Schedule.rate(Duration.minutes(1)),
test: synthetics.Test.custom({
code: synthetics.Code.fromAsset(path.join(__dirname, '../../canary')),
handler: 'index.handler',
Copy link
Member

Choose a reason for hiding this comment

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

Please try to re-name this which is appropriate to the requirement.

schedule: synthetics.Schedule.rate(Duration.minutes(1)),
test: synthetics.Test.custom({
code: synthetics.Code.fromAsset(path.join(__dirname, '../../canary')),
handler: 'index.handler',
Copy link
Member

Choose a reason for hiding this comment

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

Just explore if this lambda can be restricted within the VPC and can be invoked restrictively.

handler: 'index.handler',
}),
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_6_2,
environmentVariables: {
Copy link
Member

Choose a reason for hiding this comment

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

Use the LTS and secure runtime for the canary lambda.

}

@Test
void testGetRedshiftCredentials() throws IOException {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

change name

@prudhvigodithi
Copy link
Member

@bshien can we close this PR in favor of #40?
@getsaurabh02

@bshien bshien closed this Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants