Query metrics/logs from CloudWatch

Configure CloudWatch data source

Select AWS services from the AWS logo on the left navigation bar, which will take you to the screen as shown below showing all the AWS data sources available for you to choose from.

AWS Datasources

Select CloudWatch from the list, select the AWS Region where the PetAdoptions application is deployed and click on Add data source to add CloudWatch as a data source.

CloudWatch data source

Now click on Go to settings and select the Dashboards tab. The CloudWatch data source plugin comes with a handful of dashboards build-in.

Import built-in dashboard

Click on Import on the dashboards as shown below.

Add CW dashboard

Go to the dashboards and check the metrics and logs being visualized.

Lambda Dashboard Lambda dashboard

EBS Dashboard EBS dashboard

Query Metrics

Create a new Dashboard by clicking on the + sign and clicking on Create. Now click Add new panel, select CloudWatch data source, leave Query Mode to CloudWatch Metrics and select the appropriate values as shown in the screenshot below. This will visualize the metrics from CloudWatch Metrics.

Metrics panel

Query Logs

Create a new panel by clicking on Add panel button at the top, select CloudWatch data source and change the Query Mode to CloudWatch Logs and select any log group from the list.

Copy and paste the following CloudWatch Logs Insights query into the query field and press Shift + Enter to execute the query

fields @timestamp, @message
| sort @timestamp desc
| limit 20

You will see the result as shown below. You can click on any of the result row items to take you to CloudWatch Logs Insights on the AWS console.

Logs panel