I would like to be able to fetch the hourly average CPUUtilization for my cluster. But using amazonica I get this error: 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 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. 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
...
))