Create tag-based Amazon CloudWatch dashboards automatically
Created by Janak Vadaria (AWS), RAJNEESH TYAGI (AWS), and Vinodkumar Mandalapu (AWS)
Code repository: Goldensignals | Environment: Production | Technologies: Management & governance |
AWS services: AWS CDK; Amazon CloudWatch; AWS CodeBuild; AWS CodePipeline |
Summary
Creating different Amazon CloudWatch dashboards manually can be time-consuming, particularly when you have to create and update multiple resources to automatically scale your environment. A solution that creates and updates your CloudWatch dashboards automatically can save you time. This pattern helps you deploy a fully automated AWS Cloud Development Kit (AWS CDK) pipeline that creates and updates CloudWatch dashboards for your AWS resources based on tag change events, to display Golden Signals metrics.
In site reliability engineering (SRE), Golden Signals refers to a comprehensive set of metrics that offer a broad view of a service from a user or consumer perspective. These metrics consist of latency, traffic, errors, and saturation. For more information, see What is Site Reliability Engineering (SRE)?
The solution provided by this pattern is event-driven. After it's deployed, it continuously monitors the tag change events and automatically updates the CloudWatch dashboards and alarms.
Prerequisites and limitations
Prerequisites
An active AWS account
AWS Command Line Interface (AWS CLI), installed and configured
Prerequisites for the AWS CDK v2
A bootstrapped environment on AWS
AWS SDK for Python (Boto3)
, installed Node.js version 18
or later Node package manager (npm), installed and configured
for the AWS CDK Moderate (level 200) familiarity with the AWS CDK and AWS CodePipeline
Limitations
This solution currently creates automated dashboards for the following AWS services only:
Architecture
Target technology stack
Target architecture
An AWS tag change event for the configured application tags or code changes initiates a pipeline in AWS CodePipeline to build and deploy updated CloudWatch dashboards.
AWS CodeBuild runs a Python script to find the resources that have configured tags and stores the resource IDs in a local file in a CodeBuild environment.
CodeBuild runs cdk synth to generate AWS CloudFormation templates that deploy CloudWatch dashboards and alarms.
CodePipeline deploys the AWS CloudFormation templates to the specified AWS account and Region.
When the AWS CloudFormation stack has been deployed successfully, you can view the CloudWatch dashboards and alarms.
Automation and scale
This solution has been automated by using the AWS CDK. You can find the code in the GitHub Golden Signals Dashboards on Amazon CloudWatch
Tools
Amazon services
Amazon EventBridge
is a serverless event bus service that helps you connect your applications with real-time data from a variety of sources, including AWS Lambda functions, HTTP invocation endpoints using API destinations, or event buses in other AWS accounts. AWS CodePipeline
helps you quickly model and configure the different stages of a software release and automate the steps required to release software changes continuously. AWS CodeBuild
is a fully managed build service that helps you compile source code, run unit tests, and produce artifacts that are ready to deploy. AWS Command Line Interface (AWS CLI) is an open source tool that helps you interact with AWS services through commands in your command-line shell.
AWS Identity and Access Management (IAM)
helps you securely manage access to your AWS resources by controlling who is authenticated and authorized to use them. Amazon Simple Storage Service (Amazon S3)
is a cloud-based object storage service that helps you store, protect, and retrieve any amount of data.
Best practices
As a security best practice, you can use encryption and authentication for the source repositories that connect to your pipelines. For additional best practices, see CodePipeline best practices and use cases in the CodePipeline documentation.
Epics
Task | Description | Skills required |
---|---|---|
Configure and deploy the sample application. |
| AWS DevOps |
Automatically create dashboards and alarms. | After you deploy the sample application, you can create any of the resources that this solution supports with expected tag values, which will automatically create the specified dashboards and alarms. To test this solution, create an AWS Lambda function:
| AWS DevOps |
Task | Description | Skills required |
---|---|---|
Remove the |
| AWS DevOps |
Troubleshooting
Issue | Solution |
---|---|
Python command not found (referring to | Check the version of your Python installation. If you have installed Python version 3, replace |
Related resources
Bootstrapping (AWS CDK documentation)
Using named profiles (AWS CLI documentation)
Additional information
The following illustration shows a sample dashboard for Amazon RDS that is created as part of this solution.