我正在尝试使用AWSSDK.CloudWatch软件包检索有关我的负载均衡器的数据,但是实际上并没有从中获得任何价值的运气。似乎无论如何,响应中MetricData的Values属性都是一个空数组。
AmazonCloudWatchClient client = new AmazonCloudWatchClient("MyAccessKeyId", "MySecretAccessKey", Amazon.RegionEndpoint.MyRegion);
GetMetricDataRequest request = new GetMetricDataRequest()
{
StartTime = DateTime.UtcNow.AddHours(-12),
EndTime = DateTime.UtcNow,
MetricDataQueries = new List<MetricDataQuery>()
{
new MetricDataQuery()
{
Id = "MyMetric",
MetricStat = new MetricStat()
{
Metric = new Metric()
{
Namespace = "AWS/ELB",
MetricName = "HealthyHostCount",
Dimensions = new List<Dimension>()
{
new Dimension()
{
Name = "LoadBalancerName",
Value = "MyLoadBalancerName"
}
}
},
Period = 300,
Stat = "Sum",
Unit = "None"
}
}
},
ScanBy = ScanBy.TimestampDescending,
MaxDatapoints = 1000
};
GetMetricDataResponse response = client.GetMetricData(request);
我正在努力寻找与此相关的任何示例。我希望能够获得每个负载均衡器的这个值。
答案 0 :(得分:0)
许多因素可能导致查询不返回任何数据。这就是我调试方法的方式:
200 OK
是?如果不是,则查询本身有问题,缺少必需的参数,凭据无效或策略不允许GetMetricData调用。