AWS CloudWatch 代理 - 如何指定依赖于 EC2 元数据的值?

问题描述 投票:0回答:1

我有一个场景,我想附加一个维度,该维度取决于分配给实例的特定标签的值。例如,我有一个标有

Role = X
的实例,我想附加维度
Role
,并且该维度的值是标签
Role
的值。 我的猜测是语法类似于
${aws:InstanceId}
。我能够将新维度包含在特定指标中,如下所示

"cpu" : {
"append_dimensions" :{
"Role": "${aws:ec2:tag:Role}"
}

但这只能解析为文字字符串

"${aws:ec2:tag:Role}"

文档在此处说明https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Agent-Configuration-File-Details.html

If you want to append dimensions to metrics with arbitrary key-value pairs, use the append_dimensions parameter in the field for that particular type of metric.

If you specify a value that depends on Amazon EC2 metadata and you use proxies, you must make sure that the server can access the endpoint for Amazon EC2. For more information about these endpoints, see Amazon Elastic Compute Cloud (Amazon EC2) in the Amazon Web Services General Reference.

运行 cloudwatch 代理的 EC2 实例具有

ec2:DesribeTags
ec2:DescribeInstances

的角色
amazon-web-services amazon-cloudwatch
1个回答
0
投票

append_dimensions
字段应位于配置 json 文件中的
metrics
字段下。 但看起来您将
append_dimensions
放在另一个指标
cpu
下。

© www.soinside.com 2019 - 2024. All rights reserved.