

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

# 將警示管理員組態檔案上傳至 Amazon Managed Service for Prometheus
<a name="AMP-alertmanager-upload"></a>

在警示管理員組態檔案中了解您想要的內容後，您可以在 主控台中建立和編輯該檔案，也可以使用 Amazon Managed Service for Prometheus 主控台或 上傳現有檔案 AWS CLI。

**注意**  
如果您正在執行 Amazon EKS 叢集，您也可以使用 [AWS Kubernetes 的控制器](integrating-ack.md)上傳警示管理員組態檔案。

**使用 Amazon Managed Service for Prometheus 主控台編輯或取代警示管理員組態**

1. 開啟 Amazon Managed Service for Prometheus 主控台，位於 [https://console.aws.amazon.com/prometheus/](https://console.aws.amazon.com/prometheus/home)。

1. 選擇頁面左上角的功能表圖示，然後選擇**所有工作區**。

1. 選擇工作區的工作區 ID，然後選擇**警示管理員**索引標籤。

1. 如果工作區尚無警示管理員定義，請選擇**新增定義**。
**注意**  
如果工作區有您要取代的警示管理員定義，請改為選擇**修改**。

1. 選取**選擇檔案**、選取警示管理員定義檔案，然後選擇**繼續**。
**注意**  
或者，您也可以選擇建立**定義**選項，在主控台中直接建立新的檔案並進行編輯。這將建立您在上傳之前編輯的範例預設組態。

**第一次使用 AWS CLI 將警示管理員組態上傳至工作區**

1. Base64 會對警示管理員檔案的內容進行編碼。在 Linux 系統上，您可使用下列命令：

   ```
   base64 input-file output-file
   ```

   在 macOS 系統上，您可使用下列命令：

   ```
   openssl base64 input-file output-file
   ```

1. 若要上傳檔案，請輸入下列其中一個命令。

   在第 2 AWS CLI 版上，輸入：

   ```
   aws amp create-alert-manager-definition --data file://path_to_base_64_output_file --workspace-id my-workspace-id --region region
   ```

   在第 1 AWS CLI 版上，輸入：

   ```
   aws amp create-alert-manager-definition --data fileb://path_to_base_64_output_file --workspace-id my-workspace-id --region region
   ```

1. 警示管理員組態需要幾秒鐘才會變成啟用中。若要檢查狀態，請輸入以下命令：

   ```
   aws amp describe-alert-manager-definition --workspace-id workspace_id --region region
   ```

   如果 `status` 是 `ACTIVE`，則您的新警示管理員定義已生效。

**使用 AWS CLI 將工作區的警示管理員組態取代為新的警示管理員組態**

1. Base64 會對警示管理員檔案的內容進行編碼。在 Linux 系統上，您可使用下列命令：

   ```
   base64 input-file output-file
   ```

   在 macOS 系統上，您可使用下列命令：

   ```
   openssl base64 input-file output-file
   ```

1. 若要上傳檔案，請輸入下列其中一個命令。

   在第 2 AWS CLI 版上，輸入：

   ```
   aws amp put-alert-manager-definition --data file://path_to_base_64_output_file --workspace-id my-workspace-id --region region
   ```

   在第 1 AWS CLI 版上，輸入：

   ```
   aws amp put-alert-manager-definition --data file://path_to_base_64_output_file --workspace-id my-workspace-id --region region
   ```

1. 新的警示管理員組態需要幾秒鐘才會變成啟用中。若要檢查狀態，請輸入以下命令：

   ```
   aws amp describe-alert-manager-definition --workspace-id workspace_id --region region
   ```

   如果 `status` 是 `ACTIVE`，則您的新警示管理員定義已生效。在那之前，您先前的警示管理員組態仍為啟用中。