Amazon CloudWatch API Reference. This guide provides detailed information about Amazon CloudWatch actions, data types, * parameters, and errors. For detailed information about Amazon CloudWatch features and their associated API calls, go to the Amazon CloudWatch Developer Guide. * * Amazon CloudWatch is a web service that enables you to publish, monitor, and manage various metrics, as well as configure alarm actions * based on data from metrics. For more information about this product go to http://aws.amazon.com/cloudwatch. * * Use the following links to get started using the Amazon CloudWatch API Reference: * *
AWS_KEY constant.
* @param string $secret_key (Optional) Your Amazon API Secret Key. If blank, it will look for the AWS_SECRET_KEY constant.
* @return boolean false if no valid values are set, otherwise true.
*/
public function __construct($key = null, $secret_key = null)
{
$this->api_version = '2010-08-01';
$this->hostname = self::DEFAULT_URL;
if (!$key && !defined('AWS_KEY'))
{
// @codeCoverageIgnoreStart
throw new CW_Exception('No account key was passed into the constructor, nor was it set in the AWS_KEY constant.');
// @codeCoverageIgnoreEnd
}
if (!$secret_key && !defined('AWS_SECRET_KEY'))
{
// @codeCoverageIgnoreStart
throw new CW_Exception('No account secret was passed into the constructor, nor was it set in the AWS_SECRET_KEY constant.');
// @codeCoverageIgnoreEnd
}
return parent::__construct($key, $secret_key);
}
/*%******************************************************************************************%*/
// SERVICE METHODS
/**
*
* Creates or updates an alarm and associates it with the specified Amazon CloudWatch metric. Optionally, this operation can associate one or
* more Amazon Simple Notification Service resources with the alarm.
*
* When this operation creates an alarm, the alarm state is immediately set to INSUFFICIENT_DATA. The alarm is evaluated and its
* StateValue is set appropriately. Any actions associated with the StateValue is then executed.
*
* When updating an existing alarm, its StateValue is left unchanged.
*
* @param string $alarm_name (Required) The descriptive name for the alarm. This name must be unique within the user's AWS account
* @param string $metric_name (Required) The name for the alarm's associated metric.
* @param string $namespace (Required) The namespace for the alarm's associated metric.
* @param string $statistic (Required) The statistic to apply to the alarm's associated metric. [Allowed values: SampleCount, Average, Sum, Minimum, Maximum]
* @param integer $period (Required) The period in seconds over which the specified statistic is applied.
* @param integer $evaluation_periods (Required) The number of periods over which data is compared to the specified threshold.
* @param double $threshold (Required) The value against which the specified statistic is compared.
* @param string $comparison_operator (Required) The arithmetic operation to use when comparing the specified Statistic and Threshold. The specified Statistic value is used as the first operand. [Allowed values: GreaterThanOrEqualToThreshold, GreaterThanThreshold, LessThanThreshold, LessThanOrEqualToThreshold]
* @param array $opt (Optional) An associative array of parameters that can have the following keys: AlarmDescription - string - Optional - The description for the alarm. ActionsEnabled - boolean - Optional - Indicates whether or not actions should be executed during any changes to the alarm's state. OKActions - string|array - Optional - The list of actions to execute when this alarm transitions into an OK state from any other state. Each action is specified as an Amazon Resource Number (ARN). Currently the only action supported is publishing to an Amazon SNS topic or an Amazon Auto Scaling policy. Pass a string for a single value, or an indexed array for multiple values. AlarmActions - string|array - Optional - The list of actions to execute when this alarm transitions into an ALARM state from any other state. Each action is specified as an Amazon Resource Number (ARN). Currently the only action supported is publishing to an Amazon SNS topic or an Amazon Auto Scaling policy. Pass a string for a single value, or an indexed array for multiple values. InsufficientDataActions - string|array - Optional - The list of actions to execute when this alarm transitions into an INSUFFICIENT_DATA state from any other state. Each action is specified as an Amazon Resource Number (ARN). Currently the only action supported is publishing to an Amazon SNS topic or an Amazon Auto Scaling policy. Pass a string for a single value, or an indexed array for multiple values. Dimensions - array - Optional - The dimensions for the alarm's associated metric. x - array - This represents a simple array index. Name - string - Required - The name of the dimension. Value - string - Required - The value representing the dimension measurement Unit - string - Optional - The unit for the alarm's associated metric. [Allowed values: Seconds, Microseconds, Milliseconds, Bytes, Kilobytes, Megabytes, Gigabytes, Terabytes, Bits, Kilobits, Megabits, Gigabits, Terabits, Percent, Count, Bytes/Second, Kilobytes/Second, Megabytes/Second, Gigabytes/Second, Terabytes/Second, Bits/Second, Kilobits/Second, Megabits/Second, Gigabits/Second, Terabits/Second, Count/Second, None]curlopts - array - Optional - A set of values to pass directly into curl_setopt(), where the key is a pre-defined CURLOPT_* constant.returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.PutMetricData action, allow up to
* fifteen minutes for the metric to appear in calls to the ListMetrics action.
*
* The size of a PutMetricData request is limited to 8 KB for HTTP GET requests and 40 KB for HTTP POST requests.
*
* 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.
*
* @param string $namespace (Required) 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.
* @param array $metric_data (Required) A list of data describing the metric. x - array - This represents a simple array index. MetricName - string - Required - The name of the metric. Dimensions - array - Optional - A list of dimensions associated with the metric. x - array - This represents a simple array index. Name - string - Required - The name of the dimension. Value - string - Required - The value representing the dimension measurement Timestamp - string - Optional - The time stamp used for the metric. If not specified, the default value is set to the time the metric data was received. May be passed as a number of seconds since UNIX Epoch, or any string compatible with Value - integer - Optional - The value for the metric. StatisticValues - array - Optional - A set of statistical values describing the metric. Takes an associative array of parameters that can have the following keys: SampleCount - double - Required - The number of samples used for the statistic set. Sum - double - Required - The sum of values for the sample set. Minimum - double - Required - The minimum value of the sample set. Maximum - double - Required - The maximum value of the sample set. Unit - string - Optional - The unit of the metric. [Allowed values: Seconds, Microseconds, Milliseconds, Bytes, Kilobytes, Megabytes, Gigabytes, Terabytes, Bits, Kilobits, Megabits, Gigabits, Terabits, Percent, Count, Bytes/Second, Kilobytes/Second, Megabytes/Second, Gigabytes/Second, Terabytes/Second, Bits/Second, Kilobits/Second, Megabits/Second, Gigabits/Second, Terabits/Second, Count/Second, None]curlopts - array - Optional - A set of values to pass directly into curl_setopt(), where the key is a pre-defined CURLOPT_* constant.returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.NextToken values with subsequent
* ListMetrics operations.
*
* 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. Statistics about the metric, however, are available sooner using GetMetricStatistics.
*
* @param array $opt (Optional) An associative array of parameters that can have the following keys: Namespace - string - Optional - The namespace to filter against. MetricName - string - Optional - The name of the metric to filter against. Dimensions - array - Optional - A list of dimensions to filter against. x - array - This represents a simple array index. Name - string - Required - The dimension name to be matched. Value - string - Optional - The value of the dimension to be matched. Specifying a Name without specifying a Value returns all values associated with that Name. NextToken - string - Optional - The token returned by a previous call to indicate that there is more data available. curlopts - array - Optional - A set of values to pass directly into curl_setopt(), where the key is a pre-defined CURLOPT_* constant.returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.GetMetricStatistics request is 1,440. If a request is made that
* generates more than 1,440 data points, Amazon CloudWatch returns an error. In such a case, alter the request by narrowing the specified time
* range or increasing the specified period. Alternatively, make multiple requests across adjacent time ranges.
*
* Amazon CloudWatch aggregates data points based on the length of the period that you specify. For example, if you request
* statistics with a one-minute granularity, Amazon CloudWatch aggregates data points with time stamps that fall within the same one-minute
* period. In such a case, the data points queried can greatly outnumber the data points returned.
*
* The maximum number of data points that can be queried is 50,850; whereas the maximum number of data points returned is 1,440.
*
* The following examples show various statistics allowed by the data point query maximum of 50,850 when you call
* GetMetricStatistics on Amazon EC2 instances with detailed (one-minute) monitoring enabled:
*
* Period must be at least 60 seconds and must be a multiple of 60. The default value is 60.
* @param string|array $statistics (Required) The metric statistics to return. Pass a string for a single value, or an indexed array for multiple values.
* @param string $unit (Required) The unit for the metric. [Allowed values: Seconds, Microseconds, Milliseconds, Bytes, Kilobytes, Megabytes, Gigabytes, Terabytes, Bits, Kilobits, Megabits, Gigabits, Terabits, Percent, Count, Bytes/Second, Kilobytes/Second, Megabytes/Second, Gigabytes/Second, Terabytes/Second, Bits/Second, Kilobits/Second, Megabits/Second, Gigabits/Second, Terabits/Second, Count/Second, None]
* @param array $opt (Optional) An associative array of parameters that can have the following keys: Dimensions - array - Optional - A list of dimensions describing qualities of the metric. x - array - This represents a simple array index. Name - string - Required - The name of the dimension. Value - string - Required - The value representing the dimension measurement curlopts - array - Optional - A set of values to pass directly into curl_setopt(), where the key is a pre-defined CURLOPT_* constant.returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.curlopts - array - Optional - A set of values to pass directly into curl_setopt(), where the key is a pre-defined CURLOPT_* constant.returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.AlarmNames - string|array - Optional - A list of alarm names to retrieve information for. Pass a string for a single value, or an indexed array for multiple values. AlarmNamePrefix - string - Optional - The alarm name prefix. AlarmNames cannot be specified if this parameter is specified. StateValue - string - Optional - The state value to be used in matching alarms. [Allowed values: OK, ALARM, INSUFFICIENT_DATA]ActionPrefix - string - Optional - The action name prefix. MaxRecords - integer - Optional - The maximum number of alarm descriptions to retrieve. NextToken - string - Optional - The token returned by a previous call to indicate that there is more data available. curlopts - array - Optional - A set of values to pass directly into curl_setopt(), where the key is a pre-defined CURLOPT_* constant.returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.Statistic - string - Optional - The statistic for the metric. [Allowed values: SampleCount, Average, Sum, Minimum, Maximum]Dimensions - array - Optional - The list of dimensions associated with the metric. x - array - This represents a simple array index. Name - string - Required - The name of the dimension. Value - string - Required - The value representing the dimension measurement Period - integer - Optional - The period in seconds over which the statistic is applied. Unit - string - Optional - The unit for the metric. [Allowed values: Seconds, Microseconds, Milliseconds, Bytes, Kilobytes, Megabytes, Gigabytes, Terabytes, Bits, Kilobits, Megabits, Gigabits, Terabits, Percent, Count, Bytes/Second, Kilobytes/Second, Megabytes/Second, Gigabytes/Second, Terabytes/Second, Bits/Second, Kilobits/Second, Megabits/Second, Gigabits/Second, Terabits/Second, Count/Second, None]curlopts - array - Optional - A set of values to pass directly into curl_setopt(), where the key is a pre-defined CURLOPT_* constant.returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.AlarmName - string - Optional - The name of the alarm. HistoryItemType - string - Optional - The type of alarm histories to retrieve. [Allowed values: ConfigurationUpdate, StateUpdate, Action]StartDate - string - Optional - The starting date to retrieve alarm history. May be passed as a number of seconds since UNIX Epoch, or any string compatible with EndDate - string - Optional - The ending date to retrieve alarm history. May be passed as a number of seconds since UNIX Epoch, or any string compatible with MaxRecords - integer - Optional - The maximum number of alarm history records to retrieve. NextToken - string - Optional - The token returned by a previous call to indicate that there is more data available. curlopts - array - Optional - A set of values to pass directly into curl_setopt(), where the key is a pre-defined CURLOPT_* constant.returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.curlopts - array - Optional - A set of values to pass directly into curl_setopt(), where the key is a pre-defined CURLOPT_* constant.returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.curlopts - array - Optional - A set of values to pass directly into curl_setopt(), where the key is a pre-defined CURLOPT_* constant.returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.StateValue differs from the previous value, the action configured for
* the appropriate state is invoked. This is not a permanent change. The next periodic alarm check (in about a minute) will set the alarm to
* its actual state.
*
* @param string $alarm_name (Required) The descriptive name for the alarm. This name must be unique within the user's AWS account. The maximum length is 255 characters.
* @param string $state_value (Required) The value of the state. [Allowed values: OK, ALARM, INSUFFICIENT_DATA]
* @param string $state_reason (Required) The reason that this alarm is set to this specific state (in human-readable text format)
* @param array $opt (Optional) An associative array of parameters that can have the following keys: StateReasonData - string - Optional - The reason that this alarm is set to this specific state (in machine-readable JSON format) curlopts - array - Optional - A set of values to pass directly into curl_setopt(), where the key is a pre-defined CURLOPT_* constant.returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.