Amazon.CloudWatch.AmazonCloudWatchClient.PutMetricData C# (CSharp) Метод

PutMetricData() публичный Метод

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 ListMetrics.

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 points with time stamps from 24 hours ago or longer can take at least 48 hours to become available for GetMetricStatistics from the time they are submitted.

/// Request processing has failed due to some unknown error, exception, or failure. /// /// Parameters that cannot be used together were used together. /// /// The value of an input parameter is bad or out-of-range. /// /// An input parameter that is required is missing. ///
public PutMetricData ( PutMetricDataRequest request ) : Amazon.CloudWatch.Model.PutMetricDataResponse
request Amazon.CloudWatch.Model.PutMetricDataRequest Container for the necessary parameters to execute the PutMetricData service method.
Результат Amazon.CloudWatch.Model.PutMetricDataResponse
        public PutMetricDataResponse PutMetricData(PutMetricDataRequest request)
        {
            var marshaller = new PutMetricDataRequestMarshaller();
            var unmarshaller = PutMetricDataResponseUnmarshaller.Instance;

            return Invoke<PutMetricDataRequest,PutMetricDataResponse>(request, marshaller, unmarshaller);
        }

Usage Example

        static void Main(string[] args)
        {
            PerformanceCounter percentPageFile = new PerformanceCounter("Paging File", "% Usage",      "_Total");
            PerformanceCounter peakPageFile    = new PerformanceCounter("Paging File", "% Usage Peak", "_Total");


            IAmazonCloudWatch client = new AmazonCloudWatchClient(RegionEndpoint.USWest2);

            // Once a minute, send paging file usage statistics to CloudWatch
            for (; ; )
            {
                List<MetricDatum> data = new List<MetricDatum>();

                data.Add(new MetricDatum()
                {
                    MetricName = "PagingFilePctUsage",
                    Timestamp = DateTime.Now,
                    Unit = StandardUnit.Percent,
                    Value = percentPageFile.NextValue()
                });

                data.Add(new MetricDatum()
                {
                    MetricName = "PagingFilePctUsagePeak",
                    Timestamp = DateTime.Now,
                    Unit = StandardUnit.Percent,
                    Value = peakPageFile.NextValue()
                });


                client.PutMetricData(new PutMetricDataRequest()
                {
                    MetricData = data,
                    Namespace = "System/Windows"
                });
                    
                Thread.Sleep(1000 * 60);
            }
        }
All Usage Examples Of Amazon.CloudWatch.AmazonCloudWatchClient::PutMetricData