From 9b0f5e9669a0efa6bbacc70996c8f104336a99c7 Mon Sep 17 00:00:00 2001 From: Khai Do <3697686+zaro0508@users.noreply.github.com> Date: Wed, 10 Apr 2024 09:04:30 -0700 Subject: [PATCH] [IT-3471] Setup cloudwatch dashboard (#26) 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 | 124 ++++++++++++++++++ 5 files changed, 152 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..99cf87d --- /dev/null +++ b/templates/cw-dashboard.j2 @@ -0,0 +1,124 @@ +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 }}" + ] + ], + "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 }}" + ] + ], + "legend": { + "position": "bottom" + }, + "region": "us-east-1", + "liveData": false, + "title": "ApplicationRequests2xx: Average", + "view": "timeSeries", + "stacked": false + } + }, + { + "type": "metric", + "properties": { + "metrics": [ + [ + "AWS/ElasticBeanstalk", + "ApplicationRequests3xx", + "EnvironmentName", + "{{ sceptre_user_data.BeanstalkEnvironmentName }}" + ] + ], + "legend": { + "position": "bottom" + }, + "region": "us-east-1", + "liveData": false, + "title": "ApplicationRequests3xx: Average", + "view": "timeSeries", + "stacked": false + } + }, + { + "type": "metric", + "properties": { + "metrics": [ + [ + "AWS/ElasticBeanstalk", + "ApplicationRequests4xx", + "EnvironmentName", + "{{ sceptre_user_data.BeanstalkEnvironmentName }}" + ] + ], + "legend": { + "position": "bottom" + }, + "region": "us-east-1", + "liveData": false, + "title": "ApplicationRequests4xx: Average", + "view": "timeSeries", + "stacked": false + } + }, + { + "type": "metric", + "properties": { + "metrics": [ + [ + "AWS/ElasticBeanstalk", + "ApplicationRequests5xx", + "EnvironmentName", + "{{ sceptre_user_data.BeanstalkEnvironmentName }}" + ] + ], + "legend": { + "position": "bottom" + }, + "region": "us-east-1", + "liveData": false, + "title": "ApplicationRequests5xx: Average", + "view": "timeSeries", + "stacked": false + } + } + ] + } +Outputs: + Dashboard: + Value: !Ref Dashboard + Export: + Name: !Sub '${AWS::Region}-${AWS::StackName}-Dashboard'