gpt4 book ai didi

ruby - 使用 ruby​​ 在 simple_aws 中使用 get_metric_statistics

转载 作者:太空宇宙 更新时间:2023-11-03 18:26:18 27 4
gpt4 key购买 nike

我正在尝试探索 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 的比较失败

任何人都可以帮助找到发出此命令的正确语法。

最佳答案

result = cw.get_metric_statistics(step,
start_time,
end_time,
metric,
'AWS/RDS',
'Average',
dimensions={'DBInstanceIdentifier': [indentifier]})

这对我也有用

关于ruby - 使用 ruby​​ 在 simple_aws 中使用 get_metric_statistics,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10479344/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com