Class: ATSD::SeriesService
- Inherits:
-
BaseService
- Object
- BaseService
- ATSD::SeriesService
- Defined in:
- lib/atsd/services/series_service.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#csv_insert(entity, data, tags = {}) ⇒ true
Series CSV: Insert.
-
#insert(series) ⇒ self
Insert time series.
-
#query(entity, metric, start_time, end_time, options = {}) ⇒ SeriesQuery
Create query builder for series.
Methods inherited from BaseService
Constructor Details
This class inherits a constructor from ATSD::BaseService
Class Method Details
.post_payload(config, payload) ⇒ Faraday::Response
Post json
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/atsd/services/series_service.rb', line 62 def self.post_payload(config,payload) url = config[:url] login, password = config[:login],config[:password] @connection = Faraday.new url do |builder| builder.headers['User-Agent'] = "ATSD Ruby Client v#{VERSION}" builder.basic_auth login, password builder.request :json builder.response :errors_handler builder.response :json, :content_type => 'application/json' builder.adapter Faraday.default_adapter end response = @connection.post do |req| req.body = payload end response end |
Instance Method Details
#csv_insert(entity, data, tags = {}) ⇒ true
Series CSV: Insert
52 53 54 55 |
# File 'lib/atsd/services/series_service.rb', line 52 def csv_insert(entity, data, = {}) entity = entity.name if entity.is_a? Entity @client.series_csv_insert(entity, data, ) end |
#insert(series) ⇒ self
Insert time series.
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.
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, = {}) query = SeriesQuery.new @client entity = entity.name if entity.is_a? Entity metric = metric.name if metric.is_a? Metric .merge! entity: entity, metric: metric, start_time: start_time, end_time: end_time .each { |option, value| query[option] = value } query end |