From 292469c1a72f0bf5ff5ad29b1f7edabc0ae7c560 Mon Sep 17 00:00:00 2001 From: Khai Do Date: Fri, 5 Apr 2024 13:26:04 -0700 Subject: [PATCH] [IT-3471] Setup cloudwatch dashboard Setup a cloudwatch dashboard containing metrics from Elastic beanstalk enhanced health checks. depends on #25 --- .pre-commit-config.yaml | 2 +- config/agoradev/develop/agora-dashboard.yaml | 9 +++ config/agoraprod/prod/agora-dashboard.yaml | 9 +++ config/agoraprod/staging/agora-dashboard.yaml | 9 +++ templates/cw-dashboard.j2 | 71 +++++++++++++++++++ 5 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 config/agoradev/develop/agora-dashboard.yaml create mode 100644 config/agoraprod/prod/agora-dashboard.yaml create mode 100644 config/agoraprod/staging/agora-dashboard.yaml create mode 100644 templates/cw-dashboard.j2 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8c30c99..9ddce70 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,4 +26,4 @@ repos: rev: v1.1.0 hooks: - id: j2lint -# args: [--ignore, S3, V1, --] + args: [--ignore, V1, --] diff --git a/config/agoradev/develop/agora-dashboard.yaml b/config/agoradev/develop/agora-dashboard.yaml new file mode 100644 index 0000000..0d61cc3 --- /dev/null +++ b/config/agoradev/develop/agora-dashboard.yaml @@ -0,0 +1,9 @@ +template: + path: cw-dashboard.j2 +stack_name: agora-develop-dashboard +stack_tags: + Environment: "develop" +dependencies: + - agoradev/develop/agora.yaml +sceptre_user_data: + BeanstalkEnvironmentName: "agora-develop" diff --git a/config/agoraprod/prod/agora-dashboard.yaml b/config/agoraprod/prod/agora-dashboard.yaml new file mode 100644 index 0000000..a90b3cf --- /dev/null +++ b/config/agoraprod/prod/agora-dashboard.yaml @@ -0,0 +1,9 @@ +template: + path: cw-dashboard.j2 +stack_name: agora-staging-dashboard +stack_tags: + Environment: "prod" +dependencies: + - agoraprod/prod/agora.yaml +sceptre_user_data: + BeanstalkEnvironmentName: "agora-prod" diff --git a/config/agoraprod/staging/agora-dashboard.yaml b/config/agoraprod/staging/agora-dashboard.yaml new file mode 100644 index 0000000..f13996e --- /dev/null +++ b/config/agoraprod/staging/agora-dashboard.yaml @@ -0,0 +1,9 @@ +template: + path: cw-dashboard.j2 +stack_name: agora-staging-dashboard +stack_tags: + Environment: "staging" +dependencies: + - agoraprod/staging/agora.yaml +sceptre_user_data: + BeanstalkEnvironmentName: "agora-staging" diff --git a/templates/cw-dashboard.j2 b/templates/cw-dashboard.j2 new file mode 100644 index 0000000..fc50ca9 --- /dev/null +++ b/templates/cw-dashboard.j2 @@ -0,0 +1,71 @@ +AWSTemplateFormatVersion: 2010-09-09 +Description: Cloudwatch Dashboards +Resources: + Dashboard: + Type: AWS::CloudWatch::Dashboard + Properties: + DashboardName: {{ sceptre_user_data.BeanstalkEnvironmentName }} + DashboardBody: > + { + "widgets": [ + { + "type": "metric", + "width": 20, + "height": 6, + "properties": { + "metrics": [ + [ + "AWS/ElasticBeanstalk", + "EnvironmentHealth", + "EnvironmentName", + "{{ sceptre_user_data.BeanstalkEnvironmentName }}", + { + "period": 300, + "stat": "Average", + "region": "us-east-1" + } + ] + ], + "legend": { + "position": "bottom" + }, + "region": "us-east-1", + "liveData": false, + "title": "EnvironmentHealth: Average", + "view": "timeSeries", + "stacked": false + } + }, + { + "type": "metric", + "properties": { + "metrics": [ + [ + "AWS/ElasticBeanstalk", + "ApplicationRequests2xx", + "EnvironmentName", + "{{ sceptre_user_data.BeanstalkEnvironmentName }}", + { + "period": 300, + "stat": "Average", + "region": "us-east-1" + } + ] + ], + "legend": { + "position": "bottom" + }, + "region": "us-east-1", + "liveData": false, + "title": "ApplicationRequests2xx: Average", + "view": "timeSeries", + "stacked": false + } + } + ] + } +Outputs: + Dashboard: + Value: !Ref Dashboard + Export: + Name: !Sub '${AWS::Region}-${AWS::StackName}-Dashboard'