Initialize connection to Cloudwatch
options parameter must include values for :aws_access_key_id and :aws_secret_access_key in order to create a connection
elb = CloudWatch.new( :aws_access_key_id => your_aws_access_key_id, :aws_secret_access_key => your_aws_secret_access_key )
options<~Hash> - config arguments for connection. Defaults to {}.
region<~String> - optional region to use. For instance, 'eu-west-1', 'us-east-1', etc.
CloudWatch object with connection to AWS.
# File lib/fog/aws/cloud_watch.rb, line 92 def initialize(options={}) @use_iam_profile = options[:use_iam_profile] setup_credentials(options) @connection_options = options[:connection_options] || {} @instrumentor = options[:instrumentor] @instrumentor_name = options[:instrumentor_name] || 'fog.aws.cloud_watch' options[:region] ||= 'us-east-1' @host = options[:host] || "monitoring.#{options[:region]}.amazonaws.com" @path = options[:path] || '/' @persistent = options[:persistent] || false @port = options[:port] || 443 @scheme = options[:scheme] || 'https' @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options) end
Delete a list of alarms
AlarmNames<~Array>: A list of alarms to be deleted
response<~Excon::Response>:
docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/index.html?API_DeleteAlarms.html
# File lib/fog/aws/requests/cloud_watch/delete_alarms.rb, line 19 def delete_alarms(alarm_names) options = {} options.merge!(AWS.indexed_param('AlarmNames.member.%d', [*alarm_names])) request({ 'Action' => 'DeleteAlarms', :parser => Fog::Parsers::AWS::CloudWatch::DeleteAlarms.new }.merge(options)) end
Retrieves history for the specified alarm
AlarmName<~String>: The name of the alarm
EndDate<~DateTime>: The ending date to retrieve alarm history
HistoryItemType<~String>: The type of alarm histories to retrieve
MaxRecords<~Integer>: The maximum number of alarm history records to retrieve
NextToken<~String> The token returned by a previous call to indicate that there is more data available
StartData<~DateTime>: The starting date to retrieve alarm history
response<~Excon::Response>:
# File lib/fog/aws/requests/cloud_watch/describe_alarm_history.rb, line 24 def describe_alarm_history(options={}) request({ 'Action' => 'DescribeAlarmHistory', :parser => Fog::Parsers::AWS::CloudWatch::DescribeAlarmHistory.new }.merge(options)) end
Retrieves alarms with the specified names
ActionPrefix<~String>: The action name prefix
AlarmNamePrefix<~String>: The alarm name prefix.
AlarmNames cannot be specified if this parameter is specified
AlarmNames<~Array>: A list of alarm names to retrieve information for.
MaxRecords<~Integer>: The maximum number of alarm descriptions to retrieve
NextToken<~String>: The token returned by a previous call to indicate that there is more data available
NextToken<~String> The token returned by a previous call to indicate that there is more data available
StateValue<~String>: The state value to be used in matching alarms
response<~Excon::Response>:
docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/API_DescribeAlarms.html
# File lib/fog/aws/requests/cloud_watch/describe_alarms.rb, line 26 def describe_alarms(options={}) if alarm_names = options.delete('AlarmNames') options.merge!(AWS.indexed_param('AlarmNames.member.%d', [*alarm_names])) end request({ 'Action' => 'DescribeAlarms', :parser => Fog::Parsers::AWS::CloudWatch::DescribeAlarms.new }.merge(options)) end
Retrieves all alarms for a single metric
Dimensions<~Array>: a list of dimensions to filter against
Name : The name of the dimension Value : The value to filter against
MetricName<~String>: The name of the metric
Namespace<~String>: The namespace of the metric
Period<~Integer>: The period in seconds over which the statistic is applied
Statistics<~String>: The statistic for the metric
Unit<~String> The unit for the metric
response<~Excon::Response>:
docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/API_DescribeAlarms.html
# File lib/fog/aws/requests/cloud_watch/describe_alarms_for_metric.rb, line 26 def describe_alarms_for_metric(options) if dimensions = options.delete('Dimensions') options.merge!(AWS.indexed_param('Dimensions.member.%d.Name', dimensions.collect {|dimension| dimension['Name']})) options.merge!(AWS.indexed_param('Dimensions.member.%d.Value', dimensions.collect {|dimension| dimension['Value']})) end request({ 'Action' => 'DescribeAlarmsForMetric', :parser => Fog::Parsers::AWS::CloudWatch::DescribeAlarmsForMetric.new }.merge(options)) end
Disables actions for the specified alarms
AlarmNames<~Array>: The names of the alarms to disable actions for
response<~Excon::Response>:
docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/API_DisableAlarmActions.html
# File lib/fog/aws/requests/cloud_watch/disable_alarm_actions.rb, line 19 def disable_alarm_actions(alarm_names) options = {} options.merge!(AWS.indexed_param('AlarmNames.member.%d', [*alarm_names])) request({ 'Action' => 'DisableAlarmActions', :parser => Fog::Parsers::AWS::CloudWatch::DisableAlarmActions.new }.merge(options)) end
Enables actions for the specified alarms
AlarmNames<~Array>: The names of the alarms to enable actions for
response<~Excon::Response>:
docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/API_EnableAlarmActions.html
# File lib/fog/aws/requests/cloud_watch/enable_alarm_actions.rb, line 19 def enable_alarm_actions(alarm_names) options = {} options.merge!(AWS.indexed_param('AlarmNames.member.%d', [*alarm_names])) request({ 'Action' => 'EnableAlarmActions', :parser => Fog::Parsers::AWS::CloudWatch::EnableAlarmActions.new }.merge(options)) end
Fetch datapoints for a metric. At most 1440 datapoints will be returned, the most datapoints that can be queried is 50850 StartTime is capped to 2 weeks ago
Namespace<~String>: the namespace of the metric
MetricName<~String>: the name of the metric
StartTime<~Datetime>: when to start fetching datapoints from (inclusive)
EndTime<~Datetime>: used to determine the last datapoint to fetch (exclusive)
Period<~Integer>: Granularity, in seconds of the returned datapoints. Must be a multiple of 60, and at least 60
Statistics<~Array>: An array of up to 5 strings, which name the statistics to return
Unit<~String>: The unit for the metric
Dimensions<~Array>: a list of dimensions to filter against (optional)
Name : The name of the dimension Value : The value to filter against
response<~Excon::Response>:
docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/API_GetMetricStatistics.html
# File lib/fog/aws/requests/cloud_watch/get_metric_statistics.rb, line 27 def get_metric_statistics(options={}) %{Statistics StartTime EndTime Period MetricName Namespace}.each do |required_parameter| raise ArgumentError, "Must provide #{required_parameter}" unless options.has_key?(required_parameter) end statistics = options.delete 'Statistics' options.merge!(AWS.indexed_param('Statistics.member.%d', [*statistics])) if dimensions = options.delete('Dimensions') options.merge!(AWS.indexed_param('Dimensions.member.%d.Name', dimensions.collect {|dimension| dimension['Name']})) options.merge!(AWS.indexed_param('Dimensions.member.%d.Value', dimensions.collect {|dimension| dimension['Value']})) end request({ 'Action' => 'GetMetricStatistics', :parser => Fog::Parsers::AWS::CloudWatch::GetMetricStatistics.new }.merge(options)) end
List availabe metrics
Dimensions<~Array>: a list of dimensions to filter against,
Name : The name of the dimension Value : The value to filter against
MetricName<~String>: The name of the metric to filter against
Namespace<~String>: The namespace to filter against
NextToken<~String> The token returned by a previous call to indicate that there is more data available
response<~Excon::Response>:
docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/API_ListMetrics.html
# File lib/fog/aws/requests/cloud_watch/list_metrics.rb, line 23 def list_metrics(options={}) if dimensions = options.delete('Dimensions') options.merge!(AWS.indexed_param('Dimensions.member.%d.Name', dimensions.collect {|dimension| dimension['Name']})) options.merge!(AWS.indexed_param('Dimensions.member.%d.Value', dimensions.collect {|dimension| dimension['Value']})) end request({ 'Action' => 'ListMetrics', :parser => Fog::Parsers::AWS::CloudWatch::ListMetrics.new }.merge(options)) end
Creates or updates an alarm and associates it with the specified Amazon CloudWatch metric
ActionsEnabled<~Boolean>: Indicates whether or not actions should be executed during any changes to the alarm's state
AlarmActions<~Array>: A list of actions to execute
AlarmDescription<~String>: The description for the alarm
AlarmName<~String> The unique name for the alarm
ComparisonOperator<~String>: The arithmetic operation to use for comparison
Dimensions<~Array>: a list of dimensions to filter against,
Name : The name of the dimension Value : The value to filter against
EvaluationPeriods<~Integer>: The number of periods over which data is compared to the specified threshold
InsufficientDataActions<~Array>: A list of actions to execute
MetricName<~String>: The name for the alarm's associated metric
Namespace<~String>: The namespace for the alarm's associated metric
OKActions<~Array>: A list of actions to execute
Period<~Integer>: The period in seconds over which the specified statistic is applied
Statistic<~String>: The statistic to apply to the alarm's associated metric
Threshold<~Double>: The value against which the specified statistic is compared
Unit<~String>: The unit for the alarm's associated metric
response<~Excon::Response>:
docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/API_PutMetricAlarm.html
# File lib/fog/aws/requests/cloud_watch/put_metric_alarm.rb, line 33 def put_metric_alarm(options) if dimensions = options.delete('Dimensions') options.merge!(AWS.indexed_param('Dimensions.member.%d.Name', dimensions.collect {|dimension| dimension['Name']})) options.merge!(AWS.indexed_param('Dimensions.member.%d.Value', dimensions.collect {|dimension| dimension['Value']})) end if alarm_actions = options.delete('AlarmActions') options.merge!(AWS.indexed_param('AlarmActions.member.%d', [*alarm_actions])) end if insufficient_data_actions = options.delete('InsufficientDataActions') options.merge!(AWS.indexed_param('InsufficientDataActions.member.%d', [*insufficient_data_actions])) end if ok_actions = options.delete('OKActions') options.merge!(AWS.indexed_param('OKActions.member.%d', [*ok_actions])) end request({ 'Action' => 'PutMetricAlarm', :parser => Fog::Parsers::AWS::CloudWatch::PutMetricAlarm.new }.merge(options)) end
Publishes one or more data points to CloudWatch. A new metric is created if necessary
Namespace<~String>: the namespace of the metric data
MetricData<~Array>: the datapoints to publish of the metric
* MetricName<~String>: the name of the metric * Timestamp<~String>: the timestamp for the data point. If omitted defaults to the time at which the data is received by CloudWatch * Unit<~String>: the unit * Value<~Double> the value for the metric * StatisticValues<~Hash>: * Maximum<~Double>: the maximum value of the sample set * Sum<~Double>: the sum of the values of the sample set * SampleCount<~Double>: the number of samples used for the statistic set * Minimum<~Double>: the minimum value of the sample set * Dimensions<~Array>: the dimensions for the metric. From 0 to 10 may be included * Name<~String> * Value<~String>
response<~Excon::Response>:
docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/API_PutMetricData.html
# File lib/fog/aws/requests/cloud_watch/put_metric_data.rb, line 31 def put_metric_data(namespace, metric_data) options = {'Namespace' => namespace} #first index the dimensions for any of the datums that have dimensions metric_data.collect! do |metric_datum| if dimensions = metric_datum.delete('Dimensions') metric_datum.merge!(AWS.indexed_param('Dimensions.member.%d.Name', dimensions.collect {|dimension| dimension['Name']})) metric_datum.merge!(AWS.indexed_param('Dimensions.member.%d.Value', dimensions.collect {|dimension| dimension['Value']})) end metric_datum end #then flatten out an hashes in the metric_data array metric_data.collect! { |metric_datum| flatten_hash(metric_datum) } #then index the metric_data array options.merge!(AWS.indexed_param('MetricData.member.%d', [*metric_data])) #then finally flatten out an hashes in the overall options array options = flatten_hash(options) request({ 'Action' => 'PutMetricData', :parser => Fog::Parsers::AWS::CloudWatch::PutMetricData.new }.merge(options)) end
# File lib/fog/aws/cloud_watch.rb, line 110 def reload @connection.reset end
Temporarily sets the state of an alarm
AlarmName<~String>: The names of the alarm
StateReason<~String>: The reason that this alarm is set to this specific state (in human-readable text format)
StateReasonData<~String>: The reason that this alarm is set to this specific state (in machine-readable JSON format)
StateValue<~String>: The value of the state
response<~Excon::Response>:
docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/API_SetAlarmState.html
# File lib/fog/aws/requests/cloud_watch/set_alarm_state.rb, line 22 def set_alarm_state(options) request({ 'Action' => 'SetAlarmState', :parser => Fog::Parsers::AWS::CloudWatch::SetAlarmState.new }.merge(options)) end
Generated with the Darkfish Rdoc Generator 2.