Class: Cloudwatch::Sender::Fetcher::Custom

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudwatch/sender/fetcher/custom.rb

Constant Summary collapse

START_TIME =
180

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cloudwatch, sender) ⇒ Custom

Returns a new instance of Custom.



7
8
9
10
# File 'lib/cloudwatch/sender/fetcher/custom.rb', line 7

def initialize(cloudwatch, sender)
  @cloudwatch = cloudwatch
  @sender = sender
end

Instance Attribute Details

#cloudwatchObject (readonly)

Returns the value of attribute cloudwatch.



5
6
7
# File 'lib/cloudwatch/sender/fetcher/custom.rb', line 5

def cloudwatch
  @cloudwatch
end

#databaseObject (readonly)

Returns the value of attribute database.



5
6
7
# File 'lib/cloudwatch/sender/fetcher/custom.rb', line 5

def database
  @database
end

#senderObject (readonly)

Returns the value of attribute sender.



5
6
7
# File 'lib/cloudwatch/sender/fetcher/custom.rb', line 5

def sender
  @sender
end

Instance Method Details

#metrics(component_meta, metric) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/cloudwatch/sender/fetcher/custom.rb', line 14

def metrics(component_meta, metric)
  resp = cloudwatch.get_metric_statistics(
    :namespace   => component_meta["namespace"],
    :metric_name => metric["name"],
    :start_time  => Time.now - START_TIME,
    :end_time    => Time.now,
    :period      => 60,
    :statistics  => metric["statistics"],
    :unit        => metric["unit"]
  )
  name = component_meta["namespace"].downcase
  name_metrics(resp, name, metric["statistics"])
end