我正在使用3个区域,并使用aws配置输出时间戳和平均值。
但是我不明白为什么我的输出中有一个空数组。
我添加了不同的配置,共享cw对象和getMetricStatistics方法的详细信息。
感谢您的帮助:)
// Generated by curl-to-PHP: http://incarnate.github.io/curl-to-php/
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://books.zoho.com/api/v3/organizations?organization_id=10234695');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
$headers = array();
$headers[] = 'Authorization: Zoho-authtoken {secret token}';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
实际结果:[]
预期结果:
var arr = [
{ "region": "eu-west", "value": "http://****" },
{ "region": "eu-west", "value": "http://****" },
{ "region": "eu-west", "value": "http://****" },
] ;
AWS.config.region = region;
var cw = new AWS.CloudWatch({apiVersion: '2010-08-01'});
var startDate = new Date();
var endDate = new Date();
startDate.setHours(startDate.getHours()-1);
var params = {
StartTime: startDate,
EndTime: endDate,
Namespace: '*****', /* required */
Period: 300, /* required */
MetricName: '*****', /* required */
Dimensions: [
{
Name: 'Endpoint', /* required */
Value: Value_t
},
/* more items */
],
Statistics: [
'Average'
/* more items */
],
};
var GlobalTab = [];
var r=-1;
while ( arr[++r] ) {
var region= arr[r].region;
var Value = arr[r].value ;
cw.getMetricStatistics(params, function(err, data) {
if (err){
console.log(err, err.stack); // an error occurred
}
else {
var TabJSON = [];
for(var i=0;i<5;i++) {
TabJSON.push(data.Datapoints[i]);
}
GlobalTab.push(TabJSON);
}
});
}
console.log(GlobalTab);