enable_metrics_collection ( $auto_scaling_group_name, $granularity, $opt )

Enables monitoring of group metrics for the Auto Scaling group specified in AutoScalingGroupName. You can specify the list of enabled metrics with the Metrics parameter.

Auto scaling metrics collection can be turned on only if the InstanceMonitoring flag, in the Auto Scaling group’s launch configuration, is set to True.

Access

public

Parameters

Parameter

Type

Required

Description

$auto_scaling_group_name

string

Required

The name or ARN of the Auto Scaling group. [Constraints: The value must be between 1 and 1600 characters, and must match the following regular expression pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*]

$granularity

string

Required

The granularity to associate with the metrics to collect. Currently, the only legal granularity is “1Minute”. [Constraints: The value must be between 1 and 255 characters, and must match the following regular expression pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*]

$opt

array

Optional

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

  • Metrics - string|array - Optional - The list of metrics to collect. If no metrics are specified, all metrics are enabled. The following metrics are supported:
    • GroupMinSize
    • GroupMaxSize
    • GroupDesiredCapacity
    • GroupInServiceInstances
    • GroupPendingInstances
    • GroupTerminatingInstances
    • GroupTotalInstances
    Pass a string for a single value, or an indexed array for multiple values.
  • 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

Enable the collection of metrics.

// Instantiate the class
$as = new AmazonAS();

$response = $as->enable_metrics_collection('my-scaling-group', '1Minute', array(
	'Metrics' => array(
		'GroupMinSize',
		'GroupMaxSize',
		'GroupDesiredCapacity',
		'GroupInServiceInstances',
		'GroupPendingInstances',
		'GroupTerminatingInstances',
		'GroupTotalInstances'
	)
));

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

Related Methods

Source

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

public function enable_metrics_collection($auto_scaling_group_name, $granularity, $opt = null)
{
    if (!$opt) $opt = array();
    $opt['AutoScalingGroupName'] = $auto_scaling_group_name;
    $opt['Granularity'] = $granularity;
    
    // Optional list (non-map)
    if (isset($opt['Metrics']))
    {
        $opt = array_merge($opt, CFComplexType::map(array(
            'Metrics' => (is_array($opt['Metrics']) ? $opt['Metrics'] : array($opt['Metrics']))
        ), 'member'));
        unset($opt['Metrics']);
    }

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

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback