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

Dashboards, metrics, and alarms #228

Merged
merged 4 commits into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions bin/app.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import * as cdk from 'aws-cdk-lib'
import { CfnOutput, SecretValue, Stack, StackProps, Stage, StageProps } from 'aws-cdk-lib'
import * as chatbot from 'aws-cdk-lib/aws-chatbot'
import { BuildEnvironmentVariableType, BuildSpec, ComputeType } from 'aws-cdk-lib/aws-codebuild'
import * as sm from 'aws-cdk-lib/aws-secretsmanager'

import { PipelineNotificationEvents } from 'aws-cdk-lib/aws-codepipeline'
import { CodeBuildStep, CodePipeline, CodePipelineSource } from 'aws-cdk-lib/pipelines'
import { Construct } from 'constructs'
import dotenv from 'dotenv'
Expand Down Expand Up @@ -62,6 +65,10 @@ export class APIPipeline extends Stack {
value: 'github-token-2',
type: BuildEnvironmentVariableType.SECRETS_MANAGER,
},
VERSION: {
value: '1',
type: BuildEnvironmentVariableType.PLAINTEXT,
},
},
},
commands: [
Expand Down Expand Up @@ -151,6 +158,16 @@ export class APIPipeline extends Stack {
this.addIntegTests(code, prodUsEast2Stage, prodUsEast2AppStage, STAGE.PROD)

pipeline.buildPipeline()

const slackChannel = chatbot.SlackChannelConfiguration.fromSlackChannelConfigurationArn(
this,
'SlackChannel',
'arn:aws:chatbot::644039819003:chat-configuration/slack-channel/eng-ops-protocols-slack-chatbot'
)

pipeline.pipeline.notifyOn('NotifySlack', slackChannel, {
events: [PipelineNotificationEvents.PIPELINE_EXECUTION_FAILED],
})
}

private addIntegTests(
Expand Down
15 changes: 15 additions & 0 deletions bin/stacks/api-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import * as aws_waf from 'aws-cdk-lib/aws-wafv2'
import { Construct } from 'constructs'
import { STAGE } from '../../lib/util/stage'
import { SERVICE_NAME } from '../constants'
import { DashboardStack } from './dashboard-stack'
import { LambdaStack } from './lambda-stack'

export class APIStack extends cdk.Stack {
Expand All @@ -32,10 +33,15 @@ export class APIStack extends cdk.Stack {

const {
getOrdersLambdaAlias,
getOrdersLambda,
getNonceLambdaAlias,
getNonceLambda,
postOrderLambdaAlias,
postOrderLambda,
getDocsLambdaAlias,
getDocsUILambdaAlias,
chainIdToStatusTrackingStateMachineArn,
checkStatusFunction,
} = new LambdaStack(this, `${SERVICE_NAME}LambdaStack`, {
provisionedConcurrency,
stage: stage as STAGE,
Expand Down Expand Up @@ -163,6 +169,15 @@ export class APIStack extends cdk.Stack {
orders.addMethod('GET', getOrdersLambdaIntegration, {})
nonce.addMethod('GET', getNonceLambdaIntegration, {})

new DashboardStack(this, `${SERVICE_NAME}-Dashboard`, {
apiName: api.restApiName,
postOrderLambdaName: postOrderLambda.functionName,
getNonceLambdaName: getNonceLambda.functionName,
getOrdersLambdaName: getOrdersLambda.functionName,
chainIdToStatusTrackingStateMachineArn,
orderStatusLambdaName: checkStatusFunction.functionName,
})

const apiAlarm5xx = new aws_cloudwatch.Alarm(this, `${SERVICE_NAME}-5XXAlarm`, {
metric: api.metricServerError({
period: Duration.minutes(5),
Expand Down
Loading