

• 2026 年 4 月 30 日之後將不再提供 AWS Systems Manager CloudWatch Dashboard。客戶可以繼續使用 Amazon CloudWatch 主控台來檢視、建立和管理其 Amazon CloudWatch 儀表板，就像現在一樣。如需詳細資訊，請參閱 [Amazon CloudWatch Dashboard 文件](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Dashboards.html)。

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

# 手動建立 OpsItems (AWS CLI)
<a name="OpsCenter-creating-OpsItems-CLI"></a>

下列處理程序說明如何使用 AWS Command Line Interface (AWS CLI) 建立 OpsItem。

**OpsItem 使用 建立 AWS CLI**

1. 如果您尚未安裝和設定 AWS Command Line Interface (AWS CLI)。

   如需相關資訊，請參閱[安裝或更新最新版本的 AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)。

1. 開啟 AWS CLI 並執行下列命令來建立 OpsItem。將每個{{範例資源預留位置}}取代為您自己的資訊。

   ```
   aws ssm create-ops-item \
       --title "{{Descriptive_title}}" \
       --description "{{Information_about_the_issue}}" \
       --priority {{Number_between_1_and_5}} \
       --source {{Source_of_the_issue}} \
       --operational-data {{Up_to_20_KB_of_data_or_path_to_JSON_file}} \
       --notifications Arn="{{SNS_ARN_in_same_Region}}" \
       --tags "Key={{key_name}},Value={{a_value}}"
   ```

   **從檔案指定營運資料**

   當您建立 OpsItem 時，您可以從檔案指定營運資料。這個檔案必須是 JSON 檔案，且檔案內容必須使用以下格式。

   ```
   {
     "{{key_name}}": {
       "Type": "SearchableString",
       "Value": "{{Up to 20 KB of data}}"
     }
   }
   ```

   請見此處範例。

   ```
   aws ssm create-ops-item ^
       --title "EC2 instance disk full" ^
       --description "Log clean up may have failed which caused the disk to be full" ^
       --priority 2 ^
       --source ec2 ^
       --operational-data file:///Users/TestUser1/Desktop/OpsItems/opsData.json ^
       --notifications Arn="arn:aws:sns:us-west-1:12345678:TestUser1" ^
       --tags "Key=EC2,Value=Production"
   ```
**注意**  
如需如何在不同的本機作業系統的命令列輸入 JSON 格式參數的資訊，請參閱《*AWS Command Line Interface 使用者指南*》中的[在 AWS CLI中搭配字串使用引號](https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-parameters-quoting-strings.html)。

   系統會傳回如下資訊。

   ```
   {
       "OpsItemId": "oi-1a2b3c4d5e6f"
   }
   ```

1. 執行以下命令來檢視您建立的 OpsItem 的詳細資訊。

   ```
   aws ssm get-ops-item --ops-item-id {{ID}}
   ```

   系統會傳回如下資訊。

   ```
   {
       "OpsItem": {
           "CreatedBy": "arn:aws:iam::12345678:user/TestUser",
           "CreatedTime": 1558386334.995,
           "Description": "Log clean up may have failed which caused the disk to be full",
           "LastModifiedBy": "arn:aws:iam::12345678:user/TestUser",
           "LastModifiedTime": 1558386334.995,
           "Notifications": [
               {
                   "Arn": "arn:aws:sns:us-west-1:12345678:TestUser"
               }
           ],
           "Priority": 2,
           "RelatedOpsItems": [],
           "Status": "Open",
           "OpsItemId": "oi-1a2b3c4d5e6f",
           "Title": "EC2 instance disk full",
           "Source": "ec2",
           "OperationalData": {
               "EC2": {
                   "Value": "12345",
                   "Type": "SearchableString"
               }
           }
       }
   }
   ```

1. 執行下列命令以更新 OpsItem。此命令會將狀態從 `Open` (預設值) 變更成 `InProgress`。

   ```
   aws ssm update-ops-item --ops-item-id {{ID}} --status InProgress
   ```

   此命令無輸出。

1. 再次執行以下命令，確認狀態是否已變更為 `InProgress`。

   ```
   aws ssm get-ops-item --ops-item-id {{ID}}
   ```

