Class: Wavefront::Alert
Overview
View and manage alerts. Alerts are identified by their millisecond epoch timestamp. Returns a Wavefront::Response::Alert object.
Instance Attribute Summary
Attributes inherited from Base
#api_base, #conn, #debug, #logger, #net, #noop, #opts, #verbose
Instance Method Summary collapse
-
#create(body) ⇒ Wavefront::Response
POST /api/v2/alert Create a specific alert.
-
#delete(id) ⇒ Wavefront::Response
DELETE /api/v2/alert/id Delete a specific alert.
-
#describe(id, version = nil) ⇒ Wavefront::Response
GET /api/v2/alert/id GET /api/v2/alert/id/history/version Get a specific alert / Get a specific historical version of a specific alert.
-
#history(id, offset = nil, limit = nil) ⇒ Wavefront::Response
GET /api/v2/alert/id/history Get the version history of a specific alert.
-
#list(offset = 0, limit = 100) ⇒ Hash
GET /api/v2/alert Get all alerts for a customer.
-
#snooze(id, seconds = nil) ⇒ Wavefront::Response
POST /api/v2/alert/id/snooze Snooze a specific alert for some number of seconds.
-
#summary ⇒ Wavefront::Response
GET /api/v2/alert/summary Count alerts of various statuses for a customer.
-
#tag_add(id, tag) ⇒ Wavefront::Response
PUT /api/v2/alert/id/tag/tagValue Add a tag to a specific alert.
-
#tag_delete(id, tag) ⇒ Wavefront::Response
DELETE /api/v2/alert/id/tag/tagValue Remove a tag from a specific alert.
-
#tag_set(id, tags) ⇒ Wavefront::Response
POST /api/v2/alert/id/tag Set all tags associated with a specific alert.
-
#tags(id) ⇒ Wavefront::Response
GET /api/v2/alert/id/tag Get all tags associated with a specific alert.
-
#undelete(id) ⇒ Wavefront::Response
POST /api/v2/alert/id/undelete Undelete a specific alert.
-
#unsnooze(id) ⇒ Wavefront::Response
POST /api/v2/alert/id/unsnooze Unsnooze a specific alert.
-
#update(id, body, modify = true) ⇒ Wavefront::Response
PUT /api/v2/alert/id Update a specific alert.
- #update_keys ⇒ Object
Methods inherited from Base
#api_delete, #api_get, #api_post, #api_put, #hash_for_update, #initialize, #log, #mk_conn, #respond, #time_to_ms
Methods included from Mixins
Methods included from Validators
#wf_alert_id?, #wf_alert_severity?, #wf_cloudintegration_id?, #wf_dashboard_id?, #wf_epoch?, #wf_event_id?, #wf_granularity?, #wf_link_id?, #wf_link_template?, #wf_maintenance_window_id?, #wf_message_id?, #wf_metric_name?, #wf_ms_ts?, #wf_name?, #wf_point?, #wf_point_tags?, #wf_proxy_id?, #wf_savedsearch_entity?, #wf_savedsearch_id?, #wf_source_id?, #wf_string?, #wf_tag?, #wf_ts?, #wf_user_id?, #wf_value?, #wf_version?, #wf_webhook_id?
Constructor Details
This class inherits a constructor from Wavefront::Base
Instance Method Details
#create(body) ⇒ Wavefront::Response
POST /api/v2/alert Create a specific alert. We used to validate input here, but this couples the SDK too tightly to the API. Now it’s just a generic POST of a hash.
33 34 35 36 |
# File 'lib/wavefront-sdk/alert.rb', line 33 def create(body) raise ArgumentError unless body.is_a?(Hash) api_post('', body, 'application/json') end |
#delete(id) ⇒ Wavefront::Response
DELETE /api/v2/alert/id Delete a specific alert.
Deleting an active alert moves it to ‘trash’, from where it can be restored with an #undelete operation. Deleting an alert in ‘trash’ removes it for ever.
48 49 50 51 |
# File 'lib/wavefront-sdk/alert.rb', line 48 def delete(id) wf_alert_id?(id) api_delete(id) end |
#describe(id, version = nil) ⇒ Wavefront::Response
GET /api/v2/alert/id GET /api/v2/alert/id/history/version Get a specific alert / Get a specific historical version of a specific alert.
62 63 64 65 66 67 68 |
# File 'lib/wavefront-sdk/alert.rb', line 62 def describe(id, version = nil) wf_alert_id?(id) wf_version?(version) if version fragments = [id] fragments += ['history', version] if version api_get(fragments.uri_concat) end |
#history(id, offset = nil, limit = nil) ⇒ Wavefront::Response
GET /api/v2/alert/id/history Get the version history of a specific alert.
97 98 99 100 101 102 103 104 |
# File 'lib/wavefront-sdk/alert.rb', line 97 def history(id, offset = nil, limit = nil) wf_alert_id?(id) qs = {} qs[:offset] = offset if offset qs[:limit] = limit if limit api_get([id, 'history'].uri_concat, qs) end |
#list(offset = 0, limit = 100) ⇒ Hash
GET /api/v2/alert Get all alerts for a customer
21 22 23 |
# File 'lib/wavefront-sdk/alert.rb', line 21 def list(offset = 0, limit = 100) api_get('', { offset: offset, limit: limit }) end |
#snooze(id, seconds = nil) ⇒ Wavefront::Response
POST /api/v2/alert/id/snooze Snooze a specific alert for some number of seconds.
114 115 116 117 118 |
# File 'lib/wavefront-sdk/alert.rb', line 114 def snooze(id, seconds = nil) wf_alert_id?(id) qs = seconds ? "?seconds=#{seconds}" : '' api_post([id, "snooze#{qs}"].uri_concat, nil) end |
#summary ⇒ Wavefront::Response
GET /api/v2/alert/summary Count alerts of various statuses for a customer
198 199 200 |
# File 'lib/wavefront-sdk/alert.rb', line 198 def summary api_get('summary') end |
#tag_add(id, tag) ⇒ Wavefront::Response
PUT /api/v2/alert/id/tag/tagValue Add a tag to a specific alert.
165 166 167 168 169 |
# File 'lib/wavefront-sdk/alert.rb', line 165 def tag_add(id, tag) wf_alert_id?(id) wf_string?(tag) api_put([id, 'tag', tag].uri_concat) end |
#tag_delete(id, tag) ⇒ Wavefront::Response
DELETE /api/v2/alert/id/tag/tagValue Remove a tag from a specific alert.
152 153 154 155 156 |
# File 'lib/wavefront-sdk/alert.rb', line 152 def tag_delete(id, tag) wf_alert_id?(id) wf_string?(tag) api_delete([id, 'tag', tag].uri_concat) end |
#tag_set(id, tags) ⇒ Wavefront::Response
POST /api/v2/alert/id/tag Set all tags associated with a specific alert.
138 139 140 141 142 143 |
# File 'lib/wavefront-sdk/alert.rb', line 138 def tag_set(id, ) wf_alert_id?(id) = Array() .each { |t| wf_string?(t) } api_post([id, 'tag'].uri_concat, .to_json, 'application/json') end |
#tags(id) ⇒ Wavefront::Response
GET /api/v2/alert/id/tag Get all tags associated with a specific alert.
126 127 128 129 |
# File 'lib/wavefront-sdk/alert.rb', line 126 def (id) wf_alert_id?(id) api_get([id, 'tag'].uri_concat) end |
#undelete(id) ⇒ Wavefront::Response
POST /api/v2/alert/id/undelete Undelete a specific alert.
177 178 179 180 |
# File 'lib/wavefront-sdk/alert.rb', line 177 def undelete(id) wf_alert_id?(id) api_post([id, 'undelete'].uri_concat) end |
#unsnooze(id) ⇒ Wavefront::Response
POST /api/v2/alert/id/unsnooze Unsnooze a specific alert.
188 189 190 191 |
# File 'lib/wavefront-sdk/alert.rb', line 188 def unsnooze(id) wf_alert_id?(id) api_post([id, 'unsnooze'].uri_concat) end |
#update(id, body, modify = true) ⇒ Wavefront::Response
PUT /api/v2/alert/id Update a specific alert.
81 82 83 84 85 86 87 88 89 |
# File 'lib/wavefront-sdk/alert.rb', line 81 def update(id, body, modify = true) wf_alert_id?(id) raise ArgumentError unless body.is_a?(Hash) return api_put(id, body, 'application/json') unless modify api_put(id, hash_for_update(describe(id).response, body), 'application/json') end |
#update_keys ⇒ Object
9 10 11 12 |
# File 'lib/wavefront-sdk/alert.rb', line 9 def update_keys %i(id name target condition displayExpression minutes resolveAfterMinutes severity additionalInformation) end |