AWS SDK Version 3 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.

Encapsulates the information sent to either create a 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.CloudWatch.dll
Version: 3.x.y.z

Syntax

C#
public class MetricDatum

The MetricDatum type exposes the following members

Constructors

NameDescription
Public Method MetricDatum()

Properties

NameTypeDescription
Public Property Counts System.Collections.Generic.List<System.Double>

Gets and sets the property Counts.

Array of numbers that is used along with the Values array. Each number in the Count array is the number of times the corresponding value in the Values array occurred during the period.

If you omit the Counts array, the default of 1 is used as the value for each count. If you include a Counts array, it must include the same amount of values as the Values array.

Public Property Dimensions System.Collections.Generic.List<Amazon.CloudWatch.Model.Dimension>

Gets and sets the property Dimensions.

The dimensions associated with the metric.

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.

The statistical values for the metric.

Public Property StorageResolution System.Int32

Gets and sets the property StorageResolution.

Valid values are 1 and 60. Setting this to 1 specifies this metric as a high-resolution metric, so that CloudWatch stores the metric with sub-minute resolution down to one second. Setting this to 60 specifies this metric as a regular-resolution metric, which CloudWatch stores at 1-minute resolution. Currently, high resolution is available only for custom metrics. For more information about high-resolution metrics, see High-Resolution Metrics in the Amazon CloudWatch User Guide.

This field is optional, if you do not specify it the default of 60 is used.

Public Property Timestamp System.DateTime

Gets and sets the property TimestampUtc.

This property is deprecated. Setting this property results in non-UTC DateTimes not being marshalled correctly. Use TimestampUtc instead. Setting either Timestamp or TimestampUtc results in both Timestamp and TimestampUtc being assigned, the latest assignment to either one of the two property is reflected in the value of both. Timestamp is provided for backwards compatibility only and assigning a non-Utc DateTime to it results in the wrong timestamp being passed to the service.

The time the metric data was received, expressed as the number of milliseconds since Jan 1, 1970 00:00:00 UTC.

Public Property TimestampUtc System.DateTime

Gets and sets the property TimestampUtc.

The time the metric data was received, expressed as the number of milliseconds since Jan 1, 1970 00:00:00 UTC.

Public Property Unit Amazon.CloudWatch.StandardUnit

Gets and sets the property Unit.

When you are using a Put operation, this defines what unit you want to use when storing the metric.

In a Get operation, this displays the unit that is used for the metric.

Public Property Value System.Double

Gets and sets the property Value.

The value for the metric.

Although the parameter accepts numbers of type Double, CloudWatch rejects values that are either too small or too large. Values must be in the range of -2^360 to 2^360. In addition, special values (for example, NaN, +Infinity, -Infinity) are not supported.

Public Property Values System.Collections.Generic.List<System.Double>

Gets and sets the property Values.

Array of numbers representing the values for the metric during the period. Each unique value is listed just once in this array, and the corresponding number in the Counts array specifies the number of times that value occurred during the period. You can include up to 150 unique values in each PutMetricData action that specifies a Values array.

Although the Values array accepts numbers of type Double, CloudWatch rejects values that are either too small or too large. Values must be in the range of -2^360 to 2^360. In addition, special values (for example, 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>() { dimension },
  MetricName = "Desktop Machines Online",
  StatisticValues = new StatisticSet(),
  Timestamp = DateTime.Today,
  Unit = StandardUnit.Count,
  Value = 14
};

var metric2 = new MetricDatum
{
  Dimensions = new List<Dimension>() { dimension },
  MetricName = "Desktop Machines Offline",
  StatisticValues = new StatisticSet(),
  Timestamp = DateTime.Today,
  Unit = StandardUnit.Count,
  Value = 7
};

var metric3 = new MetricDatum
{
  Dimensions = new List<Dimension>() { dimension },
  MetricName = "Desktop Machines Online",
  StatisticValues = new StatisticSet(),
  Timestamp = DateTime.Today,
  Unit = StandardUnit.Count,
  Value = 12
};

var metric4 = new MetricDatum
{
  Dimensions = new List<Dimension>() { 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 Core App:
Supported in: 3.1

.NET Standard:
Supported in: 2.0

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