public void TestGetMetricStatistics() { string measureName = "CPUUtilization"; GetMetricStatisticsRequest request = new GetMetricStatisticsRequest() { StartTime = DateTime.Now.AddMilliseconds(-ONE_WEEK_IN_MILLISECONDS), Namespace = "AWS/EC2", Period = 60 * 60, Dimensions = new List <Dimension> { new Dimension { Name = "InstanceType", Value = "m1.small" } }, MetricName = measureName, Statistics = new List <string> { "Average", "Maximum", "Minimum", "Sum" }, EndTime = DateTime.Now }; GetMetricStatisticsResult result = Client.GetMetricStatistics(request); AssertNotEmpty(result.Label); Assert.AreEqual(measureName, result.Label); Assert.IsNotNull(result.Datapoints); }
public void CWExceptionTest() { try { GetMetricStatisticsRequest getMetricRequest = new GetMetricStatisticsRequest() { MetricName = "CPUUtilization", Namespace = "AWS/EC2", StartTime = DateTime.Parse("2008-02-26T19:00:00+00:00"), EndTime = DateTime.Parse("2011-02-26T19:00:00+00:00"), Statistics = new List <string> { "Average" }, Unit = "Percent", Period = 60 }; GetMetricStatisticsResult getMetricResult = Client.GetMetricStatistics(getMetricRequest); } catch (AmazonCloudWatchException e) { AssertValidException(e); Assert.AreEqual <string>("InvalidParameterCombination", e.ErrorCode); throw e; } }
public void BasicCRUD() { ListMetricsResult listResult = Client.ListMetrics(new ListMetricsRequest()); Assert.IsNotNull(listResult); if (listResult.NextToken != null && listResult.NextToken.Length > 0) { listResult = Client.ListMetrics(new ListMetricsRequest() { NextToken = listResult.NextToken }); Assert.IsTrue(listResult.Metrics.Count > 0); } GetMetricStatisticsRequest getMetricRequest = new GetMetricStatisticsRequest() { MetricName = "NetworkIn", Namespace = "AWS/EC2", StartTime = DateTime.Parse("2008-01-01T19:00:00+00:00"), EndTime = DateTime.Parse("2009-12-01T19:00:00+00:00"), Statistics = new List <string> { "Average" }, Unit = "Percent", Period = 42000, }; GetMetricStatisticsResult getMetricResult = Client.GetMetricStatistics(getMetricRequest); Assert.IsNotNull(getMetricResult); Assert.IsTrue(getMetricResult.Datapoints.Count >= 0); Assert.IsNotNull(getMetricResult.Label); }