从 AWS CloudWatch 指标数学 SEARCH 函数获取单个时间序列 [英] Getting single time series from AWS CloudWatch metric maths SEARCH function

查看:24
本文介绍了从 AWS CloudWatch 指标数学 SEARCH 函数获取单个时间序列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为组中的任何实例使用超过 x% 的内存创建 CloudWatch 警报,并为此构建了以下指标数学查询:

I'm attempting to creating a CloudWatch alarm for if any instances in a group go over x% of memory used and have built the following metric maths query to do so:

SEARCH('{CWAgent,InstanceId} MetricName=mem_used_percent"', 'Maximum', 300)

这个图表很好,但是 CloudWatch 控制台抱怨警报的表达式必须正好创建一个时间序列.".我相信是这样;上面的查询应该(并且确实)返回一个非多维的单线图结果.

This graphs fine, however the CloudWatch console complains "The expression for an alarm must create exactly one time series.". I believe this is the case; The query above should (and does) return a singular line graph result that is not multi-dimensional.

如何让这些数据以 CloudWatch 创建警报所需的格式返回?我的替代方案是为每个实例创建通用一个新警报,但是这对于管理警报的创建和销毁似乎更复杂.

How can I get this data to return in the format required by CloudWatch to create an alarm? My alternative is to general a new alarm per instance creation, however this seems more complex to manage the creation and destruction of alarms.

用于收集指标的实例上的 CloudWatch 配置:

CloudWatch config on instance for collecting metric:

  "metrics":{
    "append_dimensions": {
      "InstanceId": "${aws:InstanceId}"
    },
    "metrics_collected":{
      "mem": {
         "measurement": [
           "used_percent"
        ]
      },
      "disk": {
         "measurement": [ "used_percent" ],
         "metrics_collection_interval": 60,
         "resources": [ "/" ]
     }
    }

推荐答案

此示例为区域中的每个实例显示一行,显示来自 AWS/EC2 命名空间的 CPUUtilization 指标.

This example displays one line for each instance in the Region, showing the CPUUtilization metric from the AWS/EC2 namespace.

SEARCH(' {AWS/EC2,InstanceId} MetricName="CPUUtilization" ', 'Average', 300)

将 InstanceId 更改为 InstanceType 会将图表更改为针对区域中使用的每个实例类型显示一行.来自每种类型的所有实例的数据汇总到该实例类型的一行中.

Changing InstanceId to InstanceType changes the graph to show one line for each instance type used in the Region. Data from all instances of each type is aggregated into one line for that instance type.

SEARCH(' {AWS/EC2,InstanceType} MetricName="CPUUtilization" ', 'Average', 300)

删除维度名称但保留架构中的命名空间(如下例所示)会生成一行显示区域中所有实例的 CPUUtilization 指标的聚合.

Removing the dimension name but keeping the namespace in the schema, as in the following example, results in a single line showing the aggregation of CPUUtilization metrics for all instances in the Region.

SEARCH(' {AWS/EC2} MetricName="CPUUtilization" ', 'Average', 300)

参考这个 有关搜索查询的详细说明.

refer this for detailed explanation about search query.

要选择指标,请参阅 链接以获取分步说明.

To select metrics, refer this link for step-by-step explanation.

这篇关于从 AWS CloudWatch 指标数学 SEARCH 函数获取单个时间序列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