Step 7: (Optional) Install the Amazon IoT Greengrass log manager component on the device - Amazon Kinesis Video Streams
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Step 7: (Optional) Install the Amazon IoT Greengrass log manager component on the device

Note

Be aware of the CloudWatch quotas.

Follow these procedures to configure the Amazon Kinesis Video Streams Edge Agent logs to automatically upload to CloudWatch using the Amazon IoT Greengrass log manager component.

Install the Amazon IoT Greengrass log manager component
  1. Confirm that the Amazon IoT Greengrass device role has the appropriate permissions.

    1. Sign in to the Amazon Web Services Management Console and open the IAM console at https://console.amazonaws.cn/iam/.

    2. Click Roles in the left navigation.

    3. Choose the name of the TES role created in Step 2: Set up the Amazon IoT Greengrass V2 core device on the device. Use the search bar if necessary.

    4. Select the GreengrassV2TokenExchangeRoleAccess policy.

    5. Select the JSON tab and verify that the policy looks like the following:

      { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "logs:CreateLogGroup", "logs:CreateLogStream", "logs:PutLogEvents", "logs:DescribeLogStreams", "s3:GetBucketLocation" ], "Resource": "*" } ] }
    6. If the GreengrassV2TokenExchangeRoleAccess policy doesn't exist, or if some required permissions are missing, create a new IAM policy with these permissions and attach it to the TES role created in Step 2: Set up the Amazon IoT Greengrass V2 core device on the device.

  2. Sign in to the Amazon Web Services Management Console and open the Amazon IoT Core console at https://console.amazonaws.cn/iot/. Verify that the appropriate Region is selected.

  3. In the left navigation, choose Greengrass devices, Deployments.

    Choose the deployment with the same target as the thing you created in Step 2: Set up the Amazon IoT Greengrass V2 core device on the device.

  4. In the top right corner, select Actions, then choose Revise.

    In the pop-up that appears, choose Revise deployment.

  5. Complete the following sections:

    1. Step 1: Specify target. Choose Next.

    2. Step 2: Select components.

      1. Verify that the aws.greengrass.Cli component and aws.greengrass.SecretManager components are still selected.

        Important

        Don't uninstall these components.

      2. Toggle the Show only selected components switch and search for aws.greengrass.LogManager.

      3. Select the box next to aws.greengrass.LogManager, then choose Next.

    3. Step 3: Configure components. Configure the Amazon IoT Greengrass log manager component to upload the logs generated by the Amazon Kinesis Video Streams Edge Agent.

      Select the aws.greengrass.LogManager component, then choose Configure component.

      In the screen that appears, paste the following log manager configuration in the Configuration to merge box.

      { "logsUploaderConfiguration": { "componentLogsConfigurationMap": { "aws.kinesisvideo.KvsEdgeComponent/java_kvs.log": { "diskSpaceLimit": "100", "diskSpaceLimitUnit": "MB", "logFileDirectoryPath": "/greengrass/v2/work/aws.kinesisvideo.KvsEdgeComponent/log", "logFileRegex": "java_kvs.log\\w*" }, "aws.kinesisvideo.KvsEdgeComponent/cpp_kvs_edge.log": { "diskSpaceLimit": "100", "diskSpaceLimitUnit": "MB", "logFileDirectoryPath": "/greengrass/v2/work/aws.kinesisvideo.KvsEdgeComponent/log", "logFileRegex": "cpp_kvs_edge.log\\w*" }, "aws.kinesisvideo.KvsEdgeComponent/cpp_kvssink.log": { "diskSpaceLimit": "100", "diskSpaceLimitUnit": "MB", "logFileDirectoryPath": "/greengrass/v2/work/aws.kinesisvideo.KvsEdgeComponent/log", "logFileRegex": "cpp_kvssink.log\\w*" }, "aws.kinesisvideo.KvsEdgeComponent/cpp_kvs_streams.log": { "diskSpaceLimit": "100", "diskSpaceLimitUnit": "MB", "logFileDirectoryPath": "/greengrass/v2/work/aws.kinesisvideo.KvsEdgeComponent/log", "logFileRegex": "cpp_kvs_streams.log\\w*" } } }, "periodicUploadIntervalSec": "1" }
      Important

      The logFileDirectoryPath in the preceding configuration assumes that the default logging output location is used.

      Note

      For more information about each of the parameters for the log manager configuration, see the Log manager section of the Amazon IoT Greengrass Version 2 Developer Guide.

      Once you finish, select Confirm, then choose Next.

    4. Step 4: Configure advanced settings. Select Next.

    5. Step 5: Review. Select Deploy.

  6. Confirm that the Amazon log manager component and permissions were installed correctly.

  7. On the Ubuntu Amazon EC2 instance, type sudo /greengrass/v2/bin/greengrass-cli component details --name aws.greengrass.LogManager to verify the component received the updated configuration.

  8. Inspect the Amazon IoT Greengrass core logs.

    Type sudo less /greengrass/v2/logs/greengrass.log.

    Review for deployment errors.

    If there was an error, revise the deployment to remove the aws.greengrass.LogManager component.

    Type sudo service greengrass restart to restart the Amazon IoT Greengrass core service.

    If the deployment error was related to missing permissions, review Step 4: Add permissions to the token exchange service (TES) role to make sure that the TES role has proper permissions. Then, repeat this section.