本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
手动创建 OpsItems
此部分包含针对非 Amazon EventBridge 自动创建的问题手动创建 OpsItems 的过程。
开始前的准备工作
如果您为受影响的 AWS 资源手动创建 OpsItem,则收集有关此资源的信息,以便能创建 Amazon 资源名称 (ARN)。如果您在创建 OpsItem 时指定 ARN,则 OpsCenter 会自动创建一个指向有关此资源的详细信息的深层链接。例如,如果您指定受影响的 EC2 实例的 ARN,则 OpsCenter 会创建一个指向有关此实例的详细信息的深层链接。有关如何创建 ARN 的信息,请参阅 https://docs.amazonaws.cn/general/latest/gr/aws-arns-and-namespaces.html 中的 Amazon 资源名称 (ARN) 和 AWS 服务命名空间Amazon Web Services 一般参考。
OpsCenter 不支持为所有 ARN 类型创建深层链接。要查看支持基于 ARNs 的深层链接的资源列表,请参阅支持的资源参考。
本节包括以下过程。
手动创建 OpsItem(控制台)
-
通过以下网址打开 AWS Systems Manager 控制台:https://console.amazonaws.cn/systems-manager/
。 -
在导航窗格中,选择OpsCenter。
-
选择 CreateOpsItem。如果您没有看到该按钮,则选择 OpsItems 选项卡,然后选择 Create OpsItem (创建 OpsItem)。
-
对于 Title (标题),输入一个描述性名称以帮助您了解 OpsItem 的用途。
-
对于 Source (源),请输入受影响的 AWS 资源的类型或其他源信息,以帮助用户了解 OpsItem 的源。
注意 创建 后,无法编辑 Source (源)OpsItem 字段。
-
(可选)对于 Priority (优先级),选择优先级级别。
-
(可选)对于 Severity (严重性),选择严重性级别。
-
(可选)对于 Category (类别),选择一个类别。
-
对于 Description (描述),输入有关此 OpsItem 的信息,包括(如果适用)再现此问题的步骤。
-
对于 Deduplication string (重复数据删除字符串),输入系统应用于检查重复的 OpsItems 单词。有关重复数据删除字符串的更多信息,请参阅减少重复的 OpsItems。
-
(可选)对于 Notifications (通知),指定在更新此 OpsItem 时要发送通知的 SNS 主题 ARN。您必须指定一个位于与 OpsItem 相同的 AWS 区域内的 Amazon SNS ARN。
-
(可选)在 Related resources (相关资源) 下,选择 Add (添加) 以指定受影响的资源和任何相关资源的 ID 或 Amazon 资源名称 (ARN)。
-
选择 CreateOpsItem。
如果成功,则 OpsItem 将打开。有关如何配置 OpsItem 中的选项的信息,请参阅使用 OpsItems。
手动创建 OpsItem (AWS CLI)
-
打开 AWS CLI 并运行以下命令以创建 OpsItem。
aws ssm create-ops-item --title "
Descriptive_title
" --description "Information_about_the_issue
" --priorityNumber_between_1_and_5
--sourceSource_of_the_issue
--operational-dataUp_to_20_KB_of_data_or_path_to_JSON_file
--notifications Arn="SNS_ARN_in_same_Region
" --tags "Key=key_name
,Value=a_value
"下面是一些示例。
Linux
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"
以下命令在
/aws/resources
中使用 OperationalData 键创建具有 OpsItem 相关资源的 Amazon DynamoDB。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"
以下命令使用
/aws/automations
中的 OperationalData 键创建指定 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
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"
以下命令在
/aws/resources
中使用 OperationalData 键创建具有 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\"}}
以下命令使用
/aws/automations
中的 OperationalData 键创建指定 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\"}}
指定文件中的操作数据
在创建 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 用户指南 中的将引号和字符串结合使用。
系统将返回类似于以下内容的信息:
{ "OpsItemId": "oi-1a2b3c4d5e6f" }
-
运行以下命令以查看有关您创建的 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" } } } }
-
运行以下命令以更新 OpsItem。此命令将状态从
Open
(默认值)更改为InProgress
。aws ssm update-ops-item --ops-item-id
ID
--status InProgress该命令没有输出。
-
再次运行以下命令以验证状态是否已更改为
InProgress
aws ssm get-ops-item --ops-item-id
ID