Class: WavefrontDisplay::Query
- Defined in:
- lib/wavefront-cli/display/query.rb
Overview
Format human-readable output for queries.
Constant Summary
Constants included from WavefrontCli::Constants
WavefrontCli::Constants::ALL_PAGE_SIZE, WavefrontCli::Constants::DEFAULT_CONFIG, WavefrontCli::Constants::DEFAULT_OPTS, WavefrontCli::Constants::HUMAN_TIME_FORMAT, WavefrontCli::Constants::HUMAN_TIME_FORMAT_MS
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #do_aliases ⇒ Object
-
#do_default ⇒ Object
rubocop:disable Metrics/AbcSize.
- #do_raw ⇒ Object
- #do_raw_404 ⇒ Object
- #do_run ⇒ Object
- #mk_events(data) ⇒ Object
- #mk_timeseries(data) ⇒ Object
-
#prioritize_keys(data, _keys) ⇒ Object
Prioritizing keys does not make sense in this context.
Methods inherited from Base
#_prioritize_keys, #do_delete, #do_import, #do_list, #do_list_brief, #do_list_fields, #do_queries, #do_search, #do_search_brief, #do_tag_add, #do_tag_clear, #do_tag_delete, #do_tag_set, #do_tags, #do_undelete, #drop_fields, #filter_data, #filter_fields_as_arr, #friendly_name, #human_time, #initialize, #key_width, #long_output, #multicolumn, #pagination_line, #priority_keys, #readable_time, #readable_time_arr, #run, #run_error, #run_list, #run_search, #time_formats
Constructor Details
This class inherits a constructor from WavefrontDisplay::Base
Instance Method Details
#do_aliases ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/wavefront-cli/display/query.rb', line 61 def do_aliases if data.empty? puts 'No aliases defined.' else data.each_key { |k| puts k.to_s[2..-1] } end end |
#do_default ⇒ Object
rubocop:disable Metrics/AbcSize
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/wavefront-cli/display/query.rb', line 10 def do_default d_obj = { name: data.name, query: data.query, timeseries: mk_timeseries(data), events: mk_events(data) } if data.key?(:warnings) && ![:nowarn] d_obj[:warnings] = data[:warnings] end @data = d_obj long_output end |
#do_raw ⇒ Object
53 54 55 |
# File 'lib/wavefront-cli/display/query.rb', line 53 def do_raw data.each { |ts| puts humanize_series(ts[:points]).join("\n") } end |
#do_raw_404 ⇒ Object
57 58 59 |
# File 'lib/wavefront-cli/display/query.rb', line 57 def do_raw_404 puts 'API 404: metric does not exist.' end |
#do_run ⇒ Object
49 50 51 |
# File 'lib/wavefront-cli/display/query.rb', line 49 def do_run do_default end |
#mk_events(data) ⇒ Object
44 45 46 47 |
# File 'lib/wavefront-cli/display/query.rb', line 44 def mk_events(data) return [] unless data.key?(:events) data[:events].map { |s| humanize_event(s) } end |
#mk_timeseries(data) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/wavefront-cli/display/query.rb', line 31 def mk_timeseries(data) return [] unless data.key?(:timeseries) data[:timeseries].each do |s| unless [:nospark] s[:sparkline] = WavefrontSparkline.new(s[:data]).sparkline s.reorder!(label: nil, sparkline: nil) end s[:data] = humanize_series(s[:data]) end end |
#prioritize_keys(data, _keys) ⇒ Object
Prioritizing keys does not make sense in this context
27 28 29 |
# File 'lib/wavefront-cli/display/query.rb', line 27 def prioritize_keys(data, _keys) data end |