Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

CloudWatch only accepts maximum of 20 data metrics per request. We th…

…erefore split any incoming metrics in to groups of 20 before sending.
  • Loading branch information...
commit 04ad53522ed178f03b83926021ca783d4f2d42f4 1 parent 7040e94
Peter Miller authored
View
12 Class Libraries/Natol.PerformanceCounter2CloudWatch.Framework/CounterManager.cs
@@ -141,10 +141,16 @@ private void SendMetrics(IList<MetricDatum> data, string dataNamesspace)
//setup cloudwatch service
AmazonCloudWatch client = Amazon.AWSClientFactory.CreateAmazonCloudWatchClient(appSettings["AWS-CloudWatch-AccessKey"], appSettings["AWS-CloudWatch-SecretKey"], new AmazonCloudWatchConfig { ServiceURL = appSettings["AWS-CloudWatch-ServiceUrl"] });
- client.PutMetricData(new PutMetricDataRequest()
- .WithMetricData(data)
- .WithNamespace(dataNamesspace));
+ //cloud-watch only lets us send maximum of 20 pieces of metric data per request,
+ // so split in to groups of 20
+ var dataGrp = from i in Enumerable.Range(0, data.Count())
+ group data[i] by i / 20;
+ dataGrp.ToList().ForEach(dataSet =>
+ client.PutMetricData(new PutMetricDataRequest()
+ .WithMetricData(dataSet.AsEnumerable())
+ .WithNamespace(dataNamesspace))
+ );
}
Please sign in to comment.
Something went wrong with that request. Please try again.