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_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
rubocop:enable Metrics/AbcSize.
Methods inherited from Base
#do_delete, #do_import, #do_list, #do_list_brief, #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, #friendly_name, #human_time, #initialize, #key_width, #long_output, #multicolumn, #pagination_line, #put_id_first, #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
55 56 57 58 59 60 61 |
# File 'lib/wavefront-cli/display/query.rb', line 55 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
47 48 49 |
# File 'lib/wavefront-cli/display/query.rb', line 47 def do_raw data.each { |ts| puts humanize_series(ts[:points]).join("\n") } end |
#do_raw_404 ⇒ Object
51 52 53 |
# File 'lib/wavefront-cli/display/query.rb', line 51 def do_raw_404 puts 'API 404: metric does not exist.' end |
#do_run ⇒ Object
43 44 45 |
# File 'lib/wavefront-cli/display/query.rb', line 43 def do_run do_default end |
#mk_events(data) ⇒ Object
38 39 40 41 |
# File 'lib/wavefront-cli/display/query.rb', line 38 def mk_events(data) return [] unless data.key?(:events) data[:events].map { |s| humanize_event(s) } end |
#mk_timeseries(data) ⇒ Object
rubocop:enable Metrics/AbcSize
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/wavefront-cli/display/query.rb', line 25 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 |