

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

# 將標籤新增至規則群組命名空間
<a name="how-to-tag-rule-groups-namespace-add"></a>

將標籤新增至 Amazon Managed Service for Prometheus 規則群組命名空間，可協助您識別和組織資源，並管理對這些 AWS 資源的存取。首先，將一或多個標籤 (金鑰值對) 新增到規則群組命名空間。當您擁有標籤後，可以根據這些標籤建立 IAM 政策，以管理專案的存取權。您可以使用 主控台或 AWS CLI ，將標籤新增至 Amazon Managed Service for Prometheus 規則群組命名空間。

**重要**  
將標記新增至規則群組命名空間可能會影響該規則群組命名空間的存取權。在您新增標籤前，請務必確認檢閱任何可能會使用標籤控制存取資源的 IAM 政策。

如需在建立政策時，將標籤新增至規則群組命名空間的詳細資訊，請參閱 [建立規則檔案](AMP-ruler-rulesfile.md)。

**Topics**
+ [將標籤新增至規則群組命名空間 (主控台)](#how-to-tag-rule-groups-namespace-add-console)
+ [將標籤新增至規則群組命名空間 (AWS CLI)](#how-to-tag-rule-groups-namespace-add-cli)

## 將標籤新增至規則群組命名空間 (主控台)
<a name="how-to-tag-rule-groups-namespace-add-console"></a>

您可以使用主控台為 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. 選擇**所有工作區**。

1. 選擇您要管理工作區的工作區 ID。

1. 選擇「**規則管理**」標籤。

1. 選擇命名空間名稱旁的按鈕，然後選擇「**編輯**」。

1. 選擇「**建立標籤**」，「**新增標籤**」。

1. 在 **Key (金鑰)** 中，輸入標籤的名稱。您可以在 **Value (值)** 中為標籤新增選用值。

1. (選用) 若要新增另一個標籤，請再選擇「**Add tag (新增標籤)**」一次。

1. 當您完成新增標籤時，請選擇**儲存變更**。

## 將標籤新增至規則群組命名空間 (AWS CLI)
<a name="how-to-tag-rule-groups-namespace-add-cli"></a>

請依照下列步驟，使用 AWS CLI 將標籤新增至 Amazon Managed Service for Prometheus 規則群組命名空間。若要在建立標籤時將其新增至規則群組命名空間，請參閱 [將規則組態檔案上傳至 Amazon Managed Service for Prometheus](AMP-rules-upload.md)。

在這些步驟中，我們假設您已安裝最新版本的 AWS CLI 或已更新至目前版本。如需詳細資訊，請參閱[安裝 AWS Command Line Interface](https://docs.aws.amazon.com/cli/latest/userguide/installing.html)。

在終端機或命令列，執行 **tag-resource** 命令，為您要新增標籤的規則群組命名空間指定 Amazon Resource Name (ARN)，以及您想新增標籤的索引鍵和值。您可以將多個標記新增至規則群組命名空間。例如，若要使用兩個標籤來標記名為 **My-Workspace** 的 Amazon Managed Service for Prometheus 命名空間，一個名為 *Status* 的標籤金鑰，以及一個名為 *Team* 的標籤金鑰，兩個標籤金鑰的標籤值為 *Secret* 和 *My-Team*：

```
aws amp tag-resource \
    --resource-arn arn:aws:aps:us-west-2:123456789012:rulegroupsnamespace/IDstring/namespace_name \
    --tags Status=Secret,Team=My-Team
```

若成功，此命令不會傳回任何內容。