是否可以使用AWS提供的.net SDK创建AWS CloudWatch自定义指标。开发人员指南介绍了如何通过命令行工具发布自定义指标。 是否可以通过.net SDK实现。如果是,请提供链接或教程..
答案 0 :(得分:1)
以下是.NET API http://docs.aws.amazon.com/sdkfornet/latest/apidocs/Index.html
的文档答案 1 :(得分:1)
我在aws文档中找到了答案。
它在此链接中:https://docs.aws.amazon.com/sdkfornet/latest/apidocs/Index.html 在主题下: Amazon.CloudWatch> AmazonCloudWatchClient> PutMetricData
下面是这个例子
var client = new AmazonCloudWatchClient();
var dimension = new Dimension
{
Name = "Desktop Machine Metrics",
Value = "Virtual Desktop Machine Usage"
};
var metric1 = new MetricDatum
{
Dimensions = new List<Dimension>(),
MetricName = "Desktop Machines Online",
StatisticValues = new StatisticSet(),
Timestamp = DateTime.Today,
Unit = StandardUnit.Count,
Value = 14
};
var metric2 = new MetricDatum
{
Dimensions = new List<Dimension>(),
MetricName = "Desktop Machines Offline",
StatisticValues = new StatisticSet(),
Timestamp = DateTime.Today,
Unit = StandardUnit.Count,
Value = 7
};
var metric3 = new MetricDatum
{
Dimensions = new List<Dimension>(),
MetricName = "Desktop Machines Online",
StatisticValues = new StatisticSet(),
Timestamp = DateTime.Today,
Unit = StandardUnit.Count,
Value = 12
};
var metric4 = new MetricDatum
{
Dimensions = new List<Dimension>(),
MetricName = "Desktop Machines Offline",
StatisticValues = new StatisticSet(),
Timestamp = DateTime.Today,
Unit = StandardUnit.Count,
Value = 9
};
var request = new PutMetricDataRequest
{
MetricData = new List<MetricDatum>() { metric1, metric2,
metric3, metric4 },
Namespace = "Example.com Custom Metrics"
};
client.PutMetricData(request);