动态将AutoscalingGroup的EC2实例添加/删除到AWS Dashboard Metric Widget [英] Dynamically adding/removing EC2 instances of an AutoscalingGroup to AWS Dashboard Metric Widget

查看:97
本文介绍了动态将AutoscalingGroup的EC2实例添加/删除到AWS Dashboard Metric Widget的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个仪表板,并希望一个小部件在自动缩放内显示 ALL EC2实例的CPUUtilization图。
每当通过自动缩放规则添加新实例时,仪表板小部件都应自动包括新EC2实例的图,而当实例被删除时,它应删除该实例的图。

I am trying to create a dashboard and want a widget to display the CPUUtilization graphs of ALL EC2 instances within my autoscaling. Whenever a new instance gets added by autoscaling rules then the dashboard widget should include the graph of new EC2 instance automatically and when an instance gets deleted it should remove the graph of that instance.

当我选择自动缩放组作为度量标准时,尽管在该自动缩放组中有4个实例,它只是在图中显示了一条线。

When I select the autoscaling group as the metric it simply displays one line in the graph although there are 4 instances within that autoscaling groups.

可能?
如果是,我在做什么错了?

Is that possible? If yes, what am I doing wrong?

推荐答案

AWS团队发布了Lambda函数来自动更新仪表板: 此处是链接

AWS team release an Lambda function to auto update your dashboard : here is the link

脚本:


  • 加载指定的CloudWatch仪表板)

  • 查找所有显示EC2实例指标的图控件

  • 调用带有已配置参数的EC2 DescribeInstances API,以发现该图的当前EC2实例区域

  • 如有需要,更新小部件

  • 如果任何小部件定义发生更改,则保存CloudWatch仪表板

  • Loads the specified CloudWatch Dashboard(s)
  • Looks for all graph widgets displaying EC2 instance metrics
  • Calls EC2 DescribeInstances API with configured parameters to discover the current EC2 instances for that graph in that region
  • Updates the widget if needed
  • Saves the CloudWatch Dashboards if any widget definition has changed

但它也有局限性:


  • 它只会更新第一个度量为EC2的图实例指标,图上的所有其他指标都将替换为这些指标

  • 指标不能保存自定义期间或统计信息后,将使用图形默认值

这篇关于动态将AutoscalingGroup的EC2实例添加/删除到AWS Dashboard Metric Widget的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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