Global outage event
If you're experiencing issues with your AWS services, then please refer to the AWS Health Dashboard. You can find the overall status of ongoing outages, the health of AWS services, and the latest updates from AWS engineers.
使用自动化工作流 SAW 诊断 Amazon Opensearch Service 环境中的 CPU使用量异常问题
AWS 技术支援团队引入的自动化工作流(SAW),利用 AWS System Manager,提供了一个用户友好的收藏集,以 AWSSupport 或 AWSPremiumSupport 为前缀,协助您进行自助式诊断和修复。于本文场景,如果想知道具体于 Amazon Opensearch Service domain每个节点上面,CPU用量比较高的是什么样的线程,例如查询,您可以使用 AWSSupport-TroubleshootOpenSearchHighCPU,将每个节点上,CPU用量比较高的线程、具体使用多少 CPU,以及运行什么样的任务列出来。
前言
在日常维护 Amazon Opensearch Service集群时,运维团队可以透过监控 Cluster metrics 的 CPUUtilization跟踪集群中节点的 CPU用量。这个监控提供的统计数字,可以让运为团队知道,集群中节点 CPU用量的最大、最小,以及平均值。
AWS 技术支援团队引入的自动化工作流(SAW),利用AWS System Manager,提供了一个用户友好的收藏集,以 AWSSupport 或 AWSPremiumSupport 为前缀,协助您进行自助式诊断和修复。于本文场景,如果想知道具体于 Amazon Opensearch Service domain每个节点上面,CPU用量比较高的是什么样的线程,例如查询,您可以使用 AWSSupport-TroubleshootOpenSearchHighCPU,将每个节点上,CPU用量比较高的线程、具体使用多少 CPU,以及运行什么样的任务列出来。
前置作业
执行AWSSupport-TroubleshootOpenSearchHighCPU需要手册中提到的权限。请查看手册中 Required IAM permission,关于AutomationAssumeRole那个段落。请确保您的 Console Role或是 User至少有AutomationAssumeRole的权限。
此外,AWSSupport-TroubleshootOpenSearchHighCPU运行中需要透过 lambda,因此需要您事先创建一个 LambdaExecutionRole。这个 Role至少需要手册中Required IAM permission,关于LambdaExecutionRole段落中提到的权限。 以下为创建LambdaExecutionRole的步骤。
-
您由 AWS Management Console搜寻 IAM,到 IAM Console,Access management> Role点击 Create role
-
在 Trusted entity type选择 AWS Service,填入 Lambda之后,点击 Next。
-
在Add permissions的地方,搜寻AWSLambdaBasicExecutionRole。选取这个策略,并点击 Next。
-
将 Role命名为 SAW-Opensearch-LambdaExecutionRole,并点击 Create Role。
-
创建完成之后,到 IAM Console,Access management> Role搜寻 SAW-Opensearch-LambdaExecutionRole。
-
点击这个 Role,在 Add permissions的地方,点击 Create inline policy。
-
当配置 inline policy时,请点击 JSON。
请将下面这段 JSON内容复制贴上,并点选 Next。
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"ec2:CreateNetworkInterface",
"ec2:DeleteNetworkInterface",
"es:ESHttpGet",
"ec2:DescribeNetworkInterfaces"
],
"Resource": "*"
}
]
}
- 在 Policy name写上SAW-OpensearchCPU,并点击 Create policy。
- 创建完成之后,您可以看到 SAW-Opensearch-LambdaExecutionRole的IAM策略如下:
信任关系如下:
以上前置作业完成之后,我们可以开始执行 AWSSupport-TroubleshootOpenSearchHighCPU。
执行 AWSSupport-TroubleshootOpenSearchHighCPU
-
您由 AWS Management Console搜寻 Systems Manager,进入 AWS Systems Manager Console之后,在左手边选单的最下方,当您鼠标滑至最下方时,您会看到 Shared Resources> Documents。
-
您点击 Documents之后,在 Owned by Amazon的地方,您可以搜寻AWSSupport-TroubleshootOpenSearchHighCPU。
-
点击这个 document之后,看过具体 AWSSupport-TroubleshootOpenSearchHighCPU的操作内容之后,点击 Execution automation。
-
运行时,本范例运行Simple execution。
-
鼠标往下滑,在 Input parameters的地方,填入集群名称、以及刚才的 LambdaExecutionRole。AutomationAssumeRole并非必要,如果您没特别需要 assume的角色,您可以保持AutomationAssumeRole字段空白。AWSSupport-TroubleshootOpenSearchHighCPU会将运行结果输出到前缀为 /aws/lambda/AWSSupport-HighCPU- 的CloudWatch Logs,您可以在DataRetentionDays另外配置日志保存的时间。由于 CPU用量是一个持续的状态,有时候必须多搜集几次才能够看到毛刺。您可以透过NumberOfDataSamples配置您需要 lambda function运行多少次来搜集信息,以及配置NumberOfSecondsBetweenSamples为lambda function运行的间隔时间,单位为秒。以下为范例:
-
配置完成后,往下提交按Execute。
-
执行成功之后,您可以到 CloudWatch Logs搜寻以/aws/lambda/AWSSupport-HighCPU- 为前缀的 log group。
在日志里面,您可以看到每个节点上,CPU用量比较高的线程,例如以下截图。
更具体这些线程在运行什么样的操作,您也可以在打印出来的日志中一探究竟。
结语
于本篇文章,我们说明了如何透过 AWSSupport-TroubleshootOpenSearchHighCPU搜集 Amazon Opensearch Service集群中,每个节点上 CPU用料比较高线程的具体信息。您可以由日志内容,找出耗费资源的查询,进行调优,或是搭配 re:Post Knowledge Center文章,常见的 Amazon Opensearch Service CPU异常排查以及解决方式。AWS Support 不断创新故障排查技术,致力于提供更好的支持体验。
- 语言
- 中文 (简体)
相关内容
AWS 官方已更新 2 年前