AWS SDK Version 2 for .NET
API Reference

AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

.NET Framework 3.5
 
The MetricDatum data type encapsulates the information sent with PutMetricData to either create a new metric or add new values to be aggregated into an existing metric.

Inheritance Hierarchy

System.Object
  Amazon.CloudWatch.Model.MetricDatum

Namespace: Amazon.CloudWatch.Model
Assembly: AWSSDK.dll
Version: (assembly version)

Syntax

C#
public class MetricDatum : Object

The MetricDatum type exposes the following members

Constructors

NameDescription
Public Method MetricDatum()

Properties

NameTypeDescription
Public Property Dimensions System.Collections.Generic.List<Amazon.CloudWatch.Model.Dimension> Gets and sets the property Dimensions.

A list of dimensions associated with the metric. Note, when using the Dimensions value in a query, you need to append .member.N to it (e.g., Dimensions.member.N).

Public Property MetricName System.String Gets and sets the property MetricName.

The name of the metric.

Public Property StatisticValues Amazon.CloudWatch.Model.StatisticSet Gets and sets the property StatisticValues.

A set of statistical values describing the metric.

Public Property Timestamp System.DateTime Gets and sets the property Timestamp.

The time stamp used for the metric in ISO 8601 Universal Coordinated Time (UTC) format. If not specified, the default value is set to the time the metric data was received.

Public Property Unit Amazon.CloudWatch.StandardUnit Gets and sets the property Unit.

The unit of the metric.

Public Property Value System.Double Gets and sets the property Value.

The value for the metric.

Although the Value parameter accepts numbers of type Double, Amazon CloudWatch rejects values that are either too small or too large. Values must be in the range of 8.515920e-109 to 1.174271e+108 (Base 10) or 2e-360 to 2e360 (Base 2). In addition, special values (e.g., NaN, +Infinity, -Infinity) are not supported.

Examples

This example shows how to publish a set of metric data points.

Publish metric data points example

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);
      

Version Information

.NET Framework:
Supported in: 4.5, 4.0, 3.5

.NET for Windows Store apps:
Supported in: Windows 8.1, Windows 8

.NET for Windows Phone:
Supported in: Windows Phone 8.1, Windows Phone 8