Reputation: 11247
How do I create a custom metric for my Elastic Beanstalk environment in C#?
I have a numerical metric seconds
.
I use the following code:
double seconds = ts.Seconds + (Convert.ToDouble(ts.Milliseconds / 10) / 100);
using (AmazonCloudWatchClient cloudwatch = new AmazonCloudWatchClient(accessKey, secretKey))
{
PutMetricDataRequest mdr = new PutMetricDataRequest();
mdr.Namespace = "Performance";
MetricDatum dataPoint = new MetricDatum();
dataPoint.MetricName = "UploadSpeedInSeconds";
dataPoint.Unit = "Seconds";
dataPoint.Value = seconds;
}
I have no idea were to continue on. I want the custom metric to mesuare the uploads in seconds of files. I already have the metric value, and I want to update a custom metric so I can keep track of it (BTW: can I view the custom metric in the console?).
Upvotes: 5
Views: 2517
Reputation: 441
Don't forget to actually send it off to AWS:
mdr.MetricData = new List<MetricDatum>();
mdr.MetricData.Add(dataPoint);
PutMetricDataResponse resp = cloudwatch.PutMetricData(mdr);
Debug.Assert(resp.HttpStatusCode == System.Net.HttpStatusCode.OK);
Upvotes: 10