AWS - How to change the cloudwatchclient configuration service version in AWSSDK for .NET.

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.

Error image

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 + "%"); } } 
+7
c # amazon-ec2 aws-sdk
source share
1 answer

why do you think you will need to change the date?

The property really does not have a setter (see code ), so you cannot determine the configuration with this property.

I understand that you do not want to disclose your information, but what do you have under

  var dimension = new Dimension { Name = "instanceName", Value = "instanceID" }; 

The name should be InstanceName , and if you use the instance identifier as indicated in the value, it should be InstanceId something like

  var dimension = new Dimension { Name = "InstanceId" Value = "i-54cfb999" }; 
0
source share

All Articles