

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 在 Lex V2 中監控操作指標
<a name="monitoring-operational-metrics"></a>

Amazon CloudWatch 和 AWS CloudTrail 是與 Amazon Lex V2 整合的兩個 AWS 服務，可協助您監控使用者與機器人的互動。使用這些服務來記錄動作、傳送近乎即時的資料，以及在符合條件時設定通知和自動化動作。

**Topics**
+ [使用 Amazon CloudWatch 測量操作指標](monitoring-cloudwatch.md)
+ [使用 AWS CloudTrail for Lex V2 檢視事件](logging-using-cloudtrail.md)

# 使用 Amazon CloudWatch 測量操作指標
<a name="monitoring-cloudwatch"></a>

您可以使用 CloudWatch 監控 Amazon Lex V2，這會收集原始資料並將其處理為可讀且幾近即時的指標。這些統計資料會保留 15 個月，以便您存取歷史資訊，並更清楚 Web 應用程式或服務的執行效能。您也可以設定留意特定閾值的警示，當滿足這些閾值時傳送通知或採取動作。如需詳細資訊，請參閱 [Amazon CloudWatch 使用者指南](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/)。

Amazon Lex V2 服務會在 `AWS/Lex` 命名空間中報告下列指標。


| 指標 | Description | 
| --- | --- | 
|  `AssistedSlotResolutionModelAccessDeniedErrorCount`  |  Amazon Lex V2 拒絕存取 Amazon Bedrock 的次數 `RecognizeUtterance` 和 `StartConversation`操作的有效維度： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/monitoring-cloudwatch.html) 的有效維度`RecognizeText`： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/monitoring-cloudwatch.html) 單位：計數  | 
|  `AssistedSlotResolutionModelInvocationCount`  |  叫用 Amazon Bedrock 的次數。 `RecognizeUtterance` 和 `StartConversation`操作的有效維度： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/monitoring-cloudwatch.html) 的有效維度`RecognizeText`： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/monitoring-cloudwatch.html) 單位：計數  | 
|  `AssistedSlotResolutionModelSystemErrorCount`  |  呼叫 Amazon Bedrock 時 5xx 發生的次數。 `RecognizeUtterance` 和 `StartConversation`操作的有效維度： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/monitoring-cloudwatch.html) 的有效維度`RecognizeText`： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/monitoring-cloudwatch.html) 單位：計數  | 
|  `AssistedSlotResolutionModelThrottlingErrorCount`  |  Amazon Bedrock 調節 Amazon Lex 的次數。 `RecognizeUtterance` 和 `StartConversation`操作的有效維度： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/monitoring-cloudwatch.html) 的有效維度`RecognizeText`： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/monitoring-cloudwatch.html) 單位：計數  | 
|  `AssistedSlotResolutionResolvedSlotCount`  |  Amazon Bedrock 傳回槽值的次數。 `RecognizeUtterance` 和 `StartConversation`操作的有效維度： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/monitoring-cloudwatch.html) 的有效維度`RecognizeText`： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/monitoring-cloudwatch.html) 單位：計數  | 
|  `KendraIndexAccessError`  |  Amazon Lex V2 無法存取 Amazon Kendra 索引的次數。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/monitoring-cloudwatch.html) 單位：計數  | 
|  `KendraLatency`  |  Amazon Kendra 回應來自 的請求所需的時間`AMAZON.KendraSearchIntent`。 有效維度： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/monitoring-cloudwatch.html) 單位：毫秒  | 
|  `KendraSuccess`  |  Amazon Lex V2 無法存取 Amazon Kendra 索引的次數。 有效維度： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/monitoring-cloudwatch.html) 單位：計數  | 
|  `KendraSystemErrors`  |  Amazon Lex V2 無法查詢 Amazon Kendra 索引的次數。 有效維度： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/monitoring-cloudwatch.html) 單位：計數  | 
|  `KendraThrottledEvents`  |  Amazon Kendra 調節來自 請求的次數`AMAZON.KendraSearchIntent`。 有效維度： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/monitoring-cloudwatch.html) 單位：計數  | 
|  `RuntimeConcurrency`  |  指定期間內並行連線的數量。 `RuntimeConcurrency` 會以 的形式報告`StatisticSet`。 `RecognizeUtterance` 或 `StartConversation`操作的有效維度： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/monitoring-cloudwatch.html) 其他操作的有效維度： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/monitoring-cloudwatch.html) 單位：計數  | 
|  `RuntimeInvalidLambdaResponses`  |  指定期間內無效的 AWS Lambda 回應數目。 有效維度： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/monitoring-cloudwatch.html) 單位：計數  | 
|  `RuntimeLambdaErrors`  |  指定期間內的 Lambda 執行時間錯誤數目。 有效維度： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/monitoring-cloudwatch.html) 單位：計數  | 
|  `RuntimePollyErrors`  |  指定期間內無效的 Amazon Polly 回應數目。 有效維度： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/monitoring-cloudwatch.html) 單位：計數  | 
|  `RuntimeRequestCount`  |  指定期間內的執行時間請求數目。 `RecognizeUtterance` 和 `StartConversation`操作的有效維度： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/monitoring-cloudwatch.html) 其他操作的有效維度： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/monitoring-cloudwatch.html) 單位：計數  | 
| `RuntimeRequestLength` | 與 Amazon Lex V2 機器人對話的總長度。僅適用於 [StartConversation](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_runtime_StartConversation.html) 操作。 有效維度： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/monitoring-cloudwatch.html) 單位：毫秒 | 
|  `RuntimeSucessfulRequestLatency`  此指標是 `RuntimeSucessfulRequestLatency`，而不是 `RuntimeSuccessfulRequestLatency`。   |  提出請求與傳回回應之間的成功請求延遲。 `RecognizeUtterance` 和 `StartConversation`操作的有效維度： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/monitoring-cloudwatch.html) 其他操作的有效維度： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/monitoring-cloudwatch.html) 單位：毫秒  | 
|  `RuntimeSystemErrors`  |  指定期間內的系統錯誤數量。系統錯誤的回應碼範圍是 500 到 599。 `RecognizeUtterance` 和 `StartConversation`操作的有效維度： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/monitoring-cloudwatch.html) 其他操作的有效維度： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/monitoring-cloudwatch.html) 單位：計數  | 
|  `RuntimeThrottledEvents`  |  限流事件的數量。當 Amazon Lex V2 收到超過您帳戶每秒交易限制的請求時，會調節事件。如果經常超過為您的帳戶所設的限制，您可以請求提高上限。若要請求提高，請參閱 [AWS 服務限制](https://docs.aws.amazon.com/general/latest/gr/aws_service_limits.html)。 `RecognizeUtterance` 和 `StartConversation`操作的有效維度： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/monitoring-cloudwatch.html) 其他操作的有效維度： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/monitoring-cloudwatch.html) 單位：計數  | 
|  `RuntimeUserErrors`  |  指定期間內的使用者錯誤數量。使用者錯誤的回應碼範圍是 400 到 499。 `RecognizeUtterance` 和 `StartConversation`操作的有效維度： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/monitoring-cloudwatch.html) 其他操作的有效維度： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/lexv2/latest/dg/monitoring-cloudwatch.html) 單位：計數  | 

