describe_alarms_for_metric ( $metric_name, $namespace, $opt )

Retrieves all alarms for a single metric. Specify a statistic, period, or unit to filter the set of alarms further.

Access

public

Parameters

Parameter

Type

Required

Description

$metric_name

string

Required

The name of the metric.

$namespace

string

Required

The namespace of the metric. [Constraints: The value must be between 1 and 255 characters, and must match the following regular expression pattern: [^:].*]

$opt

array

Optional

An associative array of parameters that can have the following keys:

  • 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 - Optional - 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.

Returns

Type

Description

CFResponse

A CFResponse object containing a parsed HTTP response.

Examples

Describe all alarms for a specific metric.

$cw = new AmazonCloudWatch();

$response = $cw->describe_alarms_for_metric('CPUUtilization', 'AWS/EC2', array(
	'Statistic' => 'Average',
	'Period' => 1800,
	'Unit' => 'Seconds'
));

// Success?
var_dump($response->isOK());
Result:
bool(true)

Related Methods

Source

Method defined in services/cloudwatch.class.php | Toggle source view (17 lines) | View on GitHub

public function describe_alarms_for_metric($metric_name, $namespace, $opt = null)
{
    if (!$opt) $opt = array();
    $opt['MetricName'] = $metric_name;
    $opt['Namespace'] = $namespace;
    
    // Optional list + map
    if (isset($opt['Dimensions']))
    {
        $opt = array_merge($opt, CFComplexType::map(array(
            'Dimensions' => $opt['Dimensions']
        ), 'member'));
        unset($opt['Dimensions']);
    }

    return $this->authenticate('DescribeAlarmsForMetric', $opt);
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback