在 Amazon 日志中查看文本 CloudWatch 日志 - Amazon Lex V1

终止支持通知:2025年9月15日, AWS 我们将停止对Amazon Lex V1的支持。2025 年 9 月 15 日之后,您将无法再访问亚马逊 Lex V1 主机或 Amazon Lex V1 资源。如果您使用的是 Amazon Lex V2,请改为参阅 Amazon Lex V2 指南

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

在 Amazon 日志中查看文本 CloudWatch 日志

Amazon Lex 将您的对话文本日志存储在亚马逊 CloudWatch 日志中。要查看日志,您可以使用 CloudWatch 日志控制台或 API。有关更多信息,请参阅 Amazon Logs 用户指南中的使用筛选模式搜索CloudWatch 日志数据和 CloudWatch 日志见解查询语法

使用 Amazon Lex 控制台查看日志
  1. 打开 Amazon Lex 控制台 https://console.aws.amazon.com/lex

  2. 从列表中,选择一个机器人。

  3. 选择 Settings (设置) 选项卡,然后从左侧菜单中选择 Conversation logs (对话日志)

  4. 选择 “文本日志” 下的链接,在 CloudWatch 控制台中查看别名的日志。

您也可以使用 CloudWatch 控制台或 API 来查看日志条目。要查找日志条目,请导航到为该别名配置的日志组。您可以在 Amazon Lex 控制台中或使用 GetBotAlias 操作查找日志的日志流前缀。

用户话语的日志条目位于多个日志流中。对话中的一个话语在一个日志流中具有一个带指定前缀的条目。日志流中的条目包含以下信息。

{ "messageVersion": "1.0", "botName": "bot name", "botAlias": "bot alias", "botVersion": "bot version", "inputTranscript": "text used to process the request", "botResponse": "response from the bot", "intent": "matched intent", "nluIntentConfidence": "number", "slots": { "slot name": "slot value", "slot name": null, "slot name": "slot value" ... }, "alternativeIntents": [ { "name": "intent name", "nluIntentConfidence": "number", "slots": { "slot name": slot value, "slot name": null, "slot name": slot value ... } }, { "name": "intent name", "nluIntentConfidence": number, "slots": {} } ], "developerOverride": "true" | "false", "missedUtterance": true | false, "inputDialogMode": "Text" | "Speech", "requestId": "request ID", "s3PathForAudio": "S3 path to audio file", "userId": "user ID", "sessionId": "session ID", "sentimentResponse": { "sentimentScore": "{Positive: number, Negative: number, Neutral: number, Mixed: number}", "sentimentLabel": "Positive" | "Negative" | "Neutral" | "Mixed" }, "slotToElicit": "slot name", "dialogState": "ElicitIntent" | "ConfirmIntent" | "ElicitSlot" | "Fulfilled" | "ReadyForFulfillment" | "Failed", "responseCard": { "genericAttachments": [ ... ], "contentType": "application/vnd.amazonaws.card.generic", "version": 1 }, "locale": "locale", "timestamp": "ISO 8601 UTC timestamp", "kendraResponse": { "totalNumberOfResults": number, "resultItems": [ { "id": "query ID", "type": "DOCUMENT" | "QUESTION_ANSWER" | "ANSWER", "additionalAttributes": [ { ... } ], "documentId": "document ID", "documentTitle": { "text": "title", "highlights": null }, "documentExcerpt": { "text": "text", "highlights": [ { "beginOffset": number, "endOffset": number, "topAnswer": true | false } ] }, "documentURI": "URI", "documentAttributes": [] } ], "facetResults": [], "sdkResponseMetadata": { "requestId": "request ID" }, "sdkHttpMetadata": { "httpHeaders": { "Content-Length": "number", "Content-Type": "application/x-amz-json-1.1", "Date": "date and time", "x-amzn-RequestId": "request ID" }, "httpStatusCode": 200 }, "queryId": "query ID" }, "sessionAttributes": { "attribute name": "attribute value" ... }, "requestAttributes": { "attribute name": "attribute value" ... } }

日志条目的内容取决于事务的结果以及自动程序和请求的配置。

  • 如果 missedUtterance 字段为 true,则 intentslotsslotToElicit 字段不会显示在条目中。

  • 如果音频日志已禁用或者 inputDialogMode 字段为 Text,则不显示 s3PathForAudio 字段。

  • 仅当您为自动程序定义了响应卡时,才会显示 responseCard 字段。

  • 仅当您在请求中指定了请求属性时,才会显示 requestAttributes 映射。

  • 只有在 AMAZON.KendraSearchIntent 请求搜索 Amazon Kendra 索引时,kendraResponse 字段才会出现。

  • 当在机器人的 Lambda 函数中指定了替代意图时,developerOverride 字段的值为 True。

  • 仅当在请求中指定了会话属性时,才会显示 sessionAttributes 映射。

  • 仅当将自动程序配置为返回情绪值时,才会显示 sentimentResponse 映射。

注意

输入格式可以更改,但不必对 messageVersion 做出相应更改。您的代码不应在有新字段时引发错误。

您必须设置角色和策略才能允许 Amazon Lex 写入 CloudWatch 日志。有关更多信息,请参阅用于对话日志的 IAM 策略