Architecture overview - CloudWatch Monitoring on AWS

Architecture overview

This solution is a reference architecture that automates the setup of Amazon CloudWatch dashboards to monitor key performance metrics and logs from your web servers. This solution deploys a preconfigured dashboard for Apache, NGINX, and Puma workloads.

This solution uses tagging mechanisms to add or remove instances from the monitoring dashboard. When you deploy the solution, you provide the tag (key, value pair) as a parameter to identify your instances. An AWS Lambda function runs on cron schedule to search for instances with the provided tag. The Lambda function maintains the list of instances in an AWS Systems Manager Parameter Store. Whenever the instance list on Systems Manager Parameter Store gets updated, it invokes an Amazon CloudWatch Events rule. This rule uses Lambda to update the deployed dashboard with metrics and logs for the new instance list.

Note

Before you add designated tags to your desired workload instance, ensure that you configure your instances correctly. It is important to refer to the CloudWatch agent and web server config files when configuring your instances. Failing to do so will result in missing metrics and logs from dashboard. For more information, refer to Configuring your Apache EC2 instance, Configuring your NGINX EC2 instance, or Configuring your Puma EC2 instance.

As illustrated in Figure 1, the deployed solution provides demo web server instances and Amazon CloudWatch dashboards to monitor your workload. As of October 2021, this solution only supports Apache, NGINX, and Puma. However, you can customize this solution to work with other workloads. For more information on how to extend this solution to other workloads, refer to the README.md file in the GitHub repository.

Figure 1: Deployment diagram

Figure 1: Deployment diagram

Deploying this solution with the default parameters builds the following environment in the AWS Cloud. The architecture can be broken down into two workflows: User Interaction and Dashboard Management.

Amazon CloudWatch Monitoring Framework architecture

Figure 2: CloudWatch Monitoring on AWS architecture

User Interaction Workflow:

The AWS CloudFormation template deploys the Amazon CloudWatch Events rule, AWS Lambda function and AWS Systems Manager Parameter Store necessary to capture the workload instances in your account.

  1. Users update the tag on their instances with the tagging schema provided as input during the stack deployment.

  2. The CloudWatch Events rule invokes the tagHandler Lambda function on cron schedule. The Lambda function primarily performs two tasks:

    • It uses the ec2 describe-tags API call to get instances with the desired tag value (same as step 1).

    • It compares the fetched instance list with the SSM Parameter Store instance list and updates the parameter as needed.

Dashboard Management Workflow:

The AWS CloudFormation template deploys the Amazon CloudWatch Events rule and AWS Lambda function necessary to configure workload specific Amazon CloudWatch dashboard in your account.

  1. When the Systems Manager Parameter Store gets updated, the event is captured using CloudWatch Events rule to invoke the dashboardHandler Lambda function.

  2. The dashboardHandler Lambda function updates the deployed dashboard widgets with logs and metrics for the updated instance list.

Note

AWS CloudFormation resources are created from AWS Cloud Development Kit (CDK) constructs.