Class: Nephelae::CloudWatch
- Inherits:
-
Object
- Object
- Nephelae::CloudWatch
- Includes:
- Logging
- Defined in:
- lib/nephelae/cloud_watch/cloud_watch.rb
Instance Attribute Summary collapse
-
#aws_access_key_id ⇒ Object
Returns the value of attribute aws_access_key_id.
-
#aws_credentials_expire_at ⇒ Object
Returns the value of attribute aws_credentials_expire_at.
-
#aws_secret_access_key ⇒ Object
Returns the value of attribute aws_secret_access_key.
-
#aws_session_token ⇒ Object
Returns the value of attribute aws_session_token.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ CloudWatch
constructor
A new instance of CloudWatch.
- #put_metric(metric) ⇒ Object
- #request(params) ⇒ Object
Methods included from Logging
Constructor Details
#initialize(options = {}) ⇒ CloudWatch
Returns a new instance of CloudWatch.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/nephelae/cloud_watch/cloud_watch.rb', line 7 def initialize(={}) [:region] ||= 'us-east-1' @host = [:host] || "monitoring.#{options[:region]}.amazonaws.com" @path = [:path] || '/' @port = [:port] || 443 @scheme = [:scheme] || 'https' @aws_access_key_id = [:aws_access_key_id] @aws_secret_access_key = [:aws_secret_access_key] @aws_session_token = [:aws_session_token] @aws_credentials_expire_at = [:aws_credentials_expire_at] @url = "#{@scheme}://#{@host}:#{@port}#{@path}" end |
Instance Attribute Details
#aws_access_key_id ⇒ Object
Returns the value of attribute aws_access_key_id.
5 6 7 |
# File 'lib/nephelae/cloud_watch/cloud_watch.rb', line 5 def aws_access_key_id @aws_access_key_id end |
#aws_credentials_expire_at ⇒ Object
Returns the value of attribute aws_credentials_expire_at.
5 6 7 |
# File 'lib/nephelae/cloud_watch/cloud_watch.rb', line 5 def aws_credentials_expire_at @aws_credentials_expire_at end |
#aws_secret_access_key ⇒ Object
Returns the value of attribute aws_secret_access_key.
5 6 7 |
# File 'lib/nephelae/cloud_watch/cloud_watch.rb', line 5 def aws_secret_access_key @aws_secret_access_key end |
#aws_session_token ⇒ Object
Returns the value of attribute aws_session_token.
5 6 7 |
# File 'lib/nephelae/cloud_watch/cloud_watch.rb', line 5 def aws_session_token @aws_session_token end |
#url ⇒ Object
Returns the value of attribute url.
5 6 7 |
# File 'lib/nephelae/cloud_watch/cloud_watch.rb', line 5 def url @url end |
Instance Method Details
#put_metric(metric) ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/nephelae/cloud_watch/cloud_watch.rb', line 45 def put_metric(metric) params = metric.params unless params.nil? cw_output = request(metric.params) unless params.nil? log.info(cw_output) cw_output end end |
#request(params) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/nephelae/cloud_watch/cloud_watch.rb', line 22 def request(params) body = AWS.signed_params( params, { :aws_access_key_id => @aws_access_key_id, :aws_session_token => @aws_session_token, :aws_secret_access_key => @aws_secret_access_key, :host => @host, :path => @path, :port => @port, :version => '2010-08-01' } ) AWS.request(@url, { :body => body, :expects => 200, :headers => { 'Content-Type' => 'application/x-www-form-urlencoded' }, :host => @host, :method => 'POST' }) end |