

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

# Gateway Load Balancer 的 CloudWatch 指標
<a name="cloudwatch-metrics"></a>

Elastic Load Balancing 會將 Gateway Load Balancer 和目標的資料點發佈到 Amazon CloudWatch。CloudWatch 可讓使用一組時間序列資料的形式來擷取這些資料點的相關統計資料，也就是*指標*。您可以將指標視為要監控的變數，且資料點是該變數在不同時間點的值。例如，您可以監控 Gateway Load Balancer 在一段指定期間內的運作狀態良好的目標總數量。每個資料點都有關聯的時間戳記和可選的測量單位。

您可以使用指標來確認系統的運作符合預期。例如，若指標超過您認為能夠接受的範圍，您可以建立 CloudWatch 警示來監控指定的指標並執行動作 (例如傳送通知到電子郵件地址)。

Elastic Load Balancing 只會在請求穿越 Gateway Load Balancer 時回報指標到 CloudWatch。如果有請求流動，Elastic Load Balancing 會以 60 秒為間隔來測量並傳送其指標。如果沒有請求流動，或者指標沒有資料，則不會回報該指標。

如需詳細資訊，請參閱 [Amazon CloudWatch 使用者指南](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/)。

**Topics**
+ [Gateway Load Balancer 指標](#metrics)
+ [Gateway Load Balancer 的指標維度](#metric-dimensions)
+ [查看 Gateway Load Balancer 的 CloudWatch 指標](#view-metric-data)

## Gateway Load Balancer 指標
<a name="metrics"></a>

`AWS/GatewayELB` 命名空間包含下列指標。


| 指標 | Description | 
| --- | --- | 
| ActiveFlowCount |  從用戶端到目標的並行流程 (或連線) 總數。 **報告條件**：有非零值 **統計資訊**：最實用的統計資訊是 `Average`、`Maximum` 與 `Minimum`。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/elasticloadbalancing/latest/gateway/cloudwatch-metrics.html)  | 
| ConsumedLCUs |  負載平衡器所使用的負載平衡器容量單位 (LCU) 數目。您需要按每小時使用的 LCU 數目付費。如需詳細資訊，請參閱「[Elastic Load Balancing 定價](https://aws.amazon.com/elasticloadbalancing/pricing/)」。 **報告條件**：一律報告 **統計資訊**：全部 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/elasticloadbalancing/latest/gateway/cloudwatch-metrics.html)  | 
| HealthyHostCount |  視為健康的目標數目。 **報告條件**：運作狀態檢查啟用時報告 **統計資訊**：最實用的統計資訊是 `Maximum` 與 `Minimum`。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/elasticloadbalancing/latest/gateway/cloudwatch-metrics.html)  | 
| NewFlowCount |  在期間內，從用戶端到目標建立的新流程 (或連線) 總數。 **報告條件**：有非零值 **統計資訊**：最實用的統計資訊是 `Sum`。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/elasticloadbalancing/latest/gateway/cloudwatch-metrics.html)  | 
| PacketsDroppedCount\$1InvalidGeneveTunnel |  將封包傳回 GWLB 時，目標設備需要交換 GENEVE 通道來源和目的地 IP 地址，並使用正確的 GENEVE 目的地連接埠 (6081)。如果封包不符合上述準則，GWLB 會捨棄封包，並遞增此指標。 **報告條件**：一律報告 **統計資訊**：最實用的統計資訊是 `Sum`。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/elasticloadbalancing/latest/gateway/cloudwatch-metrics.html)  | 
| PacketsDroppedCount\$1InvalidGwlbEndpointId |  在回應 GWLB 時，設備需要傳回 TLV 中的 GwlbeEniId。如果缺少此 TLV，GWLB 會捨棄封包並遞增此指標。 **報告條件**：一律報告 **統計資訊**：最實用的統計資訊是 `Sum`。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/elasticloadbalancing/latest/gateway/cloudwatch-metrics.html)  | 
| PacketsDroppedCount\$1InvalidGwlbFlowCookie |  設備必須像回應 GWLB 一樣傳回 FlowCookie TLV。如果指定流程的流程 Cookie 不相符，則此指標會遞增。 **報告條件**：一律報告 **統計資訊**：最實用的統計資訊是 `Sum`。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/elasticloadbalancing/latest/gateway/cloudwatch-metrics.html)  | 
| PeakBytesPerSecond |  每秒處理的最高平均位元組數，在取樣時段內每 10 秒計算一次。此指標不包含運作狀態檢查流量。 **報告條件**：一律報告 **統計資訊**：最實用的統計資訊是 `Maximum`。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/elasticloadbalancing/latest/gateway/cloudwatch-metrics.html)  | 
| PeakPacketsPerSecond |  最高平均封包速率 （每秒處理的封包數），在取樣時段內每 10 秒計算一次。此指標包含運作狀態檢查流量。 **報告條件**：一律報告 **統計資訊**：最實用的統計資訊是 `Maximum`。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/elasticloadbalancing/latest/gateway/cloudwatch-metrics.html)  | 
| ProcessedBytes |  負載平衡器處理的位元組總數。此計數包括進出目標的流量，但不包括運作狀態檢查流量。 **報告條件**：有非零值 **統計資訊**：最實用的統計資訊是 `Sum`。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/elasticloadbalancing/latest/gateway/cloudwatch-metrics.html)  | 
| ProcessedPackets |  負載平衡器處理的封包總數。此計數包括進出目標的流量，包含運作狀態檢查流量。 **報告條件**：一律報告 **統計資訊**：最實用的統計資訊是 `Sum`。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/elasticloadbalancing/latest/gateway/cloudwatch-metrics.html)  | 
| RejectedFlowCount |  負載平衡器拒絕的流程 （或連線） 總數。 **報告條件**：一律報告 **統計資訊**：最實用的統計資訊是 `Average`、`Maximum` 與 `Minimum`。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/elasticloadbalancing/latest/gateway/cloudwatch-metrics.html)  | 
| RejectedFlowCount\$1TCP |  負載平衡器拒絕的 TCP 流程 （或連線） 數目。 **報告條件**：有非零值。 **統計資訊**：最實用的統計資訊是 `Sum`。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/elasticloadbalancing/latest/gateway/cloudwatch-metrics.html)  | 
| UnHealthyHostCount |  視為不健康的目標數目。 **報告條件**：運作狀態檢查啟用時報告 **統計資訊**：最實用的統計資訊是 `Maximum` 與 `Minimum`。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/elasticloadbalancing/latest/gateway/cloudwatch-metrics.html)  | 

## Gateway Load Balancer 的指標維度
<a name="metric-dimensions"></a>

若要篩選 Gateway Load Balancer 的指標，請使用下列維度。


| 維度 | Description | 
| --- | --- | 
| AvailabilityZone |  依可用區域篩選指標資料。  | 
| LoadBalancer |  依 Gateway Load Balancer 篩選指標資料。指定 Gateway Load Balancer，如下：gateway/*load-balancer-name*/*1234567890123456* (ARN 的最終部分)。  | 
| TargetGroup |  依目標群組篩選指標資料。如下指定目標群組：targetgroup/*target-group-name*/*1234567890123456* (目標群組 ARN 的最終部分)。  | 

## 查看 Gateway Load Balancer 的 CloudWatch 指標
<a name="view-metric-data"></a>

您可以使用 Amazon EC2 主控台來檢視 Gateway Load Balancer 的 CloudWatch 指標。這些指標會以監控圖表的形式顯示。若啟用 Gateway Load Balancer 並接收請求，監控圖表會顯示資料點。

或者，您可以使用 CloudWatch 主控台來檢視 Gateway Load Balancer 的指標。

**使用 主控台檢視指標**

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

1. 若要檢視由目標群組篩選的指標，請執行下列動作：

   1. 在導覽窗格中，選擇 **Target Groups (目標群組)**。

   1. 選擇您的目標群組並選擇 **Monitoring (監控)**。

   1. (選用) 若要根據時間篩選結果，請選擇來自 **Showing data for (顯示資料)** 的時間範圍。

   1. 若要放大檢視單一指標，請選取它的圖形。

1. 若要檢視由 Gateway Load Balancer 篩選的指標，請執行下列動作：

   1. 在導覽窗格中，選擇 **Load Balancers (負載平衡器)**。

   1. 選擇您的 Gateway Load Balancer 並選擇**監控**。

   1. (選用) 若要根據時間篩選結果，請選擇來自 **Showing data for (顯示資料)** 的時間範圍。

   1. 若要放大檢視單一指標，請選取它的圖形。

**使用 CloudWatch 主控台檢視指標**

1. 在 [https://console.aws.amazon.com/cloudwatch/](https://console.aws.amazon.com/cloudwatch/) 開啟 CloudWatch 主控台。

1. 在導覽窗格中，選擇**指標**。

1. 選取 **GatewayELB** 命名空間。

1. (選用) 若要檢視所有維度的指標，請在搜尋欄位中輸入其名稱。

**使用 檢視指標 AWS CLI**  
使用下列 [list-metrics](https://docs.aws.amazon.com/cli/latest/reference/cloudwatch/list-metrics.html) 命令來列出可用指標：

```
aws cloudwatch list-metrics --namespace AWS/GatewayELB
```

**使用 取得指標的統計資料 AWS CLI**  
使用下列 [get-metric-statistics](https://docs.aws.amazon.com/cli/latest/reference/cloudwatch/get-metric-statistics.html) 指令來獲得指定指標與維度的統計資料。請注意，CloudWatch 將把維度的各獨特組合視為個別指標。您無法使用未具體發佈的維度組合來擷取統計資料。您必須指定建立指標時所使用的相同維度。

```
aws cloudwatch get-metric-statistics --namespace AWS/GatewayELB \
--metric-name UnHealthyHostCount --statistics Average  --period 3600 \
--dimensions Name=LoadBalancer,Value=net/my-load-balancer/50dc6c495c0c9188 \
Name=TargetGroup,Value=targetgroup/my-targets/73e2d6bc24d8a067 \
--start-time 2017-04-18T00:00:00Z --end-time 2017-04-21T00:00:00Z
```

以下為範例輸出。

```
{
    "Datapoints": [
        {
            "Timestamp": "2020-12-18T22:00:00Z",
            "Average": 0.0,
            "Unit": "Count"
        },
        {
            "Timestamp": "2020-12-18T04:00:00Z",
            "Average": 0.0,
            "Unit": "Count"
        },
        ...
    ],
    "Label": "UnHealthyHostCount"
}
```