## 建立 OpsItem 的範例
<a name="OpsCenter_creating_OpsItems-CLI_examples"></a>

以下範例會說明如何使用 Linux 管理入口網站、macOS 或 Windows Server 建立 OpsItem。

**Linux 管理入口網站或 macOS**

以下命令會在 Amazon Elastic Compute Cloud (Amazon EC2) 執行個體磁碟已滿時建立 OpsItem。

```
aws ssm create-ops-item \
    --title "EC2 instance disk full" \
    --description "Log clean up may have failed which caused the disk to be full" \
    --priority 2 \
    --source ec2 \
    --operational-data '{"EC2":{"Value":"12345","Type":"SearchableString"}}' \
    --notifications Arn="arn:aws:sns:us-west-1:12345678:TestUser1" \
    --tags "Key=EC2,Value=ProductionServers"
```

以下命令會在 `OperationalData` 中使用 `/aws/resources` 金鑰，來建立含 Amazon DynamoDB 相關資源的 OpsItem。

```
aws ssm create-ops-item \
    --title "EC2 instance disk full" \
    --description "Log clean up may have failed which caused the disk to be full" \
    --priority 2 \
    --source ec2 \
    --operational-data '{"/aws/resources":{"Value":"[{\"arn\": \"arn:aws:dynamodb:us-west-2:12345678:table/OpsItems\"}]","Type":"SearchableString"}}' \
    --notifications Arn="arn:aws:sns:us-west-2:12345678:TestUser"
```

以下命令會在 `OperationalData` 中使用 `/aws/automations` 金鑰，來建立可將 `AWS-ASGEnterStandby` 文件指定為相關聯的 Automation 執行手冊的 OpsItem。

```
aws ssm create-ops-item \
    --title "EC2 instance disk full" \
    --description "Log clean up may have failed which caused the disk to be full" \
    --priority 2 \
    --source ec2 \
    --operational-data '{"/aws/automations":{"Value":"[{\"automationId\": \"AWS-ASGEnterStandby\", \"automationType\": \"AWS::SSM::Automation\"}]","Type":"SearchableString"}}' \
    --notifications Arn="arn:aws:sns:us-west-2:12345678:TestUser"
```

**Windows**

以下命令會在 Amazon Relational Database Service (Amazon RDS) 執行個體未回應時建立 OpsItem。

```
aws ssm create-ops-item ^
    --title "RDS instance not responding" ^
    --description "RDS instance not responding to ping" ^
    --priority 1 ^
    --source RDS ^
    --operational-data={\"RDS\":{\"Value\":\"abcd\",\"Type\":\"SearchableString\"}} ^
    --notifications Arn="arn:aws:sns:us-west-1:12345678:TestUser1" ^
    --tags "Key=RDS,Value=ProductionServers"
```

以下命令會在 `OperationalData` 中使用 `/aws/resources` 金鑰，來建立含 Amazon EC2 執行個體相關資源的 OpsItem。

```
aws ssm create-ops-item ^
    --title "EC2 instance disk full" ^
    --description "Log clean up may have failed which caused the disk to be full" ^
    --priority 2 ^
    --source ec2 ^
    --operational-data={\"/aws/resources\":{\"Value\":\"[{\\"""arn\\""":\\"""arn:aws:ec2:us-east-1:123456789012:instance/i-1234567890abcdef0\\"""}]\",\"Type\":\"SearchableString\"}}
```

以下命令會在 `OperationalData` 中使用 `/aws/automations` 金鑰，來建立可將 `AWS-RestartEC2Instance` 執行手冊指定為相關聯的 Automation 執行手冊的 OpsItem。

```
aws ssm create-ops-item ^
    --title "EC2 instance disk full" ^
    --description "Log clean up may have failed which caused the disk to be full" ^
    --priority 2 ^
    --source ec2 ^
    --operational-data={\"/aws/automations\":{\"Value\":\"[{\\"""automationId\\""":\\"""AWS-RestartEC2Instance\\”"",\\"""automationType\\""":\\"""AWS::SSM::Automation\\"""}]\",\"Type\":\"SearchableString\"}}
```