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.
Access
public
Parameters
Parameter |
Type |
Required |
Description |
---|---|---|---|
|
Required |
The descriptive name for the alarm. This name must be unique within the user’s AWS account |
|
|
Required |
The name for the alarm’s associated metric. |
|
|
Required |
The namespace for the alarm’s associated metric. [Constraints: The value must be between 1 and 255 characters, and must match the following regular expression pattern: |
|
|
Required |
The statistic to apply to the alarm’s associated metric. [Allowed values: |
|
|
Required |
The period in seconds over which the specified statistic is applied. |
|
|
Required |
The number of periods over which data is compared to the specified threshold. |
|
|
Required |
The value against which the specified statistic is compared. |
|
|
Required |
The arithmetic operation to use when comparing the specified |
|
|
Optional |
An associative array of parameters that can have the following keys:
|
Returns
Type |
Description |
---|---|
A |
Examples
Create or update a new metric alarm.
$cw = new AmazonCloudWatch(); $response = $cw->put_metric_alarm( 'my-alarm', // Alarm name 'CPUUtilization', // Metric name 'AWS/EC2', // Namespace 'Average', // Statistic 1800, // Period 3, // Evaluation periods 50, // Threshold 'LessThanOrEqualToThreshold' // Comparison operator ); // Success? var_dump($response->isOK());Result:
bool(true)
Create or update a new metric alarm.
$cw = new AmazonCloudWatch(); $response = $cw->put_metric_alarm( 'my-other-alarm', // Alarm name 'CPUUtilization', // Metric name 'AWS/EC2', // Namespace 'Average', // Statistic 1800, // Period 3, // Evaluation periods 50, // Threshold 'LessThanOrEqualToThreshold', // Comparison operator array( 'AlarmDescription' => 'This is a description of the alarm.', 'ActionsEnabled' => 'true', 'Unit' => 'Seconds' )); // Success? var_dump($response->isOK());Result:
bool(true)
Related Methods
Source
Method defined in services/cloudwatch.class.php | Toggle source view (50 lines) | View on GitHub