Amazon Lex V2 指標支援下列維度。


|  維度  |  Description  | 
| --- | --- | 
|  Operation  |  產生項目的 Amazon Lex V2 操作名稱 – `RecognizeText`、`RecognizeUtterance``StartConversation`、`GetSession`、`PutSession`、`DeleteSession`、。  | 
|  BotId  |  機器人的英數字元唯一識別符。  | 
|  BotAliasId  |  機器人別名的英數字元唯一識別符。  | 
|  BotVersion  |  機器人的數值版本。  | 
|  InputMode  |  機器人的輸入類型 – 語音、文字或 DTMF。  | 
|  LocaleId  |  機器人地區設定的識別符，例如 en-US 或 fr-CA。  | 
|  Model  |  指出 Amazon Bedrock 大型語言模型的模型 ID。  | 
|  ModelType  |  指出從 Amazon Bedrock 調用的大型語言模型類型。  | 

# 使用 AWS CloudTrail for Lex V2 檢視事件
<a name="logging-using-cloudtrail"></a>

Amazon Lex V2 已與 服務整合 AWS CloudTrail，此服務提供 Amazon Lex V2 中使用者、角色或 AWS 服務所採取動作的記錄。CloudTrail 會將 Amazon Lex V2 的 API 呼叫擷取為事件。擷取的呼叫包括來自 Amazon Lex V2 主控台的呼叫，以及對 Amazon Lex V2 API 操作的程式碼呼叫。如果您建立線索，則可以將 CloudTrail 事件持續交付至 Amazon S3 儲存貯體，包括 Amazon Lex V2 的事件。即使您未設定追蹤，依然可以透過 CloudTrail 主控台中的**事件歷史記錄**檢視最新事件。您可以使用 CloudTrail 所收集的資訊，判斷對 Amazon Lex V2 提出的請求、提出請求的 IP 地址、提出請求的人員、提出請求的時間，以及其他詳細資訊。

若要進一步了解 CloudTrail，請參閱[「AWS CloudTrail 使用者指南」](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-user-guide.html)。

## CloudTrail 中的 Amazon Lex V2 資訊
<a name="lex-info-in-cloudtrail"></a>

