

# ML Detect
<a name="dd-detect-ml"></a>

**注意**  
在下列區域目前未提供 ML Detect：  
亞太地區 (馬來西亞)

有了 Machine Learning Detect (ML Detect)，您可以建立安全性設定檔，其會使用機器學習，根據歷史裝置資料自動建立模型來了解預期的裝置行為，並將這些設定檔指派給裝置群組或您機群中的所有裝置。AWS IoT Device Defender 接著會使用 ML 模型來識別異常並觸發警示。

如需開始使用 ML Detect 的詳細資訊，請參閱 [ML Detect 指南](dd-detect-ml-getting-started.md)。

**Topics**
+ [

## ML Detect 的使用案例
](#dd-detect-ml-use-cases)
+ [

## ML Detect 的運作方式
](#dd-detect-ml-how-it-works)
+ [

## 最低需求
](#dd-detect-ml-requirements)
+ [

## 限制
](#dd-detect-ml-limitations)
+ [

## 在警示中標記誤判和其他驗證狀態
](#dd-detect-ml-mark-false-positives)
+ [

## 支援的指標
](#dd-detect-ml-metrics)
+ [

## Service Quotas
](#dd-detect-ml-quotas)
+ [

## ML Detect CLI 命令
](#dd-detect-ml-cli-commands)
+ [

## ML Detect API
](#dd-detect-ml-apis)
+ [

## 暫停或刪除 ML Detect 安全性設定檔
](#dd-detect-ml-disable-feature)

## ML Detect 的使用案例
<a name="dd-detect-ml-use-cases"></a>

您可以在難以設定裝置的預期行為時，使用 ML Detect 來監控您的機群裝置。例如，若要監控中斷連線指標的數目，可能不清楚什麼值會被視為可接受的閾值。在此情況下，您可以啟用 ML Detect，根據從裝置回報的歷史資料來識別異常的中斷連線指標資料點。

ML Detect 的另一個使用案例是監控隨著時間動態變化的裝置行為。ML Detect 會根據從裝置變更資料模式，定期學習動態預期的裝置行為。例如，裝置訊息傳送量可能會因工作日和週末而異，而 ML Detect 會學習這種動態行為。

## ML Detect 的運作方式
<a name="dd-detect-ml-how-it-works"></a>

使用 ML Detect，您可以建立行為，跨 [6 個雲端指標](#dd-detect-ml-metrics)和 [7 個裝置端指標](#dd-detect-ml-metrics)識別操作和安全性異常。在初始的模型訓練期間之後，ML Detect 會根據過去 14 天的資料，每天重新整理模型。它會使用 ML 模型監控這些指標的資料點，並在偵測到異常時觸發警示。

如果您將安全性設定檔連接至具有類似預期行為的裝置集合，ML Detect 最合用。例如，如果您的部分裝置用於客戶的家庭，而其他裝置用於商務辦公室，則兩個群組之間的裝置行為模式可能會有很大的差異。您可以將裝置組織成 *home-device* 物件群組和 *office-device* 物件群組。如需最佳異常偵測效果，請將每個物件群組連接到個別的 ML Detect 安全性設定檔。

當 ML Detect 建置初始模型時，其需要 14 天，且在過去 14 天期間，每個指標至少需要 25,000 個資料點才能產生模型。之後，它每天都會更新模型，其中有最低的指標資料點數量。如果不符合最低需求，ML Detect 會在第二天嘗試建置模型，並在接下來的 30 天內每天重試，然後中止模型進行評估。

## 最低需求
<a name="dd-detect-ml-requirements"></a>

對於訓練和建立初始 ML 模型，ML Detect 具有以下最低需求。

**最低訓練期間**  
建置初始模型需要 14 天。之後，模型每天都會以來自過去 14 天期間的指標資料重新整理。

**最低資料點總數**  
建置 ML 模型所需的最低資料點數量是過去 14 天每個指標 25,000 個資料點。若要持續訓練和重新整理模型，ML Detect 需要從受監控裝置符合最低資料點數量。它大致相當於以下設定：  
+ 45 分鐘間隔 60 部裝置連線並在 AWS IoT 進行活動。
+ 30 分鐘間隔 40 部裝置。
+ 10 分鐘間隔 15 部裝置。
+ 5 分鐘間隔 7 部裝置。

**裝置群組目標**  
若要收集資料，您必須在安全性設定檔的目標物件群組中具有物件。

在建立初始模型之後，ML 模型每天都會重新整理，並且需要過去 14 天期間至少 25,000 個資料點。

## 限制
<a name="dd-detect-ml-limitations"></a>

您可以將 ML Detect 搭配下列雲端指標的維度一起使用：
+ [授權失敗 (aws:num-authorization-failures)](detect-cloud-side-metrics.md#detect-auth-failures)
+ [已接收的訊息 (aws:num-messages-received)](detect-cloud-side-metrics.md#detect-messages-received)
+ [已傳送的訊息 (aws:num-messages-sent)](detect-cloud-side-metrics.md#detect-messages-sent)
+ [訊息大小 (aws:message-byte-size)](detect-cloud-side-metrics.md#detect-message-size)

ML Detect 不支援下列指標。

**ML Detect 不支援雲端指標：**
+ [來源 IP (aws:source-ip-address)](detect-cloud-side-metrics.md#detect-ip-address)

**ML Detect 不支援裝置端指標：**
+ [目的地 IP (`aws:destination-ip-addresses`)](detect-device-side-metrics.md#detect-destination-ip-addresses)
+ [偵聽 TCP 連接埠 (`aws:listening-tcp-ports`)](detect-device-side-metrics.md#detect-listening-tcp-ports)
+ [偵聽 UDP 連接埠 (`aws:listening-udp-ports`)](detect-device-side-metrics.md#detect-listening-udp-ports)

自訂指標僅支援 **number** 類型。

## 在警示中標記誤判和其他驗證狀態
<a name="dd-detect-ml-mark-false-positives"></a>

 如果透過調查確認 ML Detect 警示為誤報，您可以將警示的驗證狀態設定為「誤報」。這可以幫助您和團隊識別不需要回應的警示。您也可以將警示標記為「相符」、「良性肯定」或「不明」。

您可以透過 [AWS IoT Device Defender 主控台](https://docs.aws.amazon.com//iot/latest/developerguide/detect-HowToHowTo.html)或使用 [PutVerificationStateOnViolation](https://docs.aws.amazon.com/iot/latest/apireference/API_PutVerificationStateOnViolation.html) API 動作來標記警示。

## 支援的指標
<a name="dd-detect-ml-metrics"></a>

您可以搭配使用下列雲端指標與 ML Detect：
+ [授權失敗 (aws:num-authorization-failures)](detect-cloud-side-metrics.md#detect-auth-failures)
+ [連線嘗試次數 (aws:num-connection-attempts)](detect-cloud-side-metrics.md#detect-num-connection-attempts)
+ [中斷連線 (aws:num-disconnects)](detect-cloud-side-metrics.md#detect-num-disconnects)
+ [訊息大小 (aws:message-byte-size)](detect-cloud-side-metrics.md#detect-message-size)
+ [已傳送的訊息 (aws:num-messages-sent)](detect-cloud-side-metrics.md#detect-messages-sent)
+ [已接收的訊息 (aws:num-messages-received)](detect-cloud-side-metrics.md#detect-messages-received)

您可以搭配使用下列裝置端指標與 ML Detect：
+ [位元組輸出 (`aws:all-bytes-out`)](detect-device-side-metrics.md#detect-all-bytes-out)
+ [位元組輸入 (`aws:all-bytes-in`)](detect-device-side-metrics.md#detect-all-bytes-in)
+ [接聽 TCP 連接埠計數 (`aws:num-listening-tcp-ports`)](detect-device-side-metrics.md#detect-num-listening-tcp-ports)
+ [接聽 UDP 連接埠計數 (`aws:num-listening-udp-ports`)](detect-device-side-metrics.md#detect-num-listening-udp-ports)
+ [封包輸出 (`aws:all-packets-out`)](detect-device-side-metrics.md#detect-all-packets-out)
+ [封包輸入 (`aws:all-packets-in`)](detect-device-side-metrics.md#detect-all-packets-in)
+ [已建立的 TCP 連線計數 (`aws:num-established-tcp-connections`)](detect-device-side-metrics.md#detect-num-established-tcp-connections)

## Service Quotas
<a name="dd-detect-ml-quotas"></a>

如需 ML Detect 服務配額和限制的相關資訊，請參閱 [AWS IoT Device Defender 端點和配額](https://docs.aws.amazon.com/general/latest/gr/iot_device_defender.html)。

## ML Detect CLI 命令
<a name="dd-detect-ml-cli-commands"></a>

您可以使用以下 CLI 命令來建立和管理 ML Detect。
+ [create-security-profile](https://docs.aws.amazon.com/cli/latest/reference/iot/create-security-profile.html)
+ [attach-security-profile](https://docs.aws.amazon.com/cli/latest/reference/iot/attach-security-profile.html)
+ [list-security-profiles](https://docs.aws.amazon.com/cli/latest/reference/iot/list-security-profiles.html)
+ [describe-security-profile](https://docs.aws.amazon.com/cli/latest/reference/iot/describe-security-profile.html)
+ [update-security-profile](https://docs.aws.amazon.com/cli/latest/reference/iot/update-security-profile.html)
+ [delete-security-profile](https://docs.aws.amazon.com/cli/latest/reference/iot/delete-security-profile.html)
+ [get-behavior-model-training-summaries](https://docs.aws.amazon.com/cli/latest/reference/iot/get-behavior-model-training-summaries.html)
+ [list-active-violations](https://docs.aws.amazon.com/cli/latest/reference/iot/list-active-violations.html)
+ [list-violation-events](https://docs.aws.amazon.com/cli/latest/reference/iot/list-violation-events.html)

## ML Detect API
<a name="dd-detect-ml-apis"></a>

下列 API 可以用來建立和管理 ML Detect 安全性設定檔。
+ [CreateSecurityProfile](https://docs.aws.amazon.com/iot/latest/apireference/API_CreateSecurityProfile.html)
+ [AttachSecurityProfile](https://docs.aws.amazon.com/iot/latest/apireference/API_AttachSecurityProfile.html)
+ [ListSecurityProfiles](https://docs.aws.amazon.com/iot/latest/apireference/API_ListSecurityProfiles.html)
+ [DescribeSecurityProfile](https://docs.aws.amazon.com/iot/latest/apireference/API_DescribeSecurityProfile.html)
+ [UpdateSecurityProfile](https://docs.aws.amazon.com/iot/latest/apireference/API_UpdateSecurityProfile.html)
+ [DeleteSecurityProfile](https://docs.aws.amazon.com/iot/latest/apireference/API_DeleteSecurityProfile.html)
+ [GetBehaviorModelTrainingSummaries](https://docs.aws.amazon.com/iot/latest/apireference/API_GetBehaviorModelTrainingSummaries.html)
+ [ListActiveViolations](https://docs.aws.amazon.com/iot/latest/apireference/API_ListActiveViolations.html)
+ [ListViolationEvents](https://docs.aws.amazon.com/iot/latest/apireference/API_ListViolationEvents.html)
+ [PutVerificationStateOnViolation](https://docs.aws.amazon.com/iot/latest/apireference/API_PutVerificationStateOnViolation.html)

## 暫停或刪除 ML Detect 安全性設定檔
<a name="dd-detect-ml-disable-feature"></a>

您可以暫停 ML Detect 安全性設定檔，以暫時停止監控裝置行為，或刪除您的 ML Detect 安全性設定檔，以停止長時間監控裝置行為。

**使用主控台暫停 ML Detect 安全性設定檔**  
若要使用主控台暫停 ML Detect 安全性設定檔，您必須首先具有空的物件群組。若要建立空白物件群組，請參閱《*AWS IoT Core 開發人員指南*》中的[靜態實物群組](https://docs.aws.amazon.com/iot/latest/developerguide/thing-groups.html)。如果您已建立空的物件群組，則將空的物件群組設定為 ML Detect 安全性設定檔的目標。  
 您需要在 30 天內將安全性設定檔的目標設回裝置群組，否則將無法重新啟用安全性設定檔。

**使用主控台刪除 ML Detect 安全性設定檔**  

若要刪除安全性設定檔，請遵循下列步驟：

1.  在 AWS IoT 主控台中，導覽至側邊欄，然後選擇 **Defend** (防禦)。

1. 在 **Defend** (防禦) 下，選擇 **Detect **(偵測)，然後選擇 **Security Profiles** (安全性設定檔)。

1. 選擇您要刪除的 ML Detect 安全性設定檔。

1. 選擇 **Actions** (動作)，然後從選項中選擇 **Delete** (刪除)。
在刪除 ML Detect 安全性設定檔之後，您將無法重新啟用安全性設定檔。

**使用 CLI 暫停 ML Detect 安全性設定檔**  
若要使用 CLI 暫停 ML Detect 安全性設定檔，請使用 `detach-security-security-profile` 命令：  

```
$aws iot detach-security-profile --security-profile-name SecurityProfileName --security-profile-target-arn arn:aws:iot:us-east-1:123456789012:all/registered-things
```
此選項僅能在 AWS CLI 中使用。類似於主控台工作流程，您需要在 30 天內將安全性設定檔的目標設回裝置群組，否則將無法重新啟用安全性設定檔。若要將安全性設定檔連接至裝置群組，請使用 [https://docs.aws.amazon.com/cli/latest/reference/iot/attach-security-profile.html](https://docs.aws.amazon.com/cli/latest/reference/iot/attach-security-profile.html) 命令。

**使用 CLI 刪除 ML Detect 安全性設定檔**  
您可以使用以下 `delete-security-profile` 命令，刪除安全性設定檔：  

```
delete-security-profile --security-profile-name SecurityProfileName
```
在刪除 ML Detect 安全性設定檔之後，您將無法重新啟用安全性設定檔。