class Opentsdb::QueryParam
Attributes
aggregator[RW]
downsample[RW]
end_time[RW]
group[RW]
interval[RW]
metric[RW]
rate[RW]
rate_options[RW]
start_time[RW]
Public Class Methods
new(options = {})
click to toggle source
# File lib/opentsdb/query_param.rb, line 8 def initialize(options = {}) @aggregator = options[:aggregator] @rate = options[:rate] || false @metric = options[:metric] @tags = options[:tags] || {} @excluding_tags = options[:excluding_tags] || {} @rate_options = options[:rate_options] @group = options[:group] || [] @start_time = 0 @end_time = 0 end
Public Instance Methods
to_json()
click to toggle source
# File lib/opentsdb/query_param.rb, line 28 def to_json {}.tap do |h| h[:start] = start_time h[:end] = end_time h[:queries] = [queries] end.to_json end
Private Instance Methods
aggregator_for()
click to toggle source
# File lib/opentsdb/query_param.rb, line 66 def aggregator_for case aggregator when 'sum', 'avg' then 'avg' when 'min' then 'mimmin' when 'max' then 'mimmax' else 'avg' end end
queries()
click to toggle source
# File lib/opentsdb/query_param.rb, line 56 def queries {}.tap do |qh| qh[:aggregator] = aggregator qh[:rate] = rate qh[:metric] = metric qh[:tags] = to_query_tags qh[:downsample] = downsample if downsample end end
to_ms(time = Time.now)
click to toggle source
# File lib/opentsdb/query_param.rb, line 51 def to_ms(time = Time.now) time = time.is_a?(Fixnum) ? time : time.to_i time.to_s.ljust(13, '0').to_i # ms.to_size = 13 end