Create a Dashboard

Create a dashboard using AWS Console

  1. In the AWS Management Console on the Services menu, click CloudWatch.
  2. In the left navigation menu, click on Dashboards.
  3. Click Create Dashboard.
  4. Name the dashboad observability-dashboard and click Create dashboard.

You will see a screen such as the one below where you can choose the type of widget you want.

AddWidget

  1. Select Line graph followed by Metrics, then click Configure.

This will take you a screen showing all Namespaces under which Metrics are being collected.

  1. Select ContainerInsights namespace.
  2. Select the ClusterName, Namespace, PodName dimension.

Namespace

  1. Select a metric with the Metric Name pod_cpu_utilization by checking the checkbox in the row of the metric.

AddWidget2

  1. Click the Create widgetbutton in the bottom right corner.

This will add the graph of the metric as a new widget to the dashboard.

You can adjust the size of the widget by dragging the bottom right of the corner.

  1. Click on Save dashboard to save the dashboard.

Learn about Service Quota limits on widgets and metric limits per widget/dashboard here.

You can also add CloudWatch Logs Insights results as a widget as well.

  1. Click on Add widget in the top right corner.
  2. Select Line graph followed by Logs.

This which will take you to CloudWatch Logs Insights screen.

SelectLG

  1. Select the /aws/containerinsights/PetSite/application log group from the drop down.
  2. Paste and run the query below in the query textbox, then click run Run query.
fields @timestamp, @message
| sort @timestamp desc
| filter @message like /PetListAdoptions/
| stats count(@message) by bin(5m)
| limit 20

Your screen should look similar to the one below.

The query shows the number of instances the string PetListAdoptions was found in the log data.

SelectLGResults

  1. Click Create widget.

This will add a new widget to the dashboard as shown below.

AddWidget3

Working on CloudWatch dashboards using AWS CLI

You can perform a variety of operations on CloudWatch Dashboards through AWS CLI as well.

Take a look at the available commands here.

  1. In the AWS Management Console, navigate to CloudShell.
  2. Execute the following command in the terminal:

This command gets the dashboard in json format back to you.

aws cloudwatch get-dashboard --dashboard-name observability-dashboard

Create a new dashboard

  1. Save the following json string below into a file on your local directory named dashboard.json.
  2. Replace <YOUR_AWS_REGION_HERE> in the file below with your currently selected region and save.
{"widgets":[{"type":"metric","x":0,"y":0,"width":12,"height":6,"properties":{"view":"timeSeries","stacked":false,"metrics":[["ContainerInsights","pod_cpu_utilization","PodName","petsite-deployment","ClusterName","petsite","Namespace","default"]],"region":"<YOUR_AWS_REGION_HERE>"}}]}
  1. Execute the following command in the terminal:

This will create a new CloudWatch Dashboard

aws cloudwatch put-dashboard --dashboard-name cli-dashboard --dashboard-body $(cat dashboard.json)
  1. Execute the following command in the terminal:

This will return a list of dashboards that exist on the account.

aws cloudwatch list-dashboards

You can also check your newly created dashboard on the CloudWatch Dashboard console as well.

This concludes the Dashboards module.