Class: ATSD::SeriesService

Inherits:
BaseService show all
Defined in:
lib/atsd/services/series_service.rb

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Constructor Details

This class inherits a constructor from ATSD::BaseService

Instance Method Details

#csv_insert(entity, data, tags = {}) ⇒ true

Series CSV: Insert

Parameters:

  • entity (String, Entity)
  • data (String)

    Payload - CSV containing time column and one or multiple metric columns.

    • Separator must be comma.

    • Time must be specified in Unix milliseconds.

    • Time column must be first, name of the time column could be arbitrary.

  • tags (Hash) (defaults to: {})

    tag=value hash

Returns:

  • (true)

Raises:



52
53
54
55
# File 'lib/atsd/services/series_service.rb', line 52

def csv_insert(entity, data, tags = {})
  entity = entity.name if entity.is_a? Entity
  @client.series_csv_insert(entity, data, tags)
end

#insert(series) ⇒ self

Insert time series.

Parameters:

Returns:

  • (self)

Raises:



31
32
33
34
35
36
37
38
39
40
# File 'lib/atsd/services/series_service.rb', line 31

def insert(series)
  series = Utils.ensure_array(series).map do |s|
    if s.is_a? Hash
      s = Series.new(s)
    end
    s.to_request_hash
  end
  @client.series_insert series
  self
end

#query(entity, metric, start_time, end_time, options = {}) ⇒ SeriesQuery

Create query builder for series.

Parameters:

  • entity (String, Entity)
  • metric (String, Metric)
  • start_time (Fixnum)
  • end_time (Fixnum)
  • options (Hash) (defaults to: {})

    other query parameters

Returns:



17
18
19
20
21
22
23
24
# File 'lib/atsd/services/series_service.rb', line 17

def query(entity, metric, start_time, end_time, options = {})
  query = SeriesQuery.new @client
  entity = entity.name if entity.is_a? Entity
  metric = metric.name if metric.is_a? Metric
  options.merge! entity: entity, metric: metric, start_time: start_time, end_time: end_time
  options.each { |option, value| query[option] = value }
  query
end