Why can't I view conversation logs for Amazon Lex in CloudWatch?

3 minute read
0

I can’t view the conversation logs for Amazon Lex in Amazon CloudWatch.

Short description

There are several reasons why you might not see your Amazon Lex conversation logs in CloudWatch. For example, you don't have the right permissions configured to allow Amazon Lex use CloudWatch logs. Or, you turned on COPPA on your bot, and therefore you can't use the conversation logs feature.

Resolution

Add an IAM role and policy to Amazon Lex

Check if you granted the correct permissions to allow your Amazon Lex bot to log to CloudWatch. To log conversation logs, Amazon Lex needs to use CloudWatch logs. Then, to store those logs, it needs access to Amazon Simple Storage Service (Amazon S3) buckets. Follow these steps to add the required AWS Identity and Access Management (IAM) roles and policies:

  1. Sign in to the Amazon Lex console, and choose the bot that you want to edit.

  2. Choose Settings, and then choose Conversation logs.

  3. Choose the settings icon, and then choose IAM role.

  4. Add an IAM role with trust relationship similar to the following example:

    {  "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Allow",
          "Principal": {
            "Service": "lex.amazonaws.com"   //For V2 "Service": "lexv2.amazonaws.com"
          },
          "Action": "sts:AssumeRole"
        }
      ]
    }
  5. Attach an IAM policy to the role that allows logging of conversation text to CloudWatch logs:

    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Allow",
          "Action": [
            "logs:CreateLogStream",
            "logs:PutLogEvents"
          ],
          "Resource": "arn:aws:logs:region:account-id:log-group:log-group-name:*"
        }
      ]
    }
  6. Add an IAM policy to the role that allows audio logging to an S3 bucket:

    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Allow",
          "Action": [
            "s3:PutObject"
          ],
          "Resource": "arn:aws:s3:::bucket-name/*"
        }
      ]
    }

Review your COPPA settings

Check if COPPA is activated for your bot. If you activated COPPA, then you can't use the conversation logs feature for that bot.

Amazon Lex V1

To check this setting, check the general settings of your bot in the Amazon Lex console:

  1. Sign in to the Amazon Lex console, and then choose Return to the V1 console.
  2. Choose the bot that you want to edit.
  3. Choose Settings, and then choose General.
  4. Choose COPPA.

Amazon Lex V2

  1. Sign in to the Amazon Lex V2 console, and choose bot versions.
  2. Choose the version that you want to use, and then choose COPPA.
  3. If you activated COPPA for a version that you want to use, then you can't deactivate it. Instead, go to Draft versions, and choose COPPA. You can now change COPPA to no. Then, publish a new version.

Further troubleshooting steps

  1. Check that your log group is in the same AWS Region as your Amazon Lex bot.
  2. Check that your bot alias and the alias that you specified for logging are the same. Conversation logs are configured according to bot alias, so it's important that they match.
  3. If you use Amazon Lex V1, then don't use the $LATEST alias or a test bot that Amazon Lex provides for testing. You can't log conversations for either of these.
    Note: Conversation logs work on Amazon Lex V2 with the alias TSTALIASID.

Related information

IAM policies for conversation logs

Monitoring with conversation logs

AWS OFFICIAL
AWS OFFICIALUpdated 9 months ago
2 Comments

is statement "Check that you haven't enabled AI services opt out policies in your AWS organization. If you enable opt-out policies, then Amazon Lex doesn't log conversation logs." true ? isn't conversation logs stored in customers log groups and S3 and isn't related to the opt-out policy ?

Vindy
replied 9 months ago

Thank you for your comment. We'll review and update the Knowledge Center article as needed.

profile pictureAWS
MODERATOR
replied 9 months ago