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
 
Container for the parameters to the PutMetricData operation. Publishes metric data points to Amazon CloudWatch. Amazon CloudWatch associates the data points with the specified metric. If the specified metric does not exist, Amazon CloudWatch creates the metric. When Amazon CloudWatch creates a metric, it can take up to fifteen minutes for the metric to appear in calls to the ListMetrics action.

Each PutMetricData request is limited to 8 KB in size for HTTP GET requests and is limited to 40 KB in size for HTTP POST requests.

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.

Data that is timestamped 24 hours or more in the past may take in excess of 48 hours to become available from submission time using GetMetricStatistics.

Inheritance Hierarchy

System.Object
  Amazon.Runtime.AmazonWebServiceRequest
    Amazon.CloudWatch.AmazonCloudWatchRequest
      Amazon.CloudWatch.Model.PutMetricDataRequest

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

Syntax

C#
public class PutMetricDataRequest : AmazonCloudWatchRequest
         IRequestEvents

The PutMetricDataRequest type exposes the following members

Constructors

NameDescription
Public Method PutMetricDataRequest()

Properties

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

A list of data describing the metric.

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

The namespace for the metric data.

You cannot specify a namespace that begins with "AWS/". Namespaces that begin with "AWS/" are reserved for other Amazon Web Services products that send metrics to Amazon CloudWatch.

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