我正在尝试使用CloudWatch获取特定亚马逊EC2实例的cpu百分比
The requested version (2010-08-01) of service AmazonEC2 does not exist”
我无法在AmazonCloudWatchClient中更改ServiceVersion,因为它具有只读属性
默认设置为2010-08-01
我需要将ServiceVersion更改为2014-10-01
请在下面找到配置
这里配置文字
var client = new AmazonCloudWatchClient(clientkey,secretkey,new AmazonCloudWatchConfig{ServiceURL="url"}) var dimension = new Dimension { Name = "instanceName",Value = "instanceID" }; var request = new GetMetricStatisticsRequest { Dimensions = new List<Dimension>() { dimension },EndTime = DateTime.Today,MetricName = "cpuUtilization",Namespace = "AWS/EC2",// Get statistics by day. Period = (int)TimeSpan.FromDays(1).TotalSeconds,// Get statistics for the past month. StartTime = DateTime.Today.Subtract(TimeSpan.FromDays(30)),Statistics = new List<string>() { "Minimum" },Unit = StandardUnit.Percent }; var response = client.GetMetricStatistics(request); if (response.Datapoints.Count > 0) { foreach (var point in response.Datapoints) { Console.WriteLine(point.Timestamp.ToShortDateString() + " " + point.Minimum + "%"); } }