如何获取集群的每小时平均 CPUUtilization?
How do I fetch the hourly average CPUUtilization for my cluster?
我希望能够获取集群的每小时平均 CPUUtilization。但是使用亚马逊我得到这个错误: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 returns 是正确的指标,但我想用 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
由于 documentation :start-time and :end-time must be a Date object. 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
...
))
我希望能够获取集群的每小时平均 CPUUtilization。但是使用亚马逊我得到这个错误: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 returns 是正确的指标,但我想用 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
由于 documentation :start-time and :end-time must be a Date object. 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
...
))