當您建立帳戶時，系統會在您的 AWS 帳戶中啟用 CloudTrail。當 Amazon Lex V2 中發生活動時，該活動會與**事件歷史記錄**中的其他 AWS 服務事件一起記錄在 CloudTrail 事件中。您可以檢視、搜尋和下載 AWS 帳戶中的最新事件。如需詳細資訊，請參閱[「使用 CloudTrail 事件歷史記錄檢視事件」](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/view-cloudtrail-events.html)。

若要持續記錄 AWS 帳戶中的事件，包括 Amazon Lex V2 的事件，請建立追蹤。*線索*能讓 CloudTrail 將日誌檔案交付至 Amazon S3 儲存貯體。根據預設，當您在主控台建立追蹤記錄時，追蹤記錄會套用到所有 AWS 區域。該追蹤會記錄來自 AWS 分割區中所有區域的事件，並將日誌檔案交付到您指定的 Amazon S3 儲存貯體。此外，您可以設定其他 AWS 服務，以進一步分析和處理 CloudTrail 日誌中所收集的事件資料。如需詳細資訊，請參閱下列內容：
+ [建立追蹤的概觀](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-create-and-update-a-trail.html)
+ [CloudTrail 支援的服務和整合](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-aws-service-specific-topics.html)
+ [設定 CloudTrail 的 Amazon SNS 通知](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/configure-sns-notifications-for-cloudtrail.html)
+ [接收多個區域的 CloudTrail 日誌檔案](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/receive-cloudtrail-log-files-from-multiple-regions.html)和[接收多個帳戶的 CloudTrail 日誌檔案](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-receive-logs-from-multiple-accounts.html)

Amazon Lex V2 支援記錄[模型建置 API V2](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_Operations_Amazon_Lex_Model_Building_V2.html) 中列出的所有動作。

每一筆事件或日誌專案都會包含產生請求者的資訊。身分資訊可協助您判斷下列事項：
+ 請求是使用根還是 AWS Identity and Access Management IAM 使用者登入資料提出。
+ 提出該要求時，是否使用了特定角色或聯合身分使用者的暫時安全登入資料。
+ 該請求是否由另一項 AWS 服務提出。

如需詳細資訊，請參閱 [CloudTrail userIdentity 元素](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-event-reference-user-identity.html)。

## 了解 Amazon Lex V2 日誌檔案項目
<a name="understanding-service-name-entries"></a>

追蹤是一種組態，能讓事件以日誌檔案的形式交付到您指定的 Amazon S3 儲存貯體。CloudTrail 日誌檔案包含一或多個日誌專案。一個事件為任何來源提出的單一請求，並包含請求動作、請求的日期和時間、請求參數等資訊。CloudTrail 日誌檔並非依公有 API 呼叫的堆疊追蹤排序，因此不會以任何特定順序出現。

下列範例顯示示範 [CreateBotAlias](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_CreateBotAlias.html) 動作的 CloudTrail 日誌項目。

```
{
    "eventVersion": "1.05",
    "userIdentity": {
        "type": "AssumedRole",
        "principalId": "ID of caller:temporary credentials",
        "arn": "arn:aws:sts::111122223333:assumed-role/role name/role ARN",
        "accountId": "111122223333",
        "accessKeyId": "AKIAIOSFODNN7EXAMPLE",
        "sessionContext": {
            "sessionIssuer": {
                "type": "Role",
                "principalId": "ID of caller",
                "arn": "arn:aws:iam::111122223333:role/role name",
                "accountId": "111122223333",
                "userName": "role name"
            },
            "webIdFederationData": {},
            "attributes": {
                "mfaAuthenticated": "false",
                "creationDate": "creation date"
            }
        }
    },
    "eventTime": "event timestamp",
    "eventSource": "lex.amazonaws.com",
    "eventName": "CreateBotAlias",
    "awsRegion": "Region",
    "sourceIPAddress": "192.0.2.0",
    "userAgent": "user agent",
    "requestParameters": {
        "botAliasLocaleSettingsMap": {
            "en_US": {
                "enabled": true
            }
        },
        "botId": "bot ID",
        "botAliasName": "bot aliase name",
        "botVersion": "1"
    },
    "responseElements": {
        "botAliasLocaleSettingsMap": {
            "en_US": {
                "enabled": true
            }
        },
        "botAliasId": "bot alias ID",
        "botAliasName": "bot alias name",
        "botId": "bot ID",
        "botVersion": "1",
        "creationDateTime": creation timestamp
    },
    "requestID": "unique request ID",
    "eventID": "unique event ID",
    "readOnly": false,
    "eventType": "AwsApiCall",
    "recipientAccountId": "111122223333"
}
```