Skip to content

Commit

Permalink
Dashboards, metrics, and alarms (#228)
Browse files Browse the repository at this point in the history
* Dashboards, metrics, alarms

* Fix lint

* Fix tests

* Coverage
  • Loading branch information
willpote authored Jul 3, 2023
1 parent bbe8ef7 commit e9ddfb6
Show file tree
Hide file tree
Showing 22 changed files with 2,162 additions and 1,149 deletions.
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

0 comments on commit e9ddfb6

Please sign in to comment.