gpt4 book ai didi

amazon-web-services - 如何在 Ubuntu 上设置 AWS CloudWatch 的代理以获取(正确)自定义指标,例如 CPU、内存和磁盘使用率 %

转载 作者:行者123 更新时间:2023-12-03 22:53:09 25 4
gpt4 key购买 nike

我正在运行 AWS EC2 m5.large(非突发实例)。我在仪表板中设置了 AWS CloudWatch 的默认指标 (CPU %) 和一些自定义指标(内存 + 磁盘使用情况)之一。

但是,当我将 CloudWatch 报告的数字与我进行比较时,它们与我登录时实际使用 Ubuntu 20.04 服务器的情况相去甚远……

实际使用:

CPU: ~ 35 %
Memory: ~ 33 %

云观察报告:
CPU ~ 10 %
Memory: ~ 50-55

https://www.screencast.com/t/o1nAnOFjVZW

我已按照 AWS 自己的说明添加内存和磁盘使用量指标(因为 CloudWatch 无法立即访问 O/S 级别的内容): https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/mon-scripts.html

当数字彼此相距很远时 - 那么就不可能设置有用的警报和通知。我不敢相信这就是 AWS 想要提供给选择遵循其原始说明的人的东西?
唯一完全匹配的是磁盘使用百分比。

最佳答案

如何在 UBUNTU 20.04 安装 AWS 代理(替代旧脚本的新方法:“CloudWatchMonitoringScripts”)

https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/download-cloudwatch-agent-commandline.html

1. sudo wget https://s3.amazonaws.com/amazoncloudwatch-agent/debian/amd64/latest/amazon-cloudwatch-agent.deb
2. sudo dpkg -i -E ./amazon-cloudwatch-agent.deb
3. sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard
4. Go through all the steps in the wizard (The result is saved here: /opt/aws/amazon-cloudwatch-agent/bin/config.json)

提示:我回答:
 - Default to most questions and otherwise:
- NO --> Do you want to store the config in the SSM parameter store? (Because when I answered YES it failed later on because of some permission-issue and I didn't know how to make it happy and I don't think I need SSM in regards to this)
- YES --> Do you want to turn on StatsD daemon?
- YES --> Do you want to monitor metrics from CollectD?
- NO --> Do you have any existing CloudWatch Log Agent?

现在为了防止这个错误:解析/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.toml 时出错,打开/usr/share/collectd/types.db: no such file or directory
https://github.com/awsdocs/amazon-cloudwatch-user-guide/issues/1
5. sudo mkdir -p /usr/share/collectd/
6. sudo touch /usr/share/collectd/types.db
7. sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/bin/config.json -s
8. /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -m ec2 -a status

{
"status": "running",
"starttime": "2020-06-07T10:04:41+00:00",
"version": "1.245315.0"
}
  • https://www.screencast.com/t/42VWgoS88Z (创建 IAM 角色,添加策略并使其成为服务器默认角色)。
  • https://www.screencast.com/t/fAUUHCPe (CloudWatch 新的自定义指标)
  • https://www.screencast.com/t/8J0Saw0co (现在数据匹配OK)
  • https://www.screencast.com/t/x0PxOa799 (现在数据匹配OK)

  • 我意识到 - 在我登录到机器的第二次,CPU % 使用率从 10% 上升到 30% 并保持在那里(当然可以预期会有一些增加 - 但在我看来并没有那么多)这在我的情况下解释了早些时候有很大的不同......老实说,如果这种方式比旧脚本更精确,我现在不会 - 但这应该是 2020 年的正确方法:-) 选择“时,您可以访问 179 个自定义指标”高级”在向导期间(即使只有少数对大多数人有值(value))

    关于amazon-web-services - 如何在 Ubuntu 上设置 AWS CloudWatch 的代理以获取(正确)自定义指标,例如 CPU、内存和磁盘使用率 %,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62242033/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com