简体   繁体   English

如何获取群集的每小时平均CPU使用率?

[英]How do I fetch the hourly average CPUUtilization for my cluster?

I would like to be able to fetch the hourly average CPUUtilization for my cluster. 我希望能够获取群集的每小时平均CPUUtilization。 But using amazonica I get this error: com.amazonaws.services.cloudwatch.model.InvalidParameterValueException: The parameter StartTime must not equal parameter EndTime. 但是使用com.amazonaws.services.cloudwatch.model.InvalidParameterValueException: The parameter StartTime must not equal parameter EndTime.出现以下错误: com.amazonaws.services.cloudwatch.model.InvalidParameterValueException: The parameter StartTime must not equal parameter EndTime.

(get-metric-statistics {:metric-name "CPUUtilization"
                        :namespace "AWS/ECS"
                        :dimensions [{:name  "ClusterName" :value "my-cluster"}]
                        :start-time "2018-08-31T12:00:00Z"
                        :end-time "2018-08-31T13:00:00Z"
                        :statistics ["Average"]
                        :period 3600})

Running this aws cmd returns the correct metric, but I want to use amazonica to do this. 运行此aws cmd将返回正确的指标,但是我想使用amazononica来执行此操作。

aws cloudwatch get-metric-statistics \
--metric-name CPUUtilization \
--namespace AWS/ECS \
--dimensions Name=ClusterName,Value=my-cluster \
--start-time 2018-08-31T12:00:00Z \
--end-time 2018-08-31T13:00:00Z \
--statistics Average \
--period 3600

Due to the documentation :start-time and :end-time must be a Date object. 由于文档的原因, :start-time和:end-time必须是Date对象。 It does not work with string in your example. 在您的示例中,它不适用于字符串。 You can also take a look at this example 您也可以看一下这个例子

(let [date-string (.. (SimpleDateFormat. "MM-dd-yyyy")
                  (format (Date.)))]
   (get-metric-statistics
       ....
       :start-time (.minusDays (DateTime.) 1)
       :end-time date-string
       ...
      ))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何确定AWS的CPUUtilization是否是我的网站注册超时的原因? - How can I tell if CPUUtilization in AWS is the reason my website sign-up is timing out? AWS/ECS CPUUtilization 平均值与最大值 - AWS/ECS CPUUtilization average vs maximum 如何让我的 AWS EKS Kubernetes 集群公开可见? - How do I get my AWS EKS Kubernetes Cluster to be visible publicly? 如何使用AWS自动扩展来扩展具有1个主节点和2个核心节点的AWS EMR集群? 有办法吗? - How do I scale my AWS EMR cluster with 1 master and 2 core nodes using AWS auto scaling? Is there a way? 如何使用AWS将kubernetes集群主服务器绑定到弹性IP? - How do I bind my kubernetes cluster master to an elastic ip with AWS? 如何让我的 EC2 实例连接到 ECS 集群? - How do I get my EC2 Instance to connect to ECS Cluster? 如何一次在多个实例的CPUUtilization指标上创建警报? - How to create Alarm on CPUUtilization Metric for multiple instances at a time? 如何找到我的Hadoop集群的集群ID? - how to find cluster id of my hadoop cluster? 如何在远程Spark集群上运行本地Python脚本? - How do I run a local Python script on a remote Spark cluster? 如何通过 CDK 创建带节点的 EKS 集群? - How do I create an EKS cluster with nodes via CDK?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM