如何在 Amazon CloudWatch 的 AWS/EC2 命名空间中发布每个实例的指标?

发布于 2024-12-03 15:56:24 字数 303 浏览 3 评论 0原文

我正在为 CloudWatch 发布几个自定义指标。 当指标位于我自己的命名空间上时,一切都会顺利进行。 我现在想要在 AWS/EC2 命名空间中发布每个实例的指标,类似于 CPUUtilization,维度为 ImageId=i-XXXXXXXX 。 不幸的是,CloudWatch 不同意我的观点,并给了我这个错误: “参数命名空间的值 AWS/ 无效。”

  • 如何将自定义指标添加到特定实例?
  • 这有可能吗?

非常感谢,

I am in the process of publishing several custom metrics for CloudWatch.
When the metrics are on my own namespace, all goes well.
I now want to publish a per-instance metric, similar to CPUUtilization, with dimensions ImageId=i-XXXXXXXX, in the AWS/EC2 namespace.
Unfortunately, CloudWatch disagrees with me and gives me this error:
"The value AWS/ for parameter Namespace is invalid."

  • How do I add a custom metric to a specific instance?
  • Is this possible at all?

many thanks,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

⒈起吃苦の倖褔 2024-12-10 15:56:25

AWS/EC2 命名空间是为 EC2 发布的指标保留的,因此这是不可能的。我确定我在文档中读过它,但今天找不到来源。

检查该线程中的最后一个帖子:
https://forums.aws.amazon.com/thread.jspa?threadID=86835

The AWS/EC2 namespace is reserved for EC2 published metrics, so it's not possible. I'm sure I read it in the documentation but I can't find the source today.

Check the last post in this thread:
https://forums.aws.amazon.com/thread.jspa?threadID=86835

天赋异禀 2024-12-10 15:56:25

我试图为自己找到这个。文档中没有很好地定义命名空间/指标名称/维度等问题让我四处寻找。

这是我正在使用的脚本,在详细的说明中,您可以看到术语含义以及为什么要这样做的解释。我希望它可以帮助其他人获得此设置:)

带有示例/图片/图表的详细文章

#setup variables
export AWS_CLOUDWATCH_HOME=/home/myuser/cloudwatch/CloudWatch-1.0.12.1
export JAVA_HOME=/usr/lib/jvm/jre1.6.0_33
export AWS_CREDENTIAL_FILE=$AWS_CLOUDWATCH_HOME/credential-file-path.template
 
# get free memory and send to AWS CloudWatch
FREEMEMKB=$(egrep -Eio "MemFree:\s*([0-9]*)" /proc/meminfo | egrep -Eio "[0-9]*")
echo `/home/myuser/cloudwatch/CloudWatch-1.0.12.1/mon-put-data --namespace="MySite" --metric-name=FreeMemory --dimensions="InstanceId=i-d889e31d" --unit=Kilobytes --value=$FREEMEMKB`

I was trying to figure this one our for myself. Issue like the namespaces/metricnames/dimensions not being defined well in the docs left me searching around for a bit.

Here is the script I was using, and at the detailed writeup, you can see the explication for what the terms mean and why things were done the way they were. I hope it helps others get this setup :)

Detailed Writeup with examples/pictures/charts

#setup variables
export AWS_CLOUDWATCH_HOME=/home/myuser/cloudwatch/CloudWatch-1.0.12.1
export JAVA_HOME=/usr/lib/jvm/jre1.6.0_33
export AWS_CREDENTIAL_FILE=$AWS_CLOUDWATCH_HOME/credential-file-path.template
 
# get free memory and send to AWS CloudWatch
FREEMEMKB=$(egrep -Eio "MemFree:\s*([0-9]*)" /proc/meminfo | egrep -Eio "[0-9]*")
echo `/home/myuser/cloudwatch/CloudWatch-1.0.12.1/mon-put-data --namespace="MySite" --metric-name=FreeMemory --dimensions="InstanceId=i-d889e31d" --unit=Kilobytes --value=$FREEMEMKB`
稀香 2024-12-10 15:56:25

我已经这样做了。

aws cloudwatch put-metric-data --namespace AWS/EC2 --dimensions \
InstanceID=$inst_id --metric-name test-sessions --value $cnt

问题是该值不是放在Per-Instance Metrics中而是放在附近,并且不知道如何解决这个问题:

在此处输入图像描述

I've done it by

aws cloudwatch put-metric-data --namespace AWS/EC2 --dimensions \
InstanceID=$inst_id --metric-name test-sessions --value $cnt

The problem is the value is put not in Per-Instance Metrics but nearby and idk how to fix that:

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文