Query metrics/logs from CloudWatch

Configure CloudWatch data source

  1. Select AWS services from the AWS logo on the left navigation menu.

This will take you to a screen that shows all the AWS data sources available for you to choose from as pictured below.

AWS Datasources

  1. Select CloudWatch from the Service dropdown.
  2. Select the AWS Region where the PetAdoptions application is deployed to.

CloudWatch data source

  1. Click Go to settings to the right of the data source name, then select the Dashboards tab.

The CloudWatch data source plugin comes with a handful of dashboards build-in.

Import built-in dashboard

  1. Click on Import for the dashboards as shown below.

Add CW dashboard

  1. Visit the dashboards you imported in the previous step and take a look at the metrics and logs being visualized.

Lambda Dashboard Lambda dashboard

EBS Dashboard EBS dashboard

Query Metrics

  1. Create a new Dashboard by clicking on the + sign and clicking on Create.
  2. Click Add new panel, select CloudWatch as the data source, leave Query Mode set to CloudWatch Metrics, and select the appropriate values as shown in the screenshot below.

This will display the metrics from CloudWatch Metrics.

Metrics panel

Query Logs

  1. Create a new panel by clicking on Add panel button at the top, select CloudWatch as the data source, and change the Query Mode to CloudWatch Logs.

  2. Select any log group from the list.

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

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

You will see the result similar to the one shown below. Clicking on any of the resulting rows will take you to CloudWatch Logs Insights on the AWS console.

Logs panel

This concludes this section. You may continue on to the next section.