

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

# 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 操作。