MetricDatum to_sdk_metric_datum(Metric m, int numBuckets) { var a = m.Accumulator(); StatisticSet ss = new StatisticSet(); ss.Sum = a.sum(numBuckets); ss.Minimum = a.min(numBuckets); ss.Maximum = a.max(numBuckets); ss.SampleCount = a.count(numBuckets); MetricDatum d = new MetricDatum(); d.StatisticValues = ss; foreach (var p in m.All_dimensions()) { if (p.Key == "MetricName") { d.MetricName = p.Value; } else { d.Dimensions.Add(new Amazon.CloudWatch.Model.Dimension() { Name = p.Key, Value = p.Value }); } } d.Unit = MetricsConstant.unit(d.MetricName); d.Timestamp = DateTime.Now; return(d); }
string generate_query_args(Metric m, int idx, DateTime tp) { string prefix = "MetricData.member."; prefix += idx; prefix += "."; string metric_name = ""; StringBuilder ss = new StringBuilder(); { int i = 1; foreach (var p in m.All_dimensions()) { if (p.Key != "MetricName") { string dim_prefix = "Dimensions.member."; dim_prefix += i++; dim_prefix += "."; ss.Append(prefix).Append(dim_prefix).Append("Name=").Append(escape(p.Key)).Append("&") .Append(prefix).Append(dim_prefix).Append("Value=").Append(escape(p.Value)).Append("&"); } else { ss.Append(prefix).Append("MetricName=").Append(p.Value).Append("&"); metric_name = p.Value; } } } { var a = m.Accumulator(); var count = a.count(kNumBuckets); if (count == 0) { return(null); } string stat_prefix = prefix; stat_prefix += "StatisticValues."; ss.Append(stat_prefix).Append("Maximum=").Append(escape(a.max(kNumBuckets))).Append("&") .Append(stat_prefix).Append("Minimum=").Append(escape(a.min(kNumBuckets))).Append("&") .Append(stat_prefix).Append("Sum=").Append(escape(a.sum(kNumBuckets))).Append("&") .Append(stat_prefix).Append("SampleCount=").Append(escape(count)).Append("&"); } ss.Append(prefix).Append("Unit=").Append(MetricsConstant.unit(metric_name)).Append("&"); ss.Append(prefix).Append("Timestamp=").Append(escape(KPLNETInterface.Utils.format_ptime(tp))).Append("&"); return(ss.ToString()); }