Class: Wavefront::Query
Overview
Query Wavefront metrics.
Instance Attribute Summary
Attributes inherited from Base
#conn, #debug, #logger, #net, #noop, #opts, #update_keys, #verbose
Instance Method Summary collapse
- #api_base ⇒ Object
-
#query(query, granularity = nil, t_start = nil, t_end = nil, options = {}) ⇒ Wavefront::Response
GET /api/v2/chart/api Perform a charting query against Wavefront servers that returns the appropriate points in the specified time window and granularity.
-
#raw(metric, source = nil, t_start = nil, t_end = nil) ⇒ Object
GET /api/v2/chart/raw Perform a raw data query against Wavefront servers that returns second granularity points grouped by tags.
-
#response_shim(body, status) ⇒ Object
Fake a response which looks like we get from all the other paths.
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
#api_base ⇒ Object
8 9 10 |
# File 'lib/wavefront-sdk/query.rb', line 8 def api_base 'chart' end |
#query(query, granularity = nil, t_start = nil, t_end = nil, options = {}) ⇒ Wavefront::Response
GET /api/v2/chart/api Perform a charting query against Wavefront servers that returns the appropriate points in the specified time window and granularity. Any options can be pased through in the options hash. This means the SDK does not have to closely track the API, but also means the burden of data validation is down to the user.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/wavefront-sdk/query.rb', line 31 def query(query, granularity = nil, t_start = nil, t_end = nil, = {}) raise ArgumentError unless query.is_a?(String) wf_granularity?(granularity) raise Wavefront::Exception::InvalidTimestamp if t_start.nil? [:q] = query [:g] = granularity [:s] = parse_time(t_start, true) [:e] = parse_time(t_end, true) if t_end .delete_if do |k, v| v == false && k != :i end api_get('api', ) end |
#raw(metric, source = nil, t_start = nil, t_end = nil) ⇒ Object
GET /api/v2/chart/raw Perform a raw data query against Wavefront servers that returns second granularity points grouped by tags
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/wavefront-sdk/query.rb', line 63 def raw(metric, source = nil, t_start = nil, t_end = nil) raise ArgumentError unless metric.is_a?(String) = { metric: metric, } if source wf_source_id?(source) [:source] = source end [:startTime] = parse_time(t_start, true) if t_start [:endTime] = parse_time(t_end, true) if t_end api_get('raw', ) end |
#response_shim(body, status) ⇒ Object
Fake a response which looks like we get from all the other paths. The default response is a single array.
82 83 84 85 86 87 88 |
# File 'lib/wavefront-sdk/query.rb', line 82 def response_shim(body, status) { response: JSON.parse(body), status: { result: status == 200 ? 'OK' : 'ERROR', message: '', code: status }, }.to_json end |