I am trying to get the percentage of CPU from a specific instance of Amazon EC2 using CloudWatch
I encounter this error while executing code (see below)
The requested version (2010-08-01) of the AmazonEC2 service does not exist "
I could not change ServiceVersion in AmazonCloudWatchClient because it has Read Only property
The default value is 2010-08-01
I need to change ServiceVersion on 2014-10-01
Please find the configuration below.

And the configuration in the text here
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 + "%"); } }
c # amazon-ec2 aws-sdk
arun
source share