Class: Opentsdb::QueryParam

Inherits:
Object
  • Object
show all
Defined in:
lib/opentsdb/query_param.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ QueryParam

Returns a new instance of QueryParam.



8
9
10
11
12
13
14
15
16
17
18
# 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

Instance Attribute Details

#aggregatorObject

Returns the value of attribute aggregator.



4
5
6
# File 'lib/opentsdb/query_param.rb', line 4

def aggregator
  @aggregator
end

#downsampleObject

Returns the value of attribute downsample.



4
5
6
# File 'lib/opentsdb/query_param.rb', line 4

def downsample
  @downsample
end

#end_timeObject

Returns the value of attribute end_time.



6
7
8
# File 'lib/opentsdb/query_param.rb', line 6

def end_time
  @end_time
end

#excluding_tagsObject

Returns the value of attribute excluding_tags.



5
6
7
# File 'lib/opentsdb/query_param.rb', line 5

def excluding_tags
  @excluding_tags
end

#groupObject

Returns the value of attribute group.



4
5
6
# File 'lib/opentsdb/query_param.rb', line 4

def group
  @group
end

#intervalObject

Returns the value of attribute interval.



4
5
6
# File 'lib/opentsdb/query_param.rb', line 4

def interval
  @interval
end

#metricObject

Returns the value of attribute metric.



4
5
6
# File 'lib/opentsdb/query_param.rb', line 4

def metric
  @metric
end

#rateObject

Returns the value of attribute rate.



4
5
6
# File 'lib/opentsdb/query_param.rb', line 4

def rate
  @rate
end

#rate_optionsObject

Returns the value of attribute rate_options.



4
5
6
# File 'lib/opentsdb/query_param.rb', line 4

def rate_options
  @rate_options
end

#start_timeObject

Returns the value of attribute start_time.



6
7
8
# File 'lib/opentsdb/query_param.rb', line 6

def start_time
  @start_time
end

#tagsObject

Returns the value of attribute tags.



4
5
6
# File 'lib/opentsdb/query_param.rb', line 4

def tags
  @tags
end

Instance Method Details

#to_jsonObject



28
29
30
31
32
33
34
# 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

#to_query_tagsObject



36
37
38
39
40
41
42
43
# File 'lib/opentsdb/query_param.rb', line 36

def to_query_tags
  {}.tap do |qtags|
    tags.each do |tagk, tagv|
      qtags[tagk] = tagv.to_a.compact.join('|') if tagv.is_a?(Array) || tagv.is_a?(Set)
      qtags[tagk] = '*' if tagv.nil? || tagv.empty?
    end
  end
end