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?).
To change the metric, choose Edit, choose the All metrics tab, and do one of the following: Choose the service namespace that contains the metric that you want. Continue choosing options as they appear to narrow the choices. When a list of metrics appears, select the check box next to the metric that you want.
CloudWatch Metrics now supports the following three retention schedules: 1 minute datapoints are available for 15 days. 5 minute datapoints are available for 63 days. 1 hour datapoints are available for 455 days.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With