

サポート終了通知: 2025 年 9 月 15 日、 AWS は Amazon Lex V1 のサポートを終了します。 V1 2025 年 9 月 15 日を過ぎると、Amazon Lex V1 コンソールまたは Amazon Lex V1 リソースにはアクセスできなくなります。Amazon Lex V2 を使用している場合は、代わりに [Amazon Lex V2 ガイド](https://docs.aws.amazon.com/lexv2/latest/dg/what-is.html)を参照してください。

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# Amazon CloudWatch Logs のテキストログの表示
<a name="conversation-logs-cw"></a>

Amazon Lex では、Amazon CloudWatch Logs で会話のテキストログが保存されます。ログを表示するには、CloudWatch Logs コンソールまたは API を使用します。詳細については、「*Amazon CloudWatch Logs ユーザーガイド*」の「[フィルターパターンを使用したログデータの検索](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/SearchDataFilterPattern.html)」と「[CloudWatch Logs インサイトクエリ構文](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CWL_QuerySyntax.html)」を参照してください。

**Amazon Lex コンソールを使用してログを表示するには**

1. Amazon Lex コンソール ([https://console.aws.amazon.com/lex](https://console.aws.amazon.com/lex)) を開きます。

1. リストからボットを選択します。

1. [**Settings**] (設定) タブを選択し、左側のメニューから [**Conversation logs**] (会話ログ) を選択します。

1. **[Text logs]** (テキストログ) の下のリンクを選択して、エイリアスのログを CloudWatch コンソールに表示します。

CloudWatch コンソールまたは API を使用してログエントリを表示することもできます。ログエントリを見つけるには、エイリアスに対して設定したロググループに移動します。Amazon Lex コンソールでログのログストリームプレフィックスを見つけるか、[GetBotAlias](API_GetBotAlias.md) オペレーションを使用します。

ユーザー発話のログエントリは、複数のログストリームにあります。会話内の発話には、指定されたプレフィックスを持つログストリームの 1 つにエントリがあります。ログストリームのエントリには、次の情報が含まれます。

```
{
   "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` の場合、`intent`、`slots`、および `slotToElicit` フィールドはエントリに表示されません。
+ オーディオログが無効になっている場合、または `inputDialogMode` フィールドが `Text` の場合、`s3PathForAudio` フィールドは表示されません。
+ `responseCard` フィールドは、ボットの応答カードを定義した場合にのみ表示されます。
+ `requestAttributes` マップは、リクエストでリクエスト属性を指定した場合にのみ表示されます。
+ この `kendraResponse` フィールドが存在するのは、`AMAZON.KendraSearchIntent` Amazon Kendra インデックスを検索するリクエストを作成したときのみです。
+ ボットの Lambda 関数で代替インテントが指定されている場合、この `developerOverride` フィールドは true です。
+ `sessionAttributes` マップは、リクエストでセッション属性を指定した場合にのみ表示されます。
+ `sentimentResponse` マップは、センチメント値を返すようにボットを設定した場合のみ表示されます。

**注記**  
入力形式は変わる場合があり、この変更は対応する `messageVersion` に反映されないことがあります。新しいフィールドが追加されても、コードでエラーがスローされないようにします。

Amazon Lex の CloudWatch Logs への書き込みを有効にするロールとポリシーが必要です。詳細については、「[会話ログの IAM ポリシー](conversation-logs-policies.md)」を参照してください。