我正在尝试探索 simple_aws gem。当我连接到 cloudwatch 以获取指标统计信息时,我收到如下错误:
cw.get_metric_statistics(
:metric_name => metric_name,
:period => period,
:start_time => start_time,
:end_time => end_time,
:statistics => "Average",
:namespace => "AWS/EC2"
)
SimpleAWS::UnsuccessfulResponse: MissingParameter (400):
The parameter Namespace is required.
The parameter MetricName is required.
The parameter StartTime is required.
The parameter EndTime is required.
The parameter Period is required.
The parameter Statistics is required.
后来,我尝试了这个:
cw.get_metric_statistics(
options => [
{:metric_name=>"CPUUtilization",
:period=>60,
:start_time => Time.now()-86400,
:end_time => Time.now()-3600,
:statistics => "Average"
}
]
)
但出现以下错误:
URI::InvalidComponentError: bad component(expected query component):
Action=GetMetricStatistics&{:metric_name=>"CPUUtilization"}.1.metric_name=CPUUtilization&{:metric_name=>"CPUUtilization"}.1.period=60&{:metric_name=>"CPUUtilization"}.1.start_time=2012-05-06%2014%3A25%3A28%20%2B0530&{:metric_name=>"CPUUtilization"}.1.end_time=2012-05-07%2013%3A25%3A28%20%2B0530&{:metric_name=>"CPUUtilization"}.1.statistics=Average&AWSAccessKeyId=AccessKey&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2012-05-07T08%3A55%3A28Z&Version=2010-08-01&Signature=Signature
再试一次:
cw.get_metric_statistics(
namespace: 'AWS/EC2',
measure_name: 'CPUUtilization',
statistics: 'Average',
start_time: time-1000,
dimensions: "InstanceId=#{instance_id}"
)
ArgumentError:Array 与 Array 的比较失败
任何人都可以帮助找到发出此命令的正确语法。