These docs are for v7.1.0. Click to read the latest docs for v7.6.0.

How to add an AWS CloudWatch Dashboard

AWS IoT provides a service, named CloudWatch, that can collect and show in the form of logs, graphs, and events the MQTT traffic generated by the devices connected to the IoT service. It provides to the user the full picture of all the events sent to and from AWS IoT Core service. More information on CloudWatch can be found here.

In order to view logs in AWS CloudWatch, you must first enable logs for AWS IoT Core, as they are disabled by default. To enable AWS IoT Core logging, you must create an IAM role to enable logging in AWS IoT Core to monitor in AWS CloudWatch.

  1. Sign in to the Amazon AWS Console here, if not already logged in.
  2. Navigate to the AWS IAM console.
  3. Click on Roles.
  4. Under AWS service, choose IoT -> Next: Permissions.
  5. Choose at least the AWSIoTLogging policy to attach. Use default if already shown.
  6. Select Next: Tags -> Next: Review -> provide meaningful name to your Role name, e.g. aws-iot-access-role -> Create role.
  7. Navigate to AWS IoT console.
  8. Get started (if no resources are provisioned yet).
  9. Select Settings and Logs -> Edit to enable logging.
  10. Change "Level of verbosity" to "Debug (most verbose)" and "Set role" to your created IAM role aws-iot-access-role.
  11. Click Update and now logging is enabled.
  12. Select CloudWatch from the Services tab under the main toolbar. You should see this window:
1667

You can view all data sent and received by AWS IoT Core in the form of logs by selecting CloudWatch Logs under Services on the main page. From that page, you can choose to monitor all incoming and outgoing logs seen by AWS IoT Core. Next to Incoming Log Events Sum, click on the ... icon then select View logs -> AWS/Logs - AWSIotLogsV2, as shown below:

1433

You may also create a dashboard on the CloudWatch console to view MQTT traffic in multiple ways.

Dashboard Creation

  1. Click Add a dashboard from the CloudWatch left panel. Provide a name for your dashboard, e.g. MyAwsIotLogging.
  2. You can now add multiple widgets to your dashboard in the form of line metrics, bar graphs, free text, or chart insight.

For demonstration purposes, we will create a "Line" widget, a "Stacked area" widget, and a "Query results" widget for our dashboard.

  1. Start by adding a Line widget to show metrics over a timeline. Select Line and Configure.
  2. Choose the "IoT" metrics -> "Protocol Metrics" and filter on all MQTT events.
  3. Create widget.
  4. Add a "Stacked area" widget by clicking Add widget from your dashboard. Then select Stacked area -> Configure. Follow the same procedure to filter on all MQTT traffic.
  5. Add a chart visualization by adding a "Query results" widget to your dashboard. Configure the "Query results" chart by selecting AWSIotLogsV2 from the "Select log group(s)" drop-down. Create widget.

You can also edit the time range and filter on specific logs shown, calculate stats, or sort the logs in ascending or descending order. Refresh your dashboard to see all current events.

2442