

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

# 設定 AWS ParallelCluster 的 Grafana 監控儀表板
<a name="set-up-a-grafana-monitoring-dashboard-for-aws-parallelcluster"></a>

*Dario La Porta 和 William Lu，Amazon Web Services*

## 總結
<a name="set-up-a-grafana-monitoring-dashboard-for-aws-parallelcluster-summary"></a>

AWS ParallelCluster 可協助您部署和管理高效能運算 (HPC) 叢集。它支援 AWS Batch 和 Slurm 開放原始碼任務排程器。雖然 AWS ParallelCluster 已與 Amazon CloudWatch 整合，用於記錄和指標，但不會為工作負載提供監控儀表板。

[AWS ParallelCluster (GitHub) 的 Grafana 儀表板](https://github.com/aws-samples/aws-parallelcluster-monitoring)是 AWS ParallelCluster 的監控儀表板。 GitHub 它在作業系統 (OS) 層級提供任務排程器洞察和詳細監控指標。如需此解決方案中包含之儀表板的詳細資訊，請參閱 GitHub 儲存庫中[的範例儀表板](https://github.com/aws-samples/aws-parallelcluster-monitoring#example-dashboards)。這些指標可協助您進一步了解 HPC 工作負載及其效能。不過，最新版本的 AWS ParallelCluster 或解決方案中使用的開放原始碼套件不會更新儀表板程式碼。此模式可增強解決方案，以提供下列優點：
+ 支援 AWS ParallelCluster v3
+ 使用最新版本的開放原始碼套件，包括 Prometheus、Grafana、Prometheus Slurm Exporter 和 NVIDIA DCGM-Exporter
+ 增加 Slurm 任務使用的 CPU 核心和 GPUs 數量
+ 新增任務監控儀表板
+ 為具有 4 或 8 個圖形處理單元 (GPUs) 的節點增強 GPU 節點監控儀表板

此增強型解決方案版本已在 AWS 客戶的 HPC 生產環境中實作和驗證。

## 先決條件和限制
<a name="set-up-a-grafana-monitoring-dashboard-for-aws-parallelcluster-prereqs"></a>

**先決條件**
+ [AWS ParallelCluster CLI](https://docs.aws.amazon.com/parallelcluster/latest/ug/pcluster-v3.html)，已安裝並設定。
+ AWS ParallelCluster 支援[的網路組態](https://docs.aws.amazon.com/parallelcluster/latest/ug/iam-roles-in-parallelcluster-v3.html)。此模式使用 [AWS ParallelCluster 使用兩個子網路](https://docs.aws.amazon.com/parallelcluster/latest/ug/network-configuration-v3.html#network-configuration-v3-two-subnets)組態，需要公有子網路、私有子網路、網際網路閘道和 NAT 閘道。
+ 所有 AWS ParallelCluster 叢集節點都必須具有網際網路存取權。這是必要的，以便安裝指令碼可以下載開放原始碼軟體和 Docker 映像。
+ Amazon Elastic Compute Cloud (Amazon EC2) 中的[金鑰對](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html)。具有此金鑰對的資源具有前端節點的安全殼層 (SSH) 存取權。

**限制**
+ 此模式旨在支援 Ubuntu 20.04 LTS。如果您使用的是不同版本的 Ubuntu，或是使用 Amazon Linux 或 CentOS，則需要修改此解決方案隨附的指令碼。這些修改不包含在此模式中。

**產品版本**
+ Ubuntu 20.04 LTS
+ ParallelCluster 3.X

**帳單和成本考量**
+ 免費方案不會涵蓋在此模式中部署的解決方案。Amazon EC2、Amazon FSx for Lustre、Amazon VPC 中的 NAT 閘道和 Amazon Route 53 需支付費用。

## Architecture
<a name="set-up-a-grafana-monitoring-dashboard-for-aws-parallelcluster-architecture"></a>

**目標架構**

下圖顯示使用者如何存取前端節點上 AWS ParallelCluster 的監控儀表板。前端節點執行 NICE DCV、Prometheus、Grafana、Prometheus Slurm Exporter、Prometheus Node Exporter 和 NGINX Open Source。運算節點會執行 Prometheus Node Exporter，如果節點包含 GPUs，也會執行 NVIDIA DCGM-Exporter。前端節點會從運算節點擷取資訊，並在 Grafana 儀表板中顯示該資料。

![\[存取前端節點上 AWS ParallelCluster 的監控儀表板。\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/images/pattern-img/a2132c94-98e0-4b90-8be0-99ebfa546442/images/d2255792-f66a-4ef2-8f04-cc3d5482db5f.png)


在大多數情況下，前端節點不會大量載入，因為任務排程器不需要大量的 CPU 或記憶體。使用者在連接埠 443 上使用 SSL 存取前端節點上的儀表板。

所有授權檢視者都可以匿名檢視監控儀表板。只有 Grafana 管理員可以修改儀表板。您可以在 `aws-parallelcluster-monitoring/docker-compose/docker-compose.head.yml` 檔案中設定 Grafana 管理員的密碼。

## 工具
<a name="set-up-a-grafana-monitoring-dashboard-for-aws-parallelcluster-tools"></a>

**AWS 服務**
+ [NICE DCV](https://docs.aws.amazon.com/dcv/#nice-dcv) 是一種高效能遠端顯示通訊協定，可協助您在不同的網路條件下，將遠端桌面和應用程式串流從任何雲端或資料中心交付到任何裝置。
+ [AWS ParallelCluster](https://docs.aws.amazon.com/parallelcluster/latest/ug/what-is-aws-parallelcluster.html) 可協助您部署和管理高效能運算 (HPC) 叢集。它支援 AWS Batch 和 Slurm 開放原始碼任務排程器。
+ [Amazon Simple Storage Service (Amazon S3)](https://docs.aws.amazon.com/AmazonS3/latest/userguide/Welcome.html) 是一種雲端型物件儲存服務，可協助您儲存、保護和擷取任何數量的資料。
+ [Amazon Virtual Private Cloud (Amazon VPC)](https://docs.aws.amazon.com/vpc/latest/userguide/what-is-amazon-vpc.html) 可協助您在已定義的虛擬網路中啟動 AWS 資源。

**其他工具**
+ [Docker](https://www.docker.com/) 是一組平台即服務 (PaaS) 產品，可在作業系統層級使用虛擬化在容器中交付軟體。
+ [Grafana](https://grafana.com/docs/grafana/latest/introduction/) 是一種開放原始碼軟體，可協助您查詢、視覺化、提醒和探索指標、日誌和追蹤。
+ [NGINX 開放原始碼](https://nginx.org/en/docs/?_ga=2.187509224.1322712425.1699399865-405102969.1699399865)是開放原始碼 Web 伺服器和反向代理。
+ [NVIDIA Data Center GPU Manager (DCGM)](https://docs.nvidia.com/data-center-gpu-manager-dcgm/index.html) 是一組工具，可用於管理和監控叢集環境中的 NVIDIA 資料中心圖形處理單元 (GPUs)。在此模式中，您會使用 [DCGM-Exporter](https://github.com/NVIDIA/dcgm-exporter)，這可協助您從 Prometheus 匯出 GPU 指標。
+ [Prometheus](https://prometheus.io/docs/introduction/overview/) 是一種開放原始碼系統監控工具組，可收集並儲存其指標，做為具有相關鍵值對的時間序列資料，稱為*標籤*。在此模式中，您也使用 [Prometheus Slurm Exporter](https://github.com/vpenso/prometheus-slurm-exporter) 收集和匯出指標，並使用 [Prometheus Node Exporter](https://github.com/prometheus/node_exporter) 從運算節點匯出指標。
+ [Ubuntu](https://help.ubuntu.com/) 是一種開放原始碼的 Linux 作業系統，專為企業伺服器、桌面、雲端環境和 IoT 而設計。

**程式碼儲存庫**

此模式的程式碼可在 GitHub [pcluster-monitoring-dashboard](https://github.com/aws-samples/parallelcluster-monitoring-dashboard) 儲存庫中使用。

## 史詩
<a name="set-up-a-grafana-monitoring-dashboard-for-aws-parallelcluster-epics"></a>

### 建立必要的資源
<a name="create-the-required-resources"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 建立 S3 儲存貯體。 | 建立 Amazon S3 儲存貯體。您可以使用此儲存貯體來存放組態指令碼。如需說明，請參閱 Amazon S3 文件中的[建立儲存貯](https://docs.aws.amazon.com/AmazonS3/latest/userguide/create-bucket-overview.html)體。 | 一般 AWS | 
| 複製儲存庫。 | 執行下列命令，複製 GitHub [pcluster-monitoring-dashboard](https://github.com/aws-samples/parallelcluster-monitoring-dashboard/tree/main/aws-parallelcluster-monitoring) 儲存庫。<pre>git clone https://github.com/aws-samples/parallelcluster-monitoring-dashboard.git</pre> | DevOps 工程師 | 
| 建立管理員密碼。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/set-up-a-grafana-monitoring-dashboard-for-aws-parallelcluster.html) | Linux Shell 指令碼 | 
| 將必要的檔案複製到 S3 儲存貯體。 | 將 [post\$1install.sh](https://github.com/aws-samples/parallelcluster-monitoring-dashboard/blob/main/post_install.sh) 指令碼和 [aws-parallelcluster-monitoring](https://github.com/aws-samples/parallelcluster-monitoring-dashboard/tree/main/aws-parallelcluster-monitoring) 資料夾複製到您建立的 S3 儲存貯體。如需說明，請參閱 [Amazon S3 文件中的上傳物件](https://docs.aws.amazon.com/AmazonS3/latest/userguide/upload-objects.html)。 Amazon S3  | 一般 AWS | 
| 為前端節點設定額外的安全群組。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/set-up-a-grafana-monitoring-dashboard-for-aws-parallelcluster.html) | AWS 管理員 | 
| 設定前端節點的 IAM 政策。 | 為前端節點建立身分型政策。此政策允許節點從 Amazon CloudWatch 擷取指標資料。GitHub 儲存庫包含範例[政策](https://github.com/aws-samples/parallelcluster-monitoring-dashboard/blob/main/policies/head_node.json)。如需說明，請參閱 AWS Identity and Access Management [(IAM) 文件中的建立 IAM 政策](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_create.html)。 | AWS 管理員 | 
| 設定運算節點的 IAM 政策。 | 為運算節點建立身分型政策。此政策允許節點建立包含任務 ID 和任務擁有者的標籤。GitHub 儲存庫包含範例[政策](https://github.com/aws-samples/parallelcluster-monitoring-dashboard/blob/main/policies/compute_node.json)。如需說明，請參閱 [IAM 文件中的建立 IAM 政策](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_create.html)。如果您使用提供的範例檔案，請取代下列值：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/set-up-a-grafana-monitoring-dashboard-for-aws-parallelcluster.html) | AWS 管理員 | 

### 建立叢集
<a name="create-the-cluster"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 修改提供的叢集範本檔案。 | 建立 AWS ParallelCluster 叢集。使用提供的 [cluster.yaml](https://github.com/aws-samples/parallelcluster-monitoring-dashboard/blob/main/cluster.yaml) AWS CloudFormation 範本檔案作為建立叢集的起點。在提供的範本中取代下列值：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/set-up-a-grafana-monitoring-dashboard-for-aws-parallelcluster.html) | AWS 管理員 | 
| 建立 叢集 | 在 AWS ParallelCluster CLI 中，輸入下列命令。這會部署 CloudFormation 範本並建立叢集。如需此命令的詳細資訊，請參閱 AWS [ParallelCluster 文件中的 pcluster create-cluster](https://docs.aws.amazon.com/parallelcluster/latest/ug/pcluster.create-cluster-v3.html)。 ParallelCluster <pre>pcluster create-cluster -n <cluster_name> -c cluster.yaml</pre> | AWS 管理員 | 
| 監控叢集建立。 | 輸入下列命令來監控叢集建立。如需此命令的詳細資訊，請參閱 AWS [ParallelCluster 文件中的 pcluster describe-cluster](https://docs.aws.amazon.com/parallelcluster/latest/ug/pcluster.describe-cluster-v3.html)。 ParallelCluster <pre>pcluster describe-cluster -n <cluster_name></pre> | AWS 管理員 | 

### 使用 Grafana 儀表板
<a name="using-the-grafana-dashboards"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 存取 Grafana 入口網站。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/set-up-a-grafana-monitoring-dashboard-for-aws-parallelcluster.html) | AWS 管理員 | 

### 清除解決方案以停止產生相關聯的成本
<a name="clean-up-the-solution-to-stop-incurring-associated-costs"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 刪除叢集。 | 輸入下列命令來刪除叢集。如需此命令的詳細資訊，請參閱 AWS ParallelCluster 文件中的 [pcluster delete-cluster](https://docs.aws.amazon.com/parallelcluster/latest/ug/pcluster.delete-cluster-v3.html)。 ParallelCluster <pre>pcluster delete-cluster -n <cluster_name></pre> | AWS 管理員 | 
| 刪除 IAM 政策。 | 刪除您為前端節點和運算節點建立的政策。如需刪除政策的詳細資訊，請參閱 [IAM 文件中的刪除 IAM 政策](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_manage-delete.html)。 | AWS 管理員 | 
| 刪除安全群組和規則。 | 刪除您為前端節點建立的安全群組。如需詳細資訊，請參閱 Amazon VPC 文件中的[刪除安全群組規則](https://docs.aws.amazon.com/vpc/latest/userguide/working-with-security-groups.html#deleting-security-group-rules)和[刪除安全群組](https://docs.aws.amazon.com/vpc/latest/userguide/working-with-security-groups.html#deleting-security-groups)。 | AWS 管理員 | 
| 刪除 S3 儲存貯體。 | 刪除您建立來存放組態指令碼的 S3 儲存貯體。如需詳細資訊，請參閱 Amazon S3 文件中的[刪除儲存貯](https://docs.aws.amazon.com/AmazonS3/latest/userguide/delete-bucket.html)體。 | 一般 AWS | 

## 疑難排解
<a name="set-up-a-grafana-monitoring-dashboard-for-aws-parallelcluster-troubleshooting"></a>


| 問題 | 解決方案 | 
| --- | --- | 
| 無法在瀏覽器中存取前端節點。 | 檢查安全群組並確認傳入連接埠 443 已開啟。 | 
| Grafana 未開啟。 | 在前端節點上，檢查 的容器日誌`docker logs Grafana`。 | 
| 有些指標沒有資料。 | 在前端節點上，檢查所有容器的容器日誌。 | 

## 相關資源
<a name="set-up-a-grafana-monitoring-dashboard-for-aws-parallelcluster-resources"></a>

**AWS 文件**
+ [適用於 Amazon EC2 的 IAM 政策](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-policies-for-amazon-ec2.html)

**其他 AWS 資源**
+ [AWS ParallelCluster](https://aws.amazon.com/hpc/parallelcluster/)
+ [AWS ParallelCluster 的監控儀表板](https://aws.amazon.com/blogs/compute/monitoring-dashboard-for-aws-parallelcluster/) (AWS 部落格文章）

**其他資源**
+ [Prometheus 監控系統](https://prometheus.io/)
+ [格拉法納](https://grafana.com/)