Monitoring gateway logs - AWS IoT SiteWise

Monitoring gateway logs

You can configure your gateway to log information to Amazon CloudWatch Logs or the local file system.

Using Amazon CloudWatch Logs

You can configure your gateway to send logs to CloudWatch Logs. You might follow this procedure if you want to use the AWS Management Console to view your gateway's log files.

To configure and access CloudWatch Logs

  1. To configure CloudWatch Logs for your gateway, see Configure logging in the AWS IoT Greengrass Version 1 Developer Guide.

  2. Navigate to the CloudWatch console.

  3. In the navigation pane, choose Log groups.

  4. You can find the AWS IoT SiteWise connector logs in the following log groups:

    • /aws/greengrass/Lambda/region/aws/swCollector – The logs for the gateway's Lambda function that collects data from the gateway's OPC-UA sources.

    • /aws/greengrass/Lambda/region/aws/swPublisher – The logs for the gateway's Lambda function that publishes OPC-UA data streams to AWS IoT SiteWise.

    Choose the log group for the function to debug.

  5. Choose a log stream that has a name that ends with the name of your AWS IoT Greengrass group. By default, CloudWatch displays the most recent log stream first.

    
              CloudWatch Logs "Log groups" page screenshot.
  6. To show logs from the last 5 minutes, do the following:

    1. Choose custom in the upper-right corner.

    2. Choose Relative.

    3. Choose 5 minutes.

    4. Choose Apply.

    
              CloudWatch "Logs" page screenshot.
  7. (Optional) To see fewer logs, you can choose 1m from the upper-right corner.

  8. Scroll to the bottom of the log entries to show the most recent logs.

Using local file system logs

You can configure your gateway to store logs locally. You might follow this procedure if you want to use the command line or local software to view your gateway's log files.

To configure and access local file system logs

  1. To configure local file system logs on your gateway, see Configure logging in the AWS IoT Greengrass Version 1 Developer Guide.

    Note

    You must have root permissions to read AWS IoT Greengrass logs on the file system.

  2. On your gateway, run the following command to list all AWS IoT SiteWise connector log files and their file details. Replace greengrass-root with the root of your AWS IoT Greengrass installation, and replace region with the Region of the gateway. The default greengrass-root is /greengrass.

    sudo ls -l /greengrass-root/ggc/var/log/user/region/aws

    You can find the most recent AWS IoT SiteWise connector logs in the following files:

    • swCollector.log – The most recent logs for the Lambda function that collects data from the gateway's OPC-UA sources.

    • swPublisher.log – The most recent logs for the Lambda function that publishes OPC-UA data streams to AWS IoT SiteWise.

    You can view earlier logs in the files named swCollector.log-timestamp and swPublisher.log-timestamp.

  3. Run the following command to view the publisher log file contents, for example.

    sudo tail -f /greengrass-root/ggc/var/log/user/region/aws/swPublisher.log

    The tail command shows the end of a file, and the -f option shows new lines as they're appended to the file.