Class: Wavefront::Alerting
- Inherits:
-
Object
- Object
- Wavefront::Alerting
- Defined in:
- lib/wavefront/alerting.rb
Constant Summary collapse
- DEFAULT_HOST =
'metrics.wavefront.com'- DEFAULT_PATH =
'/api/alert/'
Instance Attribute Summary collapse
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #active(options = {}) ⇒ Object
- #affected_by_maintenance(options = {}) ⇒ Object
- #all(options = {}) ⇒ Object
- #get_alerts(path, options = {}) ⇒ Object
-
#initialize(token, debug = false) ⇒ Alerting
constructor
A new instance of Alerting.
- #invalid(options = {}) ⇒ Object
- #snoozed(options = {}) ⇒ Object
Constructor Details
#initialize(token, debug = false) ⇒ Alerting
Returns a new instance of Alerting.
30 31 32 33 |
# File 'lib/wavefront/alerting.rb', line 30 def initialize(token, debug=false) @token = token debug(debug) end |
Instance Attribute Details
#token ⇒ Object (readonly)
Returns the value of attribute token.
28 29 30 |
# File 'lib/wavefront/alerting.rb', line 28 def token @token end |
Instance Method Details
#active(options = {}) ⇒ Object
35 36 37 |
# File 'lib/wavefront/alerting.rb', line 35 def active(={}) get_alerts('active', ) end |
#affected_by_maintenance(options = {}) ⇒ Object
51 52 53 |
# File 'lib/wavefront/alerting.rb', line 51 def affected_by_maintenance(={}) get_alerts('affected_by_maintenance', ) end |
#all(options = {}) ⇒ Object
39 40 41 |
# File 'lib/wavefront/alerting.rb', line 39 def all(={}) get_alerts('all', ) end |
#get_alerts(path, options = {}) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/wavefront/alerting.rb', line 55 def get_alerts(path, ={}) [:host] ||= DEFAULT_HOST [:path] ||= DEFAULT_PATH query = "t=#{@token}" if [:shared_tags] = [:shared_tags].class == Array ? [:shared_tags] : [ [:shared_tags] ] # Force an array, even if string given query += "&#{.map{|t| "customerTag=#{t}"}.join('&')}" end if [:private_tags] = [:private_tags].class == Array ? [:private_tags] : [ [:private_tags] ] # Force an array, even if string given query += "&#{.map{|t| "userTag=#{t}"}.join('&')}" end uri = URI::HTTPS.build( host: [:host], path: File.join([:path], path), query: query ) RestClient.get(uri.to_s) end |
#invalid(options = {}) ⇒ Object
43 44 45 |
# File 'lib/wavefront/alerting.rb', line 43 def invalid(={}) get_alerts('invalid', ) end |
#snoozed(options = {}) ⇒ Object
47 48 49 |
# File 'lib/wavefront/alerting.rb', line 47 def snoozed(={}) get_alerts('snoozed', ) end |