

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

# 搭配 CloudWatch 指標使用指標數學
<a name="monitoring-metric-math"></a>

使用指標數學，您可以查詢多個 Amazon CloudWatch 指標，並使用數學表達式根據這些指標建立新的時間序列。您可以在 CloudWatch 主控台視覺化產生的時間序列，並將其新增至儀表板。例如，您可以使用 Amazon EFS 指標，將 `DataRead` 操作的取樣計數除以 60。結果便是指定 1 分鐘期間檔案系統的每秒讀取平均次數。如需指標數學的詳細資訊，請參閱《Amazon [ CloudWatch 使用者指南》中的搭配 CloudWatch 指標使用數學表達](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/using-metric-math.html)式。 * Amazon CloudWatch *

以下為一些實用的 Amazon EFS 指標數學運算式。

**Topics**
+ [指標數學：MiBps 的輸送量](#metric-math-throughput-mib)
+ [指標數學：輸送量百分比](#metric-math-throughput-percent)
+ [指標數學：允許輸送使用的百分比率](#metric-math-throughput-utilization)
+ [指標數學：輸送量 IOPS](#metric-math-throughput-iops)
+ [指標數學：IOPS 的百分比](#metric-math-iops-percent)
+ [指標數學：以 KiB 為單位的平均 I/O 大小](#metric-math-average-io)
+ [透過 Amazon EFS CloudFormation 範本使用指標數學](#metric-math-cloudformation-template)

## 指標數學：MiBps 的輸送量
<a name="metric-math-throughput-mib"></a>

若要計算一段時間的平均輸送量 (MiBps)，請先選擇總和統計資料 (`DataReadIOBytes`、`MetadataIOBytes`、 `DataWriteIOBytes`或 `TotalIOBytes`)。然後將該值轉換為 MiB，再除以該期間內的秒數。

假設您的範例邏輯如下：(`TotalIOBytes` 的總和 ÷ 1048576 (以轉換為 MiB)) ÷ 期間內的秒數

那麼，您的 CloudWatch 指標資訊如下。


| ID | 可用指標 | 統計數字 | Period | 
| --- | --- | --- | --- | 
| m1 |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/efs/latest/ug/monitoring-metric-math.html)  | sum | 1 分鐘 | 

您的指標數學 ID 和表達式如下。


| ID | 表達式 | 
| --- | --- | 
| e1 | (m1/1048576)/PERIOD(m1) | 

## 指標數學：輸送量百分比
<a name="metric-math-throughput-percent"></a>

此指標數學運算式會計算用於不同 I/O 類型的整體輸送量百分比，例如，由讀取請求驅動的總輸送量百分比。若要計算一段期間一種 I/O 類型 (`DataReadIOBytes`、`DataWriteIOBytes` 或 `MetadataIOBytes`) 使用的輸送量百分比，請先將個別總和統計數據乘以 100。然後將該結果除以同一期間的 `TotalIOBytes` 總和統計數據。

假設您的範例邏輯如下：(`DataReadIOBytes` 的總和 x 100 (以轉換為百分比)) ÷ `TotalIOBytes` 的總和

那麼，您的 CloudWatch 指標資訊如下。


| ID | 可用指標或多個指標 | 統計數字 | Period | 
| --- | --- | --- | --- | 
| m1 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/efs/latest/ug/monitoring-metric-math.html)  | sum | 1 分鐘 | 
| m2 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/efs/latest/ug/monitoring-metric-math.html)  | sum | 1 分鐘 | 

您的指標數學 ID 和表達式如下。


| ID | 表達式 | 
| --- | --- | 
| e1 | (m2\$1100)/m1 | 

## 指標數學：允許輸送使用的百分比率
<a name="metric-math-throughput-utilization"></a>

若要計算一段期間內允許的輸送量使用率 (`MeteredIOBytes`) 的百分比，請先將 MiBps 中的輸送量乘以 100。然後將結果除以在相同期間內`PermittedThroughput`轉換為 MiB 的平均統計資料。

假設您的範例邏輯是： (MiBps x 100 （轉換為百分比） 輸送量的指標數學表達式） ÷ (÷ 1，048，576 `PermittedThroughput` 的總和 （轉換為 MiB))

那麼，您的 CloudWatch 指標資訊如下。


| ID | 可用指標或多個指標 | 統計數字 | Period | 
| --- | --- | --- | --- | 
| m1 |  `MeteredIOBytes`  | sum | 1 分鐘 | 
| m2 | `PermittedThroughput` | average | 1 分鐘 | 

您的指標數學 ID 和表達式如下。


| ID | 表達式 | 
| --- | --- | 
| e1 |   (m1/1048576)/PERIOD(m1)  | 
| e2 | m2/1048576 | 
| e3 | ((e1)\$1100)/(e2) | 

## 指標數學：輸送量 IOPS
<a name="metric-math-throughput-iops"></a>

若要計算一段期間的每秒平均操作 (IOPS)，請將取樣計數統計數據 (`DataReadIOBytes`、`DataWriteIOBytes`、`MetadataIOBytes` 或 `TotalIOBytes`) 除以該期間的秒數。

假設您的範例邏輯如下：`DataWriteIOBytes` 的取樣計數 ÷ 期間內的秒數

那麼，您的 CloudWatch 指標資訊如下。


| ID | 可用指標 | 統計數字 | Period | 
| --- | --- | --- | --- | 
| m1 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/efs/latest/ug/monitoring-metric-math.html)  | 取樣計數 | 1 分鐘 | 

您的指標數學 ID 和表達式如下。


| ID | 表達式 | 
| --- | --- | 
| e1 | m1/PERIOD(m1) | 

## 指標數學：IOPS 的百分比
<a name="metric-math-iops-percent"></a>

若要計算一段期間的不同 I/O 類型 (`DataReadIOBytes`、`DataWriteIOBytes` 或 `MetadataIOBytes`) 每秒 IOPS 百分比，請先將個別取樣計數統計數據乘以 100。然後將該值除以同一期間的 `TotalIOBytes` 取樣計數統計數據。

假設您的範例邏輯如下：(`MetadataIOBytes` 的取樣計數 x 100 (以轉換為百分比)) ÷ `TotalIOBytes` 的取樣計數

那麼，您的 CloudWatch 指標資訊如下。


| ID | 可用指標 | 統計數字 | Period | 
| --- | --- | --- | --- | 
| m1 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/efs/latest/ug/monitoring-metric-math.html)  | 取樣計數 | 1 分鐘 | 
| m2 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/efs/latest/ug/monitoring-metric-math.html)  | 取樣計數 | 1 分鐘 | 

您的指標數學 ID 和表達式如下。


| ID | 表達式 | 
| --- | --- | 
| e1 | (m2\$1100)/m1 | 

## 指標數學：以 KiB 為單位的平均 I/O 大小
<a name="metric-math-average-io"></a>

若要計算一段期間的平均 I/O 大小 (以 KiB 為單位)，請將 `DataReadIOBytes`、`DataWriteIOBytes` 或 `MetadataIOBytes` 指標的個別總和統計數據除以該指標的相同取樣計數統計數據。

假設您的範例邏輯如下：(`DataReadIOBytes` 的總和 ÷ 1024 (轉換為 KiB))÷ `DataReadIOBytes` 的取樣計數

那麼，您的 CloudWatch 指標資訊如下。


| ID | 可用指標 | 統計數字 | Period | 
| --- | --- | --- | --- | 
| m1 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/efs/latest/ug/monitoring-metric-math.html)  | sum | 1 分鐘 | 
| m2 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/efs/latest/ug/monitoring-metric-math.html)  | 取樣計數 | 1 分鐘 | 

您的指標數學 ID 和表達式如下。


| ID | 表達式 | 
| --- | --- | 
| e1 | (m1/1024)/m2 | 

## 透過 Amazon EFS CloudFormation 範本使用指標數學
<a name="metric-math-cloudformation-template"></a>

您也可以透過 CloudFormation 範本建立指標數學表達式。GitHub 上的 [Amazon EFS 教學課程](https://github.com/aws-samples/amazon-efs-tutorial)提供其中一種範本，可供您下載和自訂使用。如需使用 CloudFormation 範本的詳細資訊，請參閱《 使用者指南》中的[使用 CloudFormation 範本](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-guide.html)。 *AWS CloudFormation *