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.
If you create a metric with the PutMetricData
action, allow up to fifteen minutes
for the metric to appear in calls to the ListMetrics
action.
The size of aPutMetricDatarequest is limited to 8 KB for HTTP GET requests and 40 KB for HTTP POST requests.
Although the Value
parameter accepts numbers of type Double
, Amazon
CloudWatch truncates values with very large exponents. Values with base-10 exponents greater
than 126 (1 x 10^126) are truncated. Likewise, values with base-10 exponents less than -130 (1
x 10^-130) are also truncated.
Access
public
Parameters
Parameter |
Type |
Required |
Description |
---|---|---|---|
|
Required |
The namespace for the metric data. [Constraints: The value must be between 1 and 255 characters, and must match the following regular expression pattern: |
|
|
Required |
A list of data describing the metric.
|
|
|
Optional |
An associative array of parameters that can have the following keys:
|
Returns
Type |
Description |
---|---|
A |
Examples
Push custom metric data into CloudWatch.
$cw = new AmazonCloudWatch(); $response = $cw->put_metric_data('Custom/', array( array( // First data set 'MetricName' => 'MyData', 'Dimensions' => array( array('Name' => 'CustomAttribute1', 'Value' => 'CustomAttributeValue1'), array('Name' => 'CustomAttribute2', 'Value' => 'CustomAttributeValue2'), ), 'Timestamp' => 'today, midnight GMT', 'StatisticValues' => array( 'SampleCount' => 100, 'Sum' => 1234567890, 'Minimum' => 0, 'Maximum' => 9999999999 ), 'Unit' => 'Bits' ), )); // Success? var_dump($response->isOK());Result:
bool(true)
Source
Method defined in services/cloudwatch.class.php | Toggle source view (21 lines) | View on GitHub