0

我希望能够获取集群的每小时平均 CPUUtilization。但是使用amazonica我得到这个错误: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})

运行此 aws cmd 会返回正确的指标,但我想使用 amazonica 来执行此操作。

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
4

1 回答 1

2

由于文档:start-time 和 :end-time 必须是 Date 对象。它不适用于您的示例中的字符串。你也可以看看这个例子

(let [date-string (.. (SimpleDateFormat. "MM-dd-yyyy")
                  (format (Date.)))]
   (get-metric-statistics
       ....
       :start-time (.minusDays (DateTime.) 1)
       :end-time date-string
       ...
      ))
于 2018-08-31T14:57:48.233 回答