

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

# Amazon Managed Workflows for Apache Airflow 的監控和指標
<a name="cw-metrics"></a>

監控是維護 Amazon Managed Workflows for Apache Airflow 和您的 AWS 解決方案可靠性、可用性和效能的重要部分。我們建議您從 AWS 解決方案的所有部分收集監控資料，以便在發生多點失敗時更輕鬆地偵錯。本主題說明 AWS Amazon MWAA 環境監控和回應潛在事件的資源。

**注意**  
Apache Airflow 指標和記錄受標準 [Amazon CloudWatch 定價](https://aws.amazon.com/cloudwatch/pricing/)約束。

如需監控 Apache Airflow 的詳細資訊，請參閱 Apache Airflow 文件網站上的[記錄和監控](https://airflow.apache.org/docs/apache-airflow/stable/logging-monitoring/index.html)。

**Topics**
+ [Amazon MWAA 的監控概觀](monitoring-overview.md)
+ [在 中存取稽核日誌 AWS CloudTrail](monitoring-cloudtrail.md)
+ [在 Amazon CloudWatch 中存取 Airflow 日誌](monitoring-airflow.md)
+ [在 Amazon MWAA 上監控儀表板和警示](monitoring-dashboard.md)
+ [CloudWatch 中的 Apache Airflow 環境指標](access-metrics-cw.md)
+ [Amazon MWAA 的容器、佇列和資料庫指標](accessing-metrics-cw-container-queue-db.md)

# Amazon MWAA 的監控概觀
<a name="monitoring-overview"></a>

此頁面說明用來監控 Amazon Managed Workflows for Apache Airflow 環境 AWS 的服務。

**Contents**
+ [Amazon CloudWatch 概觀](#monitoring-metrics-cw-about)
+ [AWS CloudTrail 概觀](#monitoring-metrics-ct-about)

## Amazon CloudWatch 概觀
<a name="monitoring-metrics-cw-about"></a>

CloudWatch 是 AWS 服務的指標儲存庫，可用來根據服務發佈的[指標](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#Metric)和[維度](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#Dimension)擷取統計資料。您可以使用這些指標來設定[警示](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#CloudWatchAlarms)、計算統計資料，然後在[儀表板](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Dashboards.html)中呈現資料，協助您在 Amazon CloudWatch 主控台中評估環境的運作狀態。

Apache Airflow 已設定為將 Amazon Managed Workflows for Apache Airflow 環境的 [StatsD](https://github.com/etsy/statsd) 指標傳送至 Amazon CloudWatch。

若要進一步了解，請參閱[什麼是 Amazon CloudWatch？](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/WhatIsCloudWatch.html)。

## AWS CloudTrail 概觀
<a name="monitoring-metrics-ct-about"></a>

CloudTrail 是一種稽核服務，可提供 Amazon MWAA AWS 中使用者、角色或服務所採取動作的記錄。您可以使用 CloudTrail 所收集的資訊，判斷對 Amazon MWAA 提出的請求、提出請求的 IP 地址、提出請求的人員、提出請求的時間，以及稽核日誌中提供的其他詳細資訊。

若要進一步了解，請參閱[什麼是 AWS CloudTrail？](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-user-guide.html)。

# 在 中存取稽核日誌 AWS CloudTrail
<a name="monitoring-cloudtrail"></a>

AWS CloudTrail 當您建立 AWS 帳戶 時， 會在您的 上啟用 。CloudTrail 會記錄 IAM 實體或服務所採取的活動 AWS ，例如 Amazon Managed Workflows for Apache Airflow，這會記錄為 CloudTrail 事件。您可以在 CloudTrail 主控台中檢視、搜尋和下載過去 90 天的事件歷史記錄。CloudTrail 會擷取 Amazon MWAA 主控台上的所有事件，以及對 Amazon MWAA APIs 的所有呼叫。它不會擷取唯讀動作，例如 `GetEnvironment`或 `PublishMetrics`動作。此頁面說明如何使用 CloudTrail 監控 Amazon MWAA 的事件。

**Contents**
+ [在 CloudTrail 中建立追蹤](#monitoring-cloudtrail-create)
+ [使用 CloudTrail 事件歷史記錄存取事件](#monitoring-cloudtrail-view)
+ [的範例追蹤 `CreateEnvironment`](#monitoring-cloudtrail-logs-ex)
+ [後續步驟？](#monitoring-cloudtrail-next-up)

## 在 CloudTrail 中建立追蹤
<a name="monitoring-cloudtrail-create"></a>

您需要建立追蹤來存取 中事件的持續記錄 AWS 帳戶，包括 Amazon MWAA 的事件。線索能讓 CloudTrail 將日誌檔案交付至 Amazon S3 儲存貯體。如果您未建立追蹤，您仍然可以在 CloudTrail 主控台中存取可用的事件歷史記錄。例如，使用 CloudTrail 收集的資訊，您可以判斷對 Amazon MWAA 提出的請求、提出請求的 IP 地址、提出請求的人員、提出請求的時間，以及其他詳細資訊。若要進一步了解，請參閱[為您的 建立追蹤 AWS 帳戶](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-create-and-update-a-trail.html)。

## 使用 CloudTrail 事件歷史記錄存取事件
<a name="monitoring-cloudtrail-view"></a>

您可以在 CloudTrail 主控台中檢視事件歷史記錄，對過去 90 天內的操作和安全事件進行故障診斷。例如，您可以存取 AWS 帳戶 與每個區域 中資源 （例如 IAM 使用者或其他 AWS 資源） 建立、修改或刪除相關的事件。若要進一步了解，請參閱[使用 CloudTrail 事件歷史記錄存取事件](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/view-cloudtrail-events.html)。

1. 開啟 [CloudTrail 主控台](https://console.aws.amazon.com/cloudtrail/home#)。

1. 選擇**事件歷史記錄**。

1. 選取您要檢視的事件，然後選擇**比較事件詳細資訊**。

## 的範例追蹤 `CreateEnvironment`
<a name="monitoring-cloudtrail-logs-ex"></a>

追蹤是一種組態，能讓事件以日誌檔案的形式交付到您指定的 Amazon S3 儲存貯體。

CloudTrail 日誌檔案包含一或多個日誌專案。事件代表來自任何來源的單一請求，並包含所請求動作的相關資訊，例如動作的日期和時間，或請求參數。CloudTrail 日誌檔案不是公有 API 呼叫的排序堆疊追蹤，也不會以任何特定順序列出。下列範例是 `CreateEnvironment`動作的日誌項目，因為缺少許可而遭到拒絕。中的值`AirflowConfigurationOptions`已針對隱私權進行修訂。

```
{
  "eventVersion": "1.05",
  "userIdentity": {
    "type": "AssumedRole",
    "principalId": "00123456ABC7DEF8HIJK",
    "arn": "arn:aws:sts::012345678901:assumed-role/root/myuser",
    "accountId": "012345678901",
    "accessKeyId": "",
    "sessionContext": {
      "sessionIssuer": {
        "type": "Role",
        "principalId": "00123456ABC7DEF8HIJK",
        "arn": "arn:aws:iam::012345678901:role/user",
        "accountId": "012345678901",
        "userName": "user"
      },
      "webIdFederationData": {},
      "attributes": {
        "mfaAuthenticated": "false",
        "creationDate": "2020-10-07T15:51:52Z"
      }
    }
  },
  "eventTime": "2020-10-07T15:52:58Z",
  "eventSource": "airflow.amazonaws.com",
  "eventName": "CreateEnvironment",
  "awsRegion": "us-west-2",
  "sourceIPAddress": "205.251.233.178",
  "userAgent": "PostmanRuntime/7.26.5",
  "errorCode": "AccessDenied",
  "requestParameters": {
    "SourceBucketArn": "arn:aws:s3:::my-bucket",
    "ExecutionRoleArn": "arn:aws:iam::012345678901:role/AirflowTaskRole",
    "AirflowConfigurationOptions": "***",
    "DagS3Path": "sample_dag.py",
    "NetworkConfiguration": {
      "SecurityGroupIds": [
      "sg-01234567890123456"
      ],
      "SubnetIds": [
        "subnet-01234567890123456",
        "subnet-65432112345665431"
      ]
    },
    "Name": "test-cloudtrail"
  },
  "responseElements": {
    "message": "Access denied."
  },
  "requestID": "RequestID",
  "eventID": "EventID",
  "readOnly": false,
  "eventType": "AwsApiCall",
  "recipientAccountId": "012345678901"
}
```

## 後續步驟？
<a name="monitoring-cloudtrail-next-up"></a>
+ 了解如何為 CloudTrail 支援的 AWS 服務和整合中的 CloudTrail 日誌中收集的事件資料設定其他服務。 [CloudTrail ](https://docs.aws.amazon.com//awscloudtrail/latest/userguide/cloudtrail-aws-service-specific-topics.html#cloudtrail-aws-service-specific-topics-integrations)
+ 了解如何在設定 CloudTrail 的 Amazon SNS 通知中，在 CloudTrail 將新的日誌檔案發佈至 Amazon S3 [儲存貯體時收到通知 Amazon SNS CloudTrail](https://docs.aws.amazon.com//awscloudtrail/latest/userguide/getting_notifications_top_level.html)。

# 在 Amazon CloudWatch 中存取 Airflow 日誌
<a name="monitoring-airflow"></a>

Amazon MWAA 可以將 Apache Airflow 日誌傳送至 Amazon CloudWatch。您可以從單一位置存取多個環境的日誌，輕鬆識別 Apache Airflow 任務延遲或工作流程錯誤，而無需額外的第三方工具。必須在 Amazon Managed Workflows for Apache Airflow 主控台上啟用 Apache Airflow 日誌，才能存取 CloudWatch 中的 Apache Airflow DAG 處理、任務、Web 伺服器、工作者日誌。

**Contents**
+ [定價](#monitoring-airflow-pricing)
+ [開始之前](#monitoring-airflow-before)
+ [日誌類型](#monitoring-airflow-log-groups)
+ [啟用 Apache Airflow 日誌](#monitoring-airflow-enable)
+ [存取 Apache Airflow 日誌](#monitoring-airflow-view)
+ [排程器日誌範例](#monitoring-airflow-example)
+ [後續步驟？](#monitoring-airflow-next-up)

## 定價
<a name="monitoring-airflow-pricing"></a>
+ 需支付標準 CloudWatch Logs 費用。如需詳細資訊，請參閱 [CloudWatch 定價](https://aws.amazon.com/cloudwatch/pricing/)。

## 開始之前
<a name="monitoring-airflow-before"></a>
+ 您必須擁有可存取 CloudWatch 中日誌的角色。如需詳細資訊，請參閱 [存取 Amazon MWAA 環境](access-policies.md)。

## 日誌類型
<a name="monitoring-airflow-log-groups"></a>

Amazon MWAA 會為您啟用的每個 Airflow 記錄選項建立日誌群組，並將日誌推送至與環境相關聯的 CloudWatch Logs 群組。日誌群組會以下列格式命名：`YourEnvironmentName-LogType`。例如，如果您的環境名為 `Airflow-v202-Public`，Apache Airflow 任務日誌會傳送至 `Airflow-v202-Public-Task`。


| 日誌類型 | Description | 
| --- | --- | 
|  `YourEnvironmentName-DAGProcessing`  |  DAG 處理器管理員 （處理 DAG 檔案之排程器的一部分） 的日誌。  | 
|  `YourEnvironmentName-Scheduler`  |  Airflow 排程器產生的日誌。  | 
|  `YourEnvironmentName-Task`  |  DAG 產生的任務日誌。  | 
|  `YourEnvironmentName-WebServer`  |  Airflow Web 界面產生的日誌。  | 
|  `YourEnvironmentName-Worker`  |  在工作流程和 DAG 執行中產生的日誌。  | 

## 啟用 Apache Airflow 日誌
<a name="monitoring-airflow-enable"></a>

您可以在 `INFO`、`ERROR`、 或 `CRITICAL`層級啟用 Apache Airflow `WARNING`日誌。當您選擇日誌層級時，Amazon MWAA 會傳送該層級和所有較高嚴重性層級的日誌。例如，如果您在 `INFO`層級啟用日誌，Amazon MWAA 會將`INFO`日誌和 `ERROR`、 `WARNING`和 `CRITICAL`日誌層級傳送至 CloudWatch Logs。

1. 在 Amazon MWAA 主控台上開啟[環境](https://console.aws.amazon.com/mwaa/home#/environments)頁面。

1. 選擇環境。

1. 選擇**編輯**。

1. 選擇**下一步**。

1. 選擇下列一或多個記錄選項：

   1. 在**監控**窗格中選擇 **Airflow 排程器日誌群組**。

   1. 在**監控**窗格中選擇 **Airflow Web 伺服器日誌群組**。

   1. 在**監控**窗格中選擇 **Airflow 工作者日誌群組**。

   1. 在**監控**窗格中選擇 **Airflow DAG 處理日誌群組**。

   1. 在**監控**窗格中選擇 **Airflow 任務日誌群組**。

   1. 在日誌層級中選擇**日誌層級**。

1. 選擇**下一步**。

1. 選擇**儲存**。

## 存取 Apache Airflow 日誌
<a name="monitoring-airflow-view"></a>

下一節說明如何在 CloudWatch 主控台中存取 Apache Airflow 日誌。

1. 在 Amazon MWAA 主控台上開啟[環境](https://console.aws.amazon.com/mwaa/home#/environments)頁面。

1. 選擇環境。

1. 在**監控**窗格中選擇日誌群組。

1. 在日誌**串流中選擇日誌**。

## 排程器日誌範例
<a name="monitoring-airflow-example"></a>

您可以存取排程器的 Apache Airflow 日誌來排程工作流程和剖析`dags`資料夾。下列步驟說明如何在 Amazon MWAA 主控台上開啟排程器的日誌群組，以及在 CloudWatch Logs 主控台上存取 Apache Airflow 日誌。

**存取 的日誌 `requirements.txt`**

1. 在 Amazon MWAA 主控台上開啟[環境](https://console.aws.amazon.com/mwaa/home#/environments)頁面。

1. 選擇環境。

1. 在**監控**窗格中選擇 **Airflow 排程器日誌群組**。

1. 在`requirements_install_ip`日誌**串流中選擇日誌**。

1. 請參閱 環境上安裝的套件清單`/usr/local/airflow/.local/bin`。例如：

   ```
   Collecting appdirs==1.4.4 (from -r /usr/local/airflow/.local/bin (line 1))
   Downloading https://files.pythonhosted.org/packages/3b/00/2344469e2084fb28kjdsfiuyweb47389789vxbmnbjhsdgf5463acd6cf5e3db69324/appdirs-1.4.4-py2.py3-none-any.whl  
   Collecting astroid==2.4.2 (from -r /usr/local/airflow/.local/bin (line 2))
   ```

1. 檢閱套件清單，以及是否有任何套件在安裝期間發生錯誤。如果發生錯誤，您可能會收到類似以下的錯誤：

   ```
   2021-03-05T14:34:42.731-07:00
   No matching distribution found for LibraryName==1.0.0 (from -r /usr/local/airflow/.local/bin (line 4))
   No matching distribution found for LibraryName==1.0.0 (from -r /usr/local/airflow/.local/bin (line 4))
   ```

## 後續步驟？
<a name="monitoring-airflow-next-up"></a>
+ 了解如何使用 Amazon CloudWatch 警示在 中設定 CloudWatch 警示。 [ Amazon CloudWatch ](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/AlarmThatSendsEmail.html)
+ 了解如何使用 CloudWatch 儀表板在 中[建立 CloudWatch 儀表板](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Dashboards.html)。

# 在 Amazon MWAA 上監控儀表板和警示
<a name="monitoring-dashboard"></a>

您可以在 Amazon CloudWatch 中建立自訂儀表板，並為特定指標新增警示，以監控 Amazon Managed Workflows for Apache Airflow 環境的運作狀態。當警示在儀表板上時，它會在處於 `ALARM` 狀態時變成紅色，讓您更輕鬆地主動監控 Amazon MWAA 環境的運作狀態。

Apache Airflow 公開多個程序的指標，包括 DAG 程序數量、DAG 包大小、目前正在執行的任務、任務失敗和成功。當您建立環境時，Airflow 會自動將 Amazon MWAA 環境的指標傳送至 CloudWatch。此頁面說明如何為 Amazon MWAA 環境的 CloudWatch 中的 Airflow 指標建立運作狀態儀表板。

**Contents**
+ [指標](#monitoring-dashboard-metrics)
+ [警示狀態概觀](#monitoring-dashboard-states)
+ [自訂儀表板和警示範例](#monitoring-dashboard-custom)
  + [關於這些指標](#monitoring-dashboard-custom-about)
  + [關於儀表板](#monitoring-dashboard-custom-about-dash)
  + [使用教學 AWS 課程](#monitoring-dashboard-tutorials)
  + [使用 CloudFormation](#monitoring-dashboard-cfn)
+ [刪除指標和儀表板](#monitoring-dashboard-delete)
+ [後續步驟？](#monitoring-dashboard-next-up)

## 指標
<a name="monitoring-dashboard-metrics"></a>

您可以為 Apache Airflow 版本可用的任何指標建立自訂儀表板和警示。每個指標對應至 Apache Airflow 金鑰效能指標 (KPI)。若要存取指標清單，請參閱：
+ [CloudWatch 中的 Apache Airflow 環境指標](access-metrics-cw.md)

## 警示狀態概觀
<a name="monitoring-dashboard-states"></a>

警示擁有以下可能的狀態：
+ `OK` – 指標或表達式在定義的閾值內。
+ `ALARM` – 指標或表達式在定義的閾值外。
+ `INSUFFICIENT_DATA` – 警示剛開始無法使用指標，或資料不足無法讓指標判斷警示狀態。

## 自訂儀表板和警示範例
<a name="monitoring-dashboard-custom"></a>

您可以建置自訂監控儀表板，以顯示 Amazon MWAA 環境所選指標的圖表。

### 關於這些指標
<a name="monitoring-dashboard-custom-about"></a>

以下清單說明本節中教學課程和範本定義在自訂儀表板中建立的每個指標。
+ *QueuedTasks* - 佇列狀態的任務數量。對應至 `executor.queued_tasks` Apache Airflow 指標。
+ *TasksPending* - 執行器中待定的任務數量。對應至 `scheduler.tasks.pending` Apache Airflow 指標。
**注意**  
不適用於 Apache Airflow v2.2 和更新版本。
+ *RunningTasks* - 在執行器中執行的任務數量。對應至 `executor.running_tasks` Apache Airflow 指標。
+ *SchedulerHeartbeat* - Apache Airflow 在排程器任務上執行的簽入次數。對應至 `scheduler_heartbeat` Apache Airflow 指標。
+ *TotalParseTime* - 掃描和匯入所有 DAG 檔案一次所需的秒數。對應至 `dag_processing.total_parse_time` Apache Airflow 指標。

### 關於儀表板
<a name="monitoring-dashboard-custom-about-dash"></a>

下圖顯示本節教學課程和範本定義所建立的監控儀表板。

![\[此圖說明在 Amazon MWAA 主控台上尋找私有網路選項的位置。\]](http://docs.aws.amazon.com/zh_tw/mwaa/latest/userguide/images/cw-dashboard.png)


### 使用教學 AWS 課程
<a name="monitoring-dashboard-tutorials"></a>

您可以使用下列 AWS 教學課程，自動為目前部署的任何 Amazon MWAA 環境建立運作狀態儀表板。它也會在所有 Amazon MWAA 環境中為運作狀態不佳的工作者和排程器活動訊號失敗建立 CloudWatch 警示。
+ [Amazon MWAA 的 CloudWatch Dashboard Automation](https://github.com/aws-samples/mwaa-dashboard)

### 使用 CloudFormation
<a name="monitoring-dashboard-cfn"></a>

您可以使用本節中的 CloudFormation 範本定義，在 CloudWatch 中建立監控儀表板，然後在 CloudWatch 主控台上新增警示，以在指標超過特定閾值時接收通知。若要使用此範本定義建立堆疊，請參閱[在 CloudFormation 主控台上建立堆疊](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-console-create-stack.html)。若要將警示新增至儀表板，請參閱[使用警示](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/AlarmThatSendsEmail.html)。

```
AWSTemplateFormatVersion: "2010-09-09"
Description: Creates MWAA Cloudwatch Dashboard
Parameters:
  DashboardName:
    Description: Enter the name of the CloudWatch Dashboard
    Type: String
  EnvironmentName:
    Description: Enter the name of the MWAA Environment
    Type: String    
Resources:
  BasicDashboard:
    Type: AWS::CloudWatch::Dashboard
    Properties:
      DashboardName: !Ref DashboardName
      DashboardBody:
        Fn::Sub: '{
              "widgets": [
                  {
                      "type": "metric",
                      "x": 0,
                      "y": 0,
                      "width": 12,
                      "height": 6,
                      "properties": {
                          "view": "timeSeries",
                          "stacked": true,
                          "metrics": [
                              [
                                  "AmazonMWAA",
                                  "QueuedTasks",
                                  "Function",
                                  "Executor",
                                  "Environment",
                                  "${EnvironmentName}"
                              ]
                          ],
                          "region": "${AWS::Region}",
                          "title": "QueuedTasks ${EnvironmentName}",
                          "period": 300
                      }
                  },
                  {
                      "type": "metric",
                      "x": 0,
                      "y": 6,
                      "width": 12,
                      "height": 6,
                      "properties": {
                          "view": "timeSeries",
                          "stacked": true,
                          "metrics": [
                              [
                                  "AmazonMWAA",
                                  "RunningTasks",
                                  "Function",
                                  "Executor",
                                  "Environment",
                                  "${EnvironmentName}"
                              ]
                          ],
                          "region": "${AWS::Region}",
                          "title": "RunningTasks ${EnvironmentName}",
                          "period": 300
                      }
                  },
                  {
                      "type": "metric",
                      "x": 12,
                      "y": 6,
                      "width": 12,
                      "height": 6,
                      "properties": {
                          "view": "timeSeries",
                          "stacked": true,
                          "metrics": [
                              [
                                  "AmazonMWAA",
                                  "SchedulerHeartbeat",
                                  "Function",
                                  "Scheduler",
                                  "Environment",
                                  "${EnvironmentName}"
                              ]
                          ],
                          "region": "${AWS::Region}",
                          "title": "SchedulerHeartbeat ${EnvironmentName}",
                          "period": 300
                      }
                  },
                  {
                      "type": "metric",
                      "x": 12,
                      "y": 0,
                      "width": 12,
                      "height": 6,
                      "properties": {
                          "view": "timeSeries",
                          "stacked": true,
                          "metrics": [
                              [
                                  "AmazonMWAA",
                                  "TasksPending",
                                  "Function",
                                  "Scheduler",
                                  "Environment",
                                  "${EnvironmentName}"
                              ]
                          ],
                          "region": "${AWS::Region}",
                          "title": "TasksPending ${EnvironmentName}",
                          "period": 300
                      }
                  },
                  {
                      "type": "metric",
                      "x": 0,
                      "y": 12,
                      "width": 24,
                      "height": 6,
                      "properties": {
                          "view": "timeSeries",
                          "stacked": true,
                          "region": "${AWS::Region}",
                          "metrics": [
                              [
                                  "AmazonMWAA",
                                  "TotalParseTime",
                                  "Function",
                                  "DAG Processing",
                                  "Environment",
                                  "${EnvironmentName}"
                              ]
                          ],
                          "title": "TotalParseTime  ${EnvironmentName}",
                          "period": 300
                      }
                  }
              ]
          }'
```

## 刪除指標和儀表板
<a name="monitoring-dashboard-delete"></a>

如果您刪除 Amazon MWAA 環境，也會刪除對應的儀表板。CloudWatch 指標會儲存十五 (15) 個月，且無法刪除。CloudWatch 主控台會將指標搜尋限制在上次擷取指標後兩 (2) 週，以確保為您的 Amazon MWAA 環境顯示最新的執行個體。若要進一步了解，請參閱 [Amazon CloudWatch FAQs](https://aws.amazon.com/cloudwatch/faqs/)。

## 後續步驟？
<a name="monitoring-dashboard-next-up"></a>
+ 了解如何建立 DAG，以查詢您環境的 Amazon Aurora PostgreSQL 中繼資料資料庫，並將自訂指標發佈至 中的 CloudWatch[使用 DAG 在 CloudWatch 中寫入自訂指標](samples-custom-metrics.md)。

# CloudWatch 中的 Apache Airflow 環境指標
<a name="access-metrics-cw"></a>

Apache Airflow v2 和 v3 已設定為收集 [StatsD](https://github.com/etsy/statsd) 指標，並將 Amazon Managed Workflows for Apache Airflow 環境的 StatsD 指標傳送至 Amazon CloudWatch。Apache Airflow 傳送的指標完整清單可在 *Apache Airflow 參考指南*中的[指標](https://airflow.apache.org/docs/apache-airflow/stable/administration-and-deployment/logging-monitoring/metrics.html)頁面上取得。此頁面說明 CloudWatch 中可用的 Apache Airflow 指標，以及如何在 CloudWatch 主控台中存取指標。

**Contents**
+ [條款](#access-metrics-cw-terms)
+ [維度](#metrics-dimensions)
+ [在 CloudWatch 主控台中存取指標](#access-metrics-cw-console)
+ [CloudWatch 中可用的 Apache Airflow 指標](#available-metrics-cw)
  + [Apache Airflow 計數器](#counters-metrics)
  + [Apache Airflow 量測器](#gauges-metrics)
  + [Apache Airflow 計時器](#timers-metrics)
+ [選擇報告哪些指標](#choosing-metrics)
+ [後續步驟？](#mwaa-metrics202-next-up)

## 條款
<a name="access-metrics-cw-terms"></a>

**命名空間**  
命名空間是 AWS 服務的 CloudWatch 指標的容器。對於 Amazon MWAA，命名空間為 *AmazonMWAA*。

**CloudWatch 指標**  
CloudWatch 指標代表 CloudWatch 特有的一組按時間順序排列的資料點。

**Apache Airflow 指標**  
Apache Airflow 特定的[指標](https://airflow.apache.org/docs/apache-airflow/stable/administration-and-deployment/logging-monitoring/metrics.html )。

**維度**  
維度是一組名稱值對，是指標身分的一部分。

**單位**  
統計資料具有度量單位。對於 Amazon MWAA，單位包括*計數*、*秒*和*毫秒*。對於 Amazon MWAA，單位是根據原始 Airflow 指標中的單位設定。

## 維度
<a name="metrics-dimensions"></a>

本節說明 CloudWatch 中 Apache Airflow 指標的 CloudWatch *Dimensions* 分組。


| 維度 | Description | 
| --- | --- | 
|  DAG  |  指出特定的 Apache Airflow DAG 名稱。  | 
|  DAG 檔案名稱  |  指出特定的 Apache Airflow DAG 檔案名稱。  | 
|  函式  |  此維度用於改善 CloudWatch 中指標的分組。  | 
|  任務  |  指出排程器執行的 Apache Airflow 任務。值一律為 `Job`。  | 
|  運算子  |  指出特定的 Apache Airflow 運算子。  | 
|  集區  |  指出特定的 Apache Airflow 工作者集區。  | 
|  任務  |  指出特定的 Apache Airflow 任務。  | 
|  HostName  |  指出特定執行中 Apache Airflow 程序的主機名稱。  | 

## 在 CloudWatch 主控台中存取指標
<a name="access-metrics-cw-console"></a>

本節說明如何存取 CloudWatch 中特定 DAG 的效能指標。

**存取維度的效能指標**

1. 在 CloudWatch 主控台上開啟[指標頁面](https://console.aws.amazon.com/cloudwatch/home#metricsV2:graph=~())。

1. 選取您的 AWS 區域。

1. 選擇 **AmazonMWAA** 命名空間。

1. **在所有指標**索引標籤中，選取維度。例如 *DAG、Environment*。

1. 選擇維度的 CloudWatch 指標。例如，*TaskInstanceSuccesses* 或 *TaskInstanceDuration*。選擇繪製**所有搜尋結果的圖形**。

1. 選擇**圖形化指標**索引標籤，以存取 Apache Airflow 指標的效能統計資料，例如 *DAG、環境、任務*。

## CloudWatch 中可用的 Apache Airflow 指標
<a name="available-metrics-cw"></a>

本節說明傳送至 CloudWatch 的 Apache Airflow 指標和維度。

### Apache Airflow 計數器
<a name="counters-metrics"></a>

本節中的 Apache Airflow 指標包含有關 [Apache Airflow *計數器*](https://airflow.apache.org/docs/apache-airflow/stable/administration-and-deployment/logging-monitoring/metrics.html#counters)的資料。


| CloudWatch 指標 | Apache Airflow 指標 | 單位 | 維度 | 
| --- | --- | --- | --- | 
|  SLAMissed  僅適用於 Apache Airflow v2.4.3 至 v2.10.3。   |  sla\$1missed  |  計數  |  函數、排程器  | 
|  FailedSLACallback  僅適用於 Apache Airflow v2.4.3 至 v2.10.3。   |  sla\$1callback\$1notification\$1failure  |  計數  |  函數、排程器  | 
|  更新  適用於 Apache Airflow 2.6.3 版及更新版本。   |  dataset.updates  |  計數  |  函數、排程器  | 
|  孤立  適用於 Apache Airflow 2.6.3 版及更新版本。   |  dataset.orphaned  |  計數  |  函數、排程器  | 
|  FailedCeleryTaskExecution  適用於 Apache Airflow 2.4.3 版及更新版本。   |  celery.execute\$1command.failure  |  計數  |  函數、Celery  | 
|  FilePathQueueUpdateCount  適用於 Apache Airflow 2.6.3 版及更新版本。   |  dag\$1processing.file\$1path\$1queue\$1update\$1count  |  計數  |  函數、排程器  | 
|  CriticalSectionBusy  |  scheduler.critical\$1section\$1busy  |  計數  |  函數、排程器  | 
|  DagBagSize  |  dagbag\$1size  |  計數  |  函數、DAG 處理  | 
|  DagCallbackExceptions  |  dag.callback\$1exceptions  |  計數  |  DAG，全部  | 
|  FailedSLAEmailAttempts  不適用於 Apache Airflow v3.0.6 和更新版本。   |  sla\$1email\$1notification\$1failure  |  計數  |  函數、排程器  | 
|  TaskInstanceFinished  |  ti.finish.\$1dag\$1id\$1.\$1task\$1id\$1.\$1state\$1  |  計數  |  DAG、\$1dag\$1id\$1 任務，\$1task\$1id\$1 狀態，\$1state\$1  | 
|  JobEnd  |  \$1job\$1name\$1\$1end  |  計數  |  任務，\$1job\$1name\$1  | 
|  JobHeartbeatFailure  |  \$1job\$1name\$1\$1heartbeat\$1failure  |  計數  |  任務，\$1job\$1name\$1  | 
|  JobStart  |  \$1job\$1name\$1\$1start  |  計數  |  任務，\$1job\$1name\$1  | 
|  ManagerStalls  |  dag\$1processing.manager\$1stalls  |  計數  |  函數、DAG 處理  | 
|  OperatorFailures  |  Operator\$1failures\$1\$1operator\$1name\$1  |  計數  |  運算子，\$1operator\$1name\$1  | 
|  OperatorSuccesses  |  Operator\$1successes\$1\$1operator\$1name\$1  |  計數  |  運算子，\$1operator\$1name\$1  | 
|  OtherCallbackCount  Apache Airflow 2.6.3 版及更新版本中提供。   |  dag\$1processing.other\$1callback\$1count  |  計數  |  函數、排程器  | 
|  Processes  |  dag\$1processing.processes  |  計數  |  函數、DAG 處理  | 
|  SchedulerHeartbeat  |  scheduler\$1heartbeat  |  計數  |  函數、排程器  | 
|  StartedTaskInstances  |  ti.start.\$1dag\$1id\$1.\$1task\$1id\$1  |  計數  |  DAG，全部 任務，全部  | 
|  SlaCallbackCount  |  dag\$1processing.sla\$1callback\$1count  適用於 Apache Airflow 2.6.3 版及更新版本。   |  計數  |  函數、排程器  | 
|  TasksKilledExternally  |  scheduler.tasks.killed\$1externally  |  計數  |  函數、排程器  | 
|  TaskTimeoutError  |  celery.task\$1timeout\$1error  |  計數  |  函數、Celery  | 
|  TaskInstanceCreatedUsingOperator  |  task\$1instance\$1created-\$1operator\$1name\$1  |  計數  |  運算子，\$1operator\$1name\$1  | 
|  TaskInstancePreviouslySucceeded  |  previously\$1succeeded  |  計數  |  DAG，全部 任務，全部  | 
|  TaskInstanceFailures  |  ti\$1failures  |  計數  |  DAG，全部 任務，全部  | 
|  TaskInstanceSuccesses  |  ti\$1successes  |  計數  |  DAG，全部 任務，全部  | 
|  TaskRemovedFromDAG  |  task\$1removed\$1from\$1dag.\$1dag\$1id\$1  |  計數  |  DAG、\$1dag\$1id\$1  | 
|  TaskRestoredToDAG  |  task\$1restored\$1to\$1dag.\$1dag\$1id\$1  |  計數  |  DAG、\$1dag\$1id\$1  | 
|  TriggersSucceeded  適用於 Apache Airflow 2.7.2 版及更新版本。   |  triggers.succeeded  |  計數  |  函數、觸發  | 
|  TriggersFailed  適用於 Apache Airflow 2.7.2 版及更新版本。   |  triggers.failed  |  計數  |  函數、觸發  | 
|  TriggersBlockedMainThread  適用於 Apache Airflow 2.7.2 版及更新版本。   |  triggers.blocked\$1main\$1thread  |  計數  |  函數、觸發  | 
|  TriggerHeartbeat  適用於 Apache Airflow 2.8.1 版及更新版本。   |  triggerer\$1heartbeat  |  計數  |  函數、觸發器  | 
|  TaskInstanceCreatedUsingOperator  |  airflow.task\$1instance\$1created\$1`{operator_name}`  適用於 Apache Airflow 2.7.2 版及更新版本。   |  計數  |  運算子、 `{operator_name}`  | 
|  ZombiesKilled  |  zombies\$1killed  |  計數  |  DAG，全部 任務，全部  | 

### Apache Airflow 量測器
<a name="gauges-metrics"></a>

本節中的 Apache Airflow 指標包含有關 [Apache Airflow *量測計*](https://airflow.apache.org/docs/apache-airflow/stable/administration-and-deployment/logging-monitoring/metrics.html#gauges)的資料。


| CloudWatch 指標 | Apache Airflow 指標 | 單位 | 維度 | 
| --- | --- | --- | --- | 
|  DAGFileRefreshError  |  dag\$1file\$1refresh\$1error  |  計數  |  函數、DAG 處理  | 
|  ImportErrors  |  dag\$1processing.import\$1errors  |  計數  |  函數、DAG 處理  | 
|  ExceptionFailures  |  smart\$1sensor\$1operator.exception\$1failures  |  計數  |  函數、智慧型感應器運算子  | 
|  ExecutedTasks  |  smart\$1sensor\$1operator.executed\$1tasks  |  計數  |  函數、智慧型感應器運算子  | 
|  InfraFailures  |  smart\$1sensor\$1operator.infra\$1failures  |  計數  |  函數、智慧型感應器運算子  | 
|  LoadedTasks  |  smart\$1sensor\$1operator.loaded\$1tasks  |  計數  |  函數、智慧型感應器運算子  | 
|  TotalParseTime  |  dag\$1processing.total\$1parse\$1time  |  秒鐘  |  函數、DAG 處理  | 
|  TriggeredDagRuns  Apache Airflow 2.6.3 版及更新版本中提供。   |  dataset.triggered\$1dagruns  |  計數  |  函數、排程器  | 
|  TriggersRunning  Apache Airflow 2.7.2 版及更新版本中提供。   |  triggers.running.*\$1hostname\$1*  |  計數  |  函數、觸發 HostName、*\$1hostname\$1*  | 
|  PoolDeferredSlots  Apache Airflow 2.7.2 版及更新版本中提供。   |  pool.deferred\$1slots。`{pool_name}`  |  計數  |  集區，\$1pool\$1name\$1  | 
|  DAGFileProcessingLastRunSecondsAgo  |  dag\$1processing.last\$1run.seconds\$1ago.\$1dag\$1filename\$1  |  秒鐘  |  DAG 檔案名稱，\$1dag\$1filename\$1  | 
|  OpenSlots  |  executor.open\$1slots  |  計數  |  函數、執行器  | 
|  OrphanedTasksAdopted  |  scheduler.orphaned\$1tasks.adopted  |  計數  |  函數、排程器  | 
|  OrphanedTasksCleared  |  scheduler.orphaned\$1tasks.cleared  |  計數  |  函數、排程器  | 
|  PokedExceptions  |  smart\$1sensor\$1operator.poked\$1exception  |  計數  |  函數、智慧型感應器運算子  | 
|  PokedSuccess  |  smart\$1sensor\$1operator.poked\$1success  |  計數  |  函數、智慧型感應器運算子  | 
|  PokedTasks  |  smart\$1sensor\$1operator.poked\$1tasks  |  計數  |  函數、智慧型感應器運算子  | 
|  PoolFailures  |  pool.open\$1slots.\$1pool\$1name\$1  |  計數  |  集區，\$1pool\$1name\$1  | 
|  PoolStarvingTasks  |  pool.starving\$1tasks.\$1pool\$1name\$1  |  計數  |  集區，\$1pool\$1name\$1  | 
|  PoolOpenSlots  |  pool.open\$1slots.\$1pool\$1name\$1  |  計數  |  集區，\$1pool\$1name\$1  | 
|  PoolQueuedSlots  |  pool.queued\$1slots.\$1pool\$1name\$1  |  計數  |  集區，\$1pool\$1name\$1  | 
|  PoolRunningSlots  |  pool.running\$1slots.\$1pool\$1name\$1  |  計數  |  集區，\$1pool\$1name\$1  | 
|  ProcessorTimeouts  |  dag\$1processing.processor\$1timeouts  |  計數  |  函數、DAG 處理  | 
|  QueuedTasks  |  executor.queued\$1tasks  |  計數  |  函數、執行器  | 
|  RunningTasks  |  executor.running\$1tasks  |  計數  |  函數、執行器  | 
|  TasksExecutable  |  scheduler.tasks.executable  |  計數  |  函數、排程器  | 
|  TasksPending  不適用於 Apache Airflow v2.2 和更新版本。   |  scheduler.tasks.pending  |  計數  |  函數、排程器  | 
|  TasksRunning  |  scheduler.tasks.running  |  計數  |  函數、排程器  | 
|  TasksStarving  |  scheduler.tasks.starving  |  計數  |  函數、排程器  | 
|  TasksWithoutDagRun  |  scheduler.tasks.without\$1dagrun  |  計數  |  函數、排程器  | 
|  DAGFileProcessingLastNumOfDbQueries  適用於 Apache Airflow 2.10.1 版及更新版本。  |  dag\$1processing.last\$1num\$1of\$1db\$1queries.\$1dag\$1filename\$1  |  計數  |  DAG 檔案名稱，\$1dag\$1filename\$1  | 
|  PoolScheduledSlots  適用於 Apache Airflow 2.10.1 版及更新版本。   |  pool.scheduled\$1slots.\$1pool\$1name\$1  |  計數  |  集區，\$1pool\$1name\$1  | 
|  TaskCpuUsage  Apache Airflow 2.10.1 版及更新版本中提供。  |  cpu.usage.\$1dag\$1id\$1.\$1task\$1id\$1  |  百分比  |  DAG、\$1dag\$1id\$1 任務，\$1task\$1id\$1  | 
|  TaskMemoryUsage  Apache Airflow 2.10.1 版及更新版本中提供。  |  mem.usage.\$1dag\$1id\$1.\$1task\$1id\$1  |  百分比  |  DAG、\$1dag\$1id\$1 任務，\$1task\$1id\$1  | 

### Apache Airflow 計時器
<a name="timers-metrics"></a>

本節中的 Apache Airflow 指標包含有關 [Apache Airflow *計時器*](https://airflow.apache.org/docs/apache-airflow/stable/administration-and-deployment/logging-monitoring/metrics.html#timers)的資料。


| CloudWatch 指標 | Apache Airflow 指標 | 單位 | 維度 | 
| --- | --- | --- | --- | 
|  CollectDBDags  |  collect\$1db\$1dags  |  毫秒  |  函數、DAG 處理  | 
|  CriticalSectionDuration  |  scheduler.critical\$1section\$1duration  |  毫秒  |  函數、排程器  | 
|  CriticalSectionQueryDuration  適用於 Apache Airflow 2.5.1 版及更新版本。   |  scheduler.critical\$1section\$1query\$1duration  |  毫秒  |  函數、排程器  | 
|  DAGDependencyCheck  |  dagrun.dependency-check.\$1dag\$1id\$1  |  毫秒  |  DAG、\$1dag\$1id\$1  | 
|  DAGDurationFailed  |  dagrun.duration.failed.\$1dag\$1id\$1  |  毫秒  |  DAG、\$1dag\$1id\$1  | 
|  DAGDurationSuccess  |  dagrun.duration.success.\$1dag\$1id\$1  |  毫秒  |  DAG、\$1dag\$1id\$1  | 
|  DAGFileProcessingLastDuration  |  dag\$1processing.last\$1duration.\$1dag\$1filename\$1  |  秒鐘  |  DAG 檔案名稱，\$1dag\$1filename\$1  | 
|  DAGScheduleDelay  |  dagrun.schedule\$1delay.\$1dag\$1id\$1  |  毫秒  |  DAG、\$1dag\$1id\$1  | 
|  FirstTaskSchedulingDelay  |  dagrun.\$1dag\$1id\$1.first\$1task\$1scheduling\$1delay  |  毫秒  |  DAG、\$1dag\$1id\$1  | 
|  SchedulerLoopDuration  適用於 Apache Airflow 2.5.1 版及更新版本。   |  scheduler.scheduler\$1loop\$1duration  |  毫秒  |  函數、排程器  | 
|  TaskInstanceDuration  |  dag.\$1dag\$1id\$1.\$1task\$1id\$1.duration  |  毫秒  |  DAG、\$1dag\$1id\$1 任務，\$1task\$1id\$1  | 
|  TaskInstanceQueuedDuration  |  dag.`{dag_id}`.`{task_id}`queued\$1duration  適用於 Apache Airflow 2.7.2 版及更新版本。   |  毫秒  |  DAG、\$1dag\$1id\$1 任務，\$1task\$1id\$1  | 
|  TaskInstanceScheduledDuration  適用於 Apache Airflow 2.7.2 版及更新版本。   |  dag.`{dag_id}``{task_id}`.scheduled\$1duration  |  毫秒  |  DAG、\$1dag\$1id\$1 任務，\$1task\$1id\$1  | 

## 選擇報告哪些指標
<a name="choosing-metrics"></a>

您可以使用下列 Amazon MWAA [組態選項](configuring-env-variables.md)，選擇向 CloudWatch 發出或由 Apache Airflow 封鎖的 Apache Airflow 指標：
+ **`metrics.metrics_allow_list`** — 逗號分隔的字首清單，可用來選取環境向 CloudWatch 發出的指標。如果您希望 Apache Airflow 不傳送所有可用的指標，而是選取元素子集，請使用此選項。例如 `scheduler,executor,dagrun`。
+ **`metrics.metrics_block_list`** — 逗號分隔字首清單，用於篩選以清單元素開頭的指標。例如 `scheduler,executor,dagrun`。

如果您同時設定 `metrics.metrics_allow_list`和 `metrics.metrics_block_list`，Apache Airflow 會忽略 `metrics.metrics_block_list`。如果您設定 `metrics.metrics_block_list` 但未設定 `metrics.metrics_allow_list`，Apache Airflow 會篩選掉您在 中指定的元素`metrics.metrics_block_list`。

**注意**  
`metrics.metrics_allow_list` 和 `metrics.metrics_block_list`組態選項僅適用於 Apache Airflow v2.6.3 和更新版本。對於舊版 Apache Airflow，請`metrics.statsd_block_list`改用 `metrics.statsd_allow_list`和 。

## 後續步驟？
<a name="mwaa-metrics202-next-up"></a>
+ 探索用於在 [PublishMetrics](https://docs.aws.amazon.com/mwaa/latest/API/API_PublishMetrics.html) 發佈環境運作狀態指標的 Amazon MWAA API 操作。

# Amazon MWAA 的容器、佇列和資料庫指標
<a name="accessing-metrics-cw-container-queue-db"></a>

除了 Apache Airflow 指標之外，您還可以使用 CloudWatch 監控 Amazon Managed Workflows for Apache Airflow 環境的基礎元件，其會收集原始資料並將資料處理為可讀且幾近即時的指標。透過這些環境指標，您將更清楚了解關鍵效能指標，協助您適當地調整環境大小，並偵錯工作流程的問題。這些指標適用於 Amazon MWAA 上所有支援的 Apache Airflow 版本。



Amazon MWAA 將為每個 Amazon Elastic Container Service (Amazon ECS) 容器和 Amazon Aurora PostgreSQL 執行個體提供 CPU 和記憶體使用率，以及為最舊訊息數量和存留期提供 Amazon Simple Queue Service (Amazon SQS) 指標、為資料庫連線提供 Amazon Relational Database Service (Amazon RDS) 指標、磁碟佇列深度、寫入操作、延遲和輸送量，以及 Amazon RDS Proxy 指標。這些指標也包含基礎工作者、其他工作者、排程器和 Web 伺服器的數量。

這些統計資料會保留 15 個月，因此您可以存取歷史資訊，並更清楚排程失敗的原因，以及對基礎問題進行疑難排解。您也可以設定監控特定閾值的警示，並在達到這些閾值時傳送通知或採取動作。如需詳細資訊，請參閱 [Amazon CloudWatch 使用者指南](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/)。

**Topics**
+ [條款](#accessing-metrics-cw-container-queue-db-terms)
+ [維度](#accessing-metrics-cw-container-queue-db-dimensions)
+ [在 CloudWatch 主控台中存取指標](#accessing-metrics-cw-container-queue-db-console)
+ [指標清單](#accessing-metrics-cw-container-queue-db-list)

## 條款
<a name="accessing-metrics-cw-container-queue-db-terms"></a>

**命名空間**  
命名空間是 AWS 服務的 CloudWatch 指標的容器。對於 Amazon MWAA，命名空間為 `AWS/MWAA`。

**CloudWatch 指標**  
CloudWatch 指標代表 CloudWatch 特有的一組按時間順序排列的資料點。

**維度**  
維度是一組名稱值對，是指標身分的一部分。

**單位**  
統計資料具有度量單位。對於 Amazon MWAA，單位包含*計數*。

## 維度
<a name="accessing-metrics-cw-container-queue-db-dimensions"></a>

本節說明 CloudWatch 中 Amazon MWAA 指標的 CloudWatch 維度分組。


| 維度 | Description | 
| --- | --- | 
|  叢集  |  Amazon MWAA 環境用來執行 Apache Airflow 元件的最少三個 Amazon ECS 容器的指標：排程器、工作者和 Web 伺服器。  | 
|  佇列  |  將排程器與工作者分離的 Amazon SQS 佇列指標。當工作者讀取訊息時，它們會被視為進行中，不適用於其他工作者。如果在 12 小時可見性逾時之前未刪除訊息，其他工作者即可讀取訊息。  | 
|  資料庫  |  Amazon MWAA 使用的 Aurora 叢集指標。這包括主要資料庫執行個體的指標，以及支援讀取操作的僅供讀取複本。Amazon MWAA 會同時發佈 READER 和 WRITER 執行個體的資料庫指標。  | 

## 在 CloudWatch 主控台中存取指標
<a name="accessing-metrics-cw-container-queue-db-console"></a>

本節說明如何在 CloudWatch 中存取 Amazon MWAA 指標。

**存取維度的效能指標**

1. 在 CloudWatch 主控台上開啟[指標頁面](https://console.aws.amazon.com/cloudwatch/home#metricsV2:graph=~())。

1. 選取您的 AWS 區域。

1. 選擇 **AWS/MWAA** 命名空間。

1. **在所有指標**索引標籤中，選擇維度。例如，**叢集**。

1. 選擇維度的 CloudWatch 指標。例如，*NumSchedulers* 或 *CPUUtilization*。然後，選擇繪製**所有搜尋結果的圖形**。

1. 選擇**圖形化指標**索引標籤以存取效能指標。

## 指標清單
<a name="accessing-metrics-cw-container-queue-db-list"></a>

下表列出 Amazon MWAA 的叢集、佇列和資料庫服務指標。若要存取直接從 Amazon ECS、Amazon SQS 或 Amazon RDS 發出的指標描述，請選擇個別的文件連結。

**Topics**
+ [叢集指標](#container-list)
+ [資料庫指標](#db-list)
+ [佇列指標](#queue-list)
+ [Application Load Balancer 指標](#alb-list)

### 叢集指標
<a name="container-list"></a>

下列指標適用於每個排程器、基礎工作者、其他工作者和 Web 伺服器。如需每個叢集指標的詳細資訊和說明，請參閱《*Amazon ECS 開發人員指南*》中的[可用指標和維度](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/cloudwatch-metrics.html#available_cloudwatch_metrics)。


| 命名空間 | 指標 | 單位 | 
| --- | --- | --- | 
|  `AWS/MWAA`  |  `CPUUtilization`  |  百分比  | 
|  `AWS/MWAA`  |  `MemoryUtilization`  |  百分比  | 

#### 評估其他工作者和 Web 伺服器容器的數量
<a name="additional-worker-scheduler-sample-count"></a>

您可以使用**叢集**維度中提供的元件指標，如下列程序所述，來評估環境在特定時間點使用多少額外工作者或 Web 伺服器。您可以透過繪製 **CPUUtilization** 或 **MemoryUtilization** 指標的圖形，並將統計資料類型設定為**範例計數**來執行此操作。產生的值是`AdditionalWorker`元件`RUNNING`的任務總數。了解您環境使用的其他工作者執行個體數量，可協助您判斷環境如何擴展，並且您可以使用 來最佳化其他工作者的數量。

------
#### [ Workers ]

**使用 評估其他工作者的數量 AWS 管理主控台**

1. 選擇 **AWS/MWAA** 命名空間。

1. **在所有指標**索引標籤中，選擇**叢集**維度。

1. 在**叢集**維度中，針對 **AdditionalWorker**，選擇 **CPUUtilization** 或 **MemoryUtilization** 指標。

1. 在**圖形化指標**索引標籤上，將**期間**設定為 **1 分鐘**，將**統計資料**設定為**範例計數**。

------
#### [ webservers ]

**使用 評估其他 Web 伺服器的數量 AWS 管理主控台**

1. 選擇 **AWS/MWAA** 命名空間。

1. **在所有指標**索引標籤中，選擇**叢集**維度。

1. 在**叢集**維度中，針對 **AdditionalWebservers**，選擇 **CPUUtilization** 或 **MemoryUtilization** 指標。

1. 在**圖形化指標**索引標籤上，將**期間**設定為 **1 分鐘**，**將統計資料**設定為**範例計數**。

------

如需詳細資訊，請參閱《*Amazon Elastic Container Service 開發人員指南*》中的服務[`RUNNING`任務計數](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/cloudwatch-metrics.html#cw_running_task_count)。

### 資料庫指標
<a name="db-list"></a>

下列指標適用於與 Amazon MWAA 環境相關聯的每個資料庫執行個體。


| 命名空間 | 指標 | 單位 | 
| --- | --- | --- | 
|  `AWS/MWAA`  |  `CPUUtilization`  |  百分比  | 
|  `AWS/MWAA`  |  `DatabaseConnections`  |  計數  | 
|  `AWS/MWAA`  |  `DiskQueueDepth`  |  計數  | 
|  `AWS/MWAA`  |  `FreeableMemory`  |  位元組  | 
|  `AWS/MWAA`  |  `VolumeWriteIOPS`  |  每五分鐘計數  | 
|  `AWS/MWAA`  |  `WriteIOPS`  |  每秒計數  | 
|  `AWS/MWAA`  |  `WriteLatency`  |  秒鐘  | 
|  `AWS/MWAA`  |  `WriteThroughput`  |  每秒位元組數  | 

### 佇列指標
<a name="queue-list"></a>

如需下列佇列指標之單位和說明的詳細資訊，請參閱《[Amazon Simple Queue Service 開發人員指南》中的 Amazon SQS 的可用 CloudWatch 指標](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-available-cloudwatch-metrics.html)。 **


| 命名空間 | 指標 | 單位 | 
| --- | --- | --- | 
|  `AWS/MWAA`  |  `ApproximateAgeOfOldestTask`  |  秒鐘  | 
|  `AWS/MWAA`  |  `RunningTasks`  |  計數  | 
|  `AWS/MWAA`  |  `QueuedTasks`  |  計數  | 

### Application Load Balancer 指標
<a name="alb-list"></a>

Application Load Balancer 指標適用於您環境中執行的 Web 伺服器。Amazon MWAA 使用這些指標到 ，根據流量擴展您的 Web 伺服器。如需下列負載平衡器指標的單位和說明詳細資訊，請參閱《[Application Load Balancer 使用者指南》中的 Application Load Balancer 的 CloudWatch 指標](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-cloudwatch-metrics.html)。 **


| 命名空間 | 指標 | 單位 | 
| --- | --- | --- | 
|  `AWS/MWAA`  |  `ActiveConnectionCount`  |  計數  | 