

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

# 管理 EC2 執行個體的詳細監控
<a name="manage-detailed-monitoring"></a>

Amazon CloudWatch 提供兩種類別的監控：*基本監控*和*詳細監控*。依預設，設定執行個體以進行基本監控。您可以選擇啟用詳細監控，以協助您更快地識別和處理操作問題。執行個體啟動時，或在執行個體運作或停止後，您都可以啟用或關閉執行個體的詳細監控。

在執行個體上啟用詳細監控並不會影響其連接 EBS 磁碟區的監控。如需詳細資訊，請參閱 [Amazon EBS 的 Amazon CloudWatch 指標](https://docs.aws.amazon.com/ebs/latest/userguide/using_cloudwatch_ebs.html)。

下表重點說明您執行個體的基本監控和詳細監控之間的差異。


| 監控類型 | 描述 | 費用 | 
| --- | --- | --- | 
| 基本監控 |  狀態檢查指標在 1 分鐘內可用。所有其他指標均在 5 分鐘內可用。  | 免費。 | 
| 詳細監控 | 如果啟用了執行個體的詳細監控，即可在 1 分鐘內取得指標。 啟用詳細監控後，可彙總類似執行個體群組中的資料。 | 我們會按 Amazon EC2 傳送至 CloudWatch 的指標計費。您不需為資料儲存付費。如需詳細資訊，請參閱 [Amazon CloudWatch 定價頁面](https://aws.amazon.com/cloudwatch/pricing/#Paid_tier)中的付費方案。 | 

**Topics**
+ [必要許可](#iam-detailed-monitoring)
+ [在啟動時啟用詳細監控](#enable-detailed-monitoring)
+ [管理詳細監控](#disable-detailed-monitoring)

## 必要許可
<a name="iam-detailed-monitoring"></a>

若要啟用執行個體的詳細監控，您的使用者必須具有使用 [https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_MonitorInstances.html](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_MonitorInstances.html) API 動作的許可。若要關閉執行個體的詳細監控，您的使用者必須具有使用 [https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_UnmonitorInstances.html](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_UnmonitorInstances.html) API 動作的許可。

## 在啟動時啟用詳細監控
<a name="enable-detailed-monitoring"></a>

在啟動時，使用下列程序啟用詳細監控。依預設，執行個體會使用基本監控。

------
#### [ Console ]

**在執行個體啟動時啟用詳細監控**  
使用 Amazon EC2 主控台啟動執行個體時，請在**進階詳細資訊**下，選取**詳細 CloudWatch 監控**核取方塊。

------
#### [ AWS CLI ]

**在執行個體啟動時啟用詳細監控**  
請使用 `--monitoring` 選項並搭配 [run-instances](https://docs.aws.amazon.com/cli/latest/reference/ec2/run-instances.html) 命令。

```
--monitoring Enabled=true
```

------
#### [ PowerShell ]

**在執行個體啟動時啟用詳細監控**  
使用 [New-EC2Instance](https://docs.aws.amazon.com/powershell/latest/reference/items/New-EC2Instance.html) cmdlet 搭配 `-Monitoring` 參數。

```
-Monitoring $true
```

------

## 管理詳細監控
<a name="disable-detailed-monitoring"></a>

使用下列程序來管理執行中或已停止之執行個體的詳細監控。

------
#### [ Console ]

**若要管理詳細監控**

1. 前往 [https://console.aws.amazon.com/ec2/](https://console.aws.amazon.com/ec2/) 開啟 Amazon EC2 主控台。

1. 在導覽窗格中，選擇**執行個體**。

1. 選取執行個體。

1. 選擇**動作**、**監控和疑難排解**、**管理詳細監控**。

1. 在**詳細監控**頁面上，針對**詳細監控**，執行下列其中一項操作：
   + 詳細監控 – 選取**啟用**。
   + 基本監控 – 清除**啟用**。

1. 選擇**確認**。

------
#### [ AWS CLI ]

**若要啟用詳細監控**  
使用下列 [monitor-instances](https://docs.aws.amazon.com/cli/latest/reference/ec2/monitor-instances.html) 命令。

```
aws ec2 monitor-instances --instance-ids i-1234567890abcdef0
```

**若要停用詳細監控**  
使用 [unmonitor-instances](https://docs.aws.amazon.com/cli/latest/reference/ec2/unmonitor-instances.html) 命令。

```
aws ec2 unmonitor-instances --instance-ids i-1234567890abcdef0
```

------
#### [ PowerShell ]

**若要啟用詳細監控**  
使用 [Start-EC2InstanceMonitoring](https://docs.aws.amazon.com/powershell/latest/reference/items/Start-EC2InstanceMonitoring.html) cmdlet。

```
Start-EC2InstanceMonitoring -InstanceId i-1234567890abcdef0
```

**若要停用詳細監控**  
使用 [Stop-EC2InstanceMonitoring](https://docs.aws.amazon.com/powershell/latest/reference/items/Stop-EC2InstanceMonitoring.html) cmdlet。

```
Stop-EC2InstanceMonitoring -InstanceId i-1234567890abcdef0
```

------