atsd 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9025f64163ec30e20c4a242935de58d36956fdee
4
- data.tar.gz: f9d451cb22a9b1c1cd8ee7cbb09d916538019543
3
+ metadata.gz: 743f931e95108681d4b1a2406db3501c14b78a66
4
+ data.tar.gz: 19f72e28217eecfa35c64c5dc6abb067467d6f4c
5
5
  SHA512:
6
- metadata.gz: efd37ea4a310e612b2df8b8417b8ae09fc5990703f8b569f33c1efbdd014d293f324cb9db6181c05eb6d1a092186cb0c3ac73b3e1e11613e0f5fe280dec643ab
7
- data.tar.gz: e73b69f0c386d4f073f3df4ce77418bc00f75df5d93d3599e73078ffbb39b05ddd13d5f5f2d050765f96a0de54331b5d7e1ec6e9ad24eb0386c817227f94536f
6
+ metadata.gz: 6ba9b9e316ee783810bab3ac05f38b46e42aa98d76d73ee923e7d4637762ca988cc0c98c2516dbebc66d67c0c0064819a5f8f5df77b0826029687c59baade927
7
+ data.tar.gz: 8f9ea0a7a2f5ffd1dfa5c806f335b3ddbd2a80e376c5538189320d83ba1596f6e4f253da80e1f09eaf16462f01d1506896899a1c2f093ed0f0ba29b11e8985ee
data/README.md CHANGED
@@ -68,8 +68,10 @@ Or install manually:
68
68
  To start using the gem you need to create an ATSD instance:
69
69
 
70
70
  ```ruby
71
- atsd = ATSD.new :url => '#{API_ENDPOINT}/api/v1',
72
- :basic_auth => '#{LOGIN}:#{PASSWORD}',
71
+ require 'atsd'
72
+ include ATSD
73
+ atsd = ATSD.new :url => "#{API_ENDPOINT}/api/v1",
74
+ :basic_auth => "#{LOGIN}:#{PASSWORD}",
73
75
  :logger => true
74
76
  ```
75
77
 
@@ -119,10 +121,10 @@ to CamelCase used in the API. For example, `end_time` property in ruby code beco
119
121
  Simple query:
120
122
 
121
123
  ```ruby
122
- series = atsd.series
124
+ series_service = atsd.series_service
123
125
  # => #<ATSD::SeriesService:0x007f82a4446c08
124
126
 
125
- query = series.query('ubuntu', 'meminfo.memfree')
127
+ query = series_service.query('ubuntu', 'meminfo.memfree')
126
128
  # => {:entity=>"ubuntu", :metric=>"meminfo.memfree"}
127
129
 
128
130
  query.class
@@ -154,7 +156,7 @@ s.entity
154
156
  Complex query:
155
157
 
156
158
  ```ruby
157
- query.aggregate(types:[ATSD::SeriesQuery::AggregateType::AVG], interval:{count:1, unit:ATSD::SeriesQuery::Interval::HOUR})
159
+ query.aggregate(types:[SeriesQuery::AggregateType::AVG], interval:{count:1, unit:SeriesQuery::Interval::HOUR})
158
160
  # => {:entity=>"ubuntu",
159
161
  # :metric=>"meminfo.memfree",
160
162
  # :end_time=>1428303004000,
@@ -169,14 +171,30 @@ query.execute
169
171
  # :data=>[{"t"=>1428300000000, "v"=>82615.05263157895}]}]
170
172
  ```
171
173
 
174
+ Query with Versions:
175
+
176
+ ```ruby
177
+ query = atsd.series_service.query("sensor-1", "temperature", Time.new(2015, 11, 17, 12, 0, 0), Time.new(2015, 11, 17, 19, 0, 0), {:versioned => true})
178
+ query.execute
179
+ ```
180
+
172
181
  Data Insertion:
173
182
 
174
183
  ```ruby
175
- s = ATSD::Series.new
184
+ s = Series.new
176
185
  s.entity = 'ubuntu'
177
186
  s.metric = 'meminfo.memfree'
178
187
  s.data = [ {t: 100000000, v: 512} ]
179
- series.insert(s)
188
+ series_service.insert(s)
189
+ ```
190
+
191
+ Inserting Series with Versions:
192
+
193
+ ```ruby
194
+ sample_1 = Sample.new :t => Time.new(2015, 11, 17, 17, 0, 0), :v => 7, :version => {:status => "normal", :source => "gateway-1"}
195
+ sample_2 = Sample.new :t => Time.new(2015, 11, 17, 18, 0, 0), :v => 17, :version => {:status => "error", :source => "gateway-1"}
196
+ series = Series.new :entity => "sensor-1", :metric => "temperature", :data => [sample_1, sample_2]
197
+ atsd.series_service.insert(series)
180
198
  ```
181
199
 
182
200
  **CSV Insert**
@@ -198,41 +216,41 @@ time, mem.info.memfree, meminfo.memused
198
216
 
199
217
  Inserting csv data example:
200
218
  ```ruby
201
- series.csv_insert('ubuntu', File.read('/path/to/data.csv'), { :user => 'beta' })
219
+ series_service.csv_insert('ubuntu', File.read('/path/to/data.csv'), { :user => 'beta' })
202
220
  ```
203
221
 
204
222
  #### Properties Service
205
223
 
206
224
  ```ruby
207
- props = atsd.properties
225
+ properties_service = atsd.properties_service
208
226
  # => #<ATSD::PropertiesService:0x007f82a456e6f8
209
227
 
210
- property = ATSD::Property.new
228
+ property = Property.new
211
229
  property.entity = 'ubuntu'
212
230
  property.type = 'system'
213
231
  property.key = {"server_name":"server","user_name":"system"}
214
232
  property.tags = {"name.1": "value.1"}
215
- props.insert(property)
233
+ properties_service.insert(property)
216
234
 
217
- props.query('ubuntu', 'system').execute
235
+ properties_service.query('ubuntu', 'system').execute
218
236
  # => [{:type=>"system",
219
237
  # :entity=>"ubuntu",
220
238
  # :key=>{"server_name"=>"server", "user_name"=>"system"},
221
239
  # :timestamp=>1428304255068,
222
240
  # :tags=>{"name.1"=>"value.1"}}]
223
241
 
224
- props.delete(property)
225
- props.query('ubuntu', 'system').execute
242
+ properties_service.delete(property)
243
+ properties_service.query('ubuntu', 'system').execute
226
244
  # => []
227
245
  ```
228
246
 
229
247
  #### Alerts Service
230
248
 
231
249
  ```ruby
232
- a = atsd.alerts
250
+ alerts_service = atsd.alerts_service
233
251
  # => #<ATSD::AlertsService:0x007faf7c0efdc0
234
252
 
235
- a.query.execute
253
+ alerts_service.query.execute
236
254
  # => [{:value=>447660.0,
237
255
  # :id=>4,
238
256
  # :text_value=>"447660",
@@ -258,10 +276,10 @@ a.query.execute
258
276
  #### Metrics Service
259
277
 
260
278
  ```ruby
261
- ms = atsd.metrics
279
+ metrics_service = atsd.metrics_service
262
280
  # => #<ATSD::MetricsService:0x007fbb548d9548
263
281
 
264
- ms.list
282
+ metrics_service.list
265
283
  # => [{:name=>"activemq_metrics_count",
266
284
  # :enabled=>true,
267
285
  # :data_type=>"FLOAT",
@@ -271,6 +289,7 @@ ms.list
271
289
  # :retention_interval=>0,
272
290
  # :invalid_action=>"NONE",
273
291
  # :last_insert_time=>1428328861848},
292
+ # :versioned=>true
274
293
  # {:name=>"activemq_properties_count",
275
294
  # :enabled=>true,
276
295
  # :data_type=>"FLOAT",
@@ -278,7 +297,7 @@ ms.list
278
297
  # :persistent=>true,
279
298
  # ...
280
299
 
281
- ms.entity_and_tags('df.disk_size')
300
+ metrics_service.entity_and_tags('df.disk_size')
282
301
  # => [{:entity=>"ubuntu", :tags=>{"file_system"=>"/dev/sda1", "mount_point"=>"/"}, :last_insert_time=>1428328928000},
283
302
  # {:entity=>"ubuntu",
284
303
  # :tags=>{"file_system"=>"none", "mount_point"=>"/sys/fs/cgroup"},
@@ -288,24 +307,35 @@ ms.entity_and_tags('df.disk_size')
288
307
  # {:entity=>"ubuntu", :tags=>{"file_system"=>"none", "mount_point"=>"/run/user"}, :last_insert_time=>1428328928000},
289
308
  # {:entity=>"ubuntu", :tags=>{"file_system"=>"udev", "mount_point"=>"/dev"}, :last_insert_time=>1428328928000},
290
309
  # {:entity=>"ubuntu", :tags=>{"file_system"=>"tmpfs", "mount_point"=>"/run"}, :last_insert_time=>1428328928000}]
310
+
311
+ metric = Metric.new
312
+ # => {}
313
+ metric.name = "cpu_count"
314
+ # => "cpu_count"
315
+ metric.versioned = true
316
+ # => true
317
+ metrics_service.create_or_replace(metric)
318
+ metrics_service.get("cpu_count")
319
+ # => {:name=>"cpu_count", :enabled=>true, :data_type=>"FLOAT", :counter=>false, :persistent=>true, :tags=>{}, :time_precision=>"MILLISECONDS", :retention_interval=>0, :invalid_action=>"NONE", :versioned=>true}
320
+
291
321
  ```
292
322
 
293
323
  #### Entities Service
294
324
 
295
325
  ```ruby
296
- ent = atsd.entities
326
+ entities_service = atsd.entities_service
297
327
  # => #<ATSD::EntitiesService:0x007f82a45b40b8
298
328
 
299
- ent.list
329
+ entities_service.list
300
330
  # => [{:name=>"atsd", :enabled=>true, :last_insert_time=>1428304482631},
301
331
  # {:name=>"mine", :enabled=>true},
302
332
  # {:name=>"test_entity", :enabled=>true, :last_insert_time=>1000000000},
303
333
  # {:name=>"ubuntu", :enabled=>true, :last_insert_time=>1428304489000}]
304
334
 
305
- ent.get('ubuntu')
335
+ entities_service.get('ubuntu')
306
336
  # => {:name=>"ubuntu", :enabled=>true, :last_insert_time=>1428304499000, :tags=>{}}
307
337
 
308
- ent.metrics('ubuntu')
338
+ entities_service.metrics('ubuntu')
309
339
  # => [{:name=>"df.disk_size",
310
340
  # :enabled=>true,
311
341
  # :data_type=>"FLOAT",
@@ -319,8 +349,8 @@ ent.metrics('ubuntu')
319
349
  # :enabled=>true,
320
350
  # ...
321
351
 
322
- ent.delete(ent.get('mine')) # or ent.delete('mine')
323
- ent.list
352
+ entities_service.delete(entities_service.get('mine')) # or entities_service.delete('mine')
353
+ entities_service.list
324
354
  # => [{:name=>"atsd", :enabled=>true, :last_insert_time=>1428304482631},
325
355
  # {:name=>"test_entity", :enabled=>true, :last_insert_time=>1000000000},
326
356
  # {:name=>"ubuntu", :enabled=>true, :last_insert_time=>1428304489000}]
@@ -328,19 +358,19 @@ ent.list
328
358
  #### Entity Groups Service
329
359
 
330
360
  ```ruby
331
- eg = atsd.entity_groups
361
+ entity_groups_service = atsd.entity_groups_service
332
362
  # => #<ATSD::EntityGroupsService:0x007fb1b2a0d7f8
333
363
 
334
- eg.create_or_replace('group1')
335
- eg.list
364
+ entity_groups_service.create_or_replace('group1')
365
+ entity_groups_service.list
336
366
  # => [{:name=>"group1"}]
337
367
 
338
- eg.add_entities('group1', [{name:'entity1'},{name:'entity2'}])
339
- eg.entities(eg.get('group1'))
368
+ entity_groups_service.add_entities('group1', [{name:'entity1'},{name:'entity2'}])
369
+ entity_groups_service.entities(entity_groups_service.get('group1'))
340
370
  # => [{:name=>"entity1", :enabled=>true}, {:name=>"entity2", :enabled=>true}]
341
371
 
342
- eg.delete_all_entities('group1')
343
- eg.entities('group1')
372
+ entity_groups_service.delete_all_entities('group1')
373
+ entity_groups_service.entities('group1')
344
374
  # => []
345
375
  ```
346
376
 
data/lib/atsd/atsd.rb CHANGED
@@ -44,11 +44,11 @@ module ATSD
44
44
  end
45
45
  end
46
46
 
47
- service :series, SeriesService
48
- service :properties, PropertiesService
49
- service :alerts, AlertsService
50
- service :metrics, MetricsService
51
- service :entities, EntitiesService
52
- service :entity_groups, EntityGroupsService
47
+ service :series_service, SeriesService
48
+ service :properties_service, PropertiesService
49
+ service :alerts_service, AlertsService
50
+ service :metrics_service, MetricsService
51
+ service :entities_service, EntitiesService
52
+ service :entity_groups_service, EntityGroupsService
53
53
  end
54
54
  end
@@ -5,6 +5,8 @@ module ATSD
5
5
  include ::Hashie::Extensions::MethodAccess
6
6
  include ::Hashie::Extensions::MergeInitializer
7
7
  include Utils::UnderscoreKeys
8
+ include ::Hashie::Extensions::Coercion
9
+
8
10
 
9
11
  # Converts model to hash usable for API
10
12
  #
@@ -18,6 +20,19 @@ module ATSD
18
20
  end
19
21
  hash
20
22
  end
23
+
24
+ # def method_missing(meth, *args, &block)
25
+ # action = meth[0, 3]
26
+ # field = meth[4..-1]
27
+ # case action
28
+ # when "get"
29
+ # return self.send(field)
30
+ # when "set"
31
+ # return self[field]=args[0]
32
+ # else
33
+ # super
34
+ # end
35
+ # end
21
36
  end
22
37
  end
23
38
 
@@ -2,6 +2,45 @@ require 'atsd/models/base_model'
2
2
 
3
3
  module ATSD
4
4
  class Entity < BaseModel
5
+ def set_name(name)
6
+ self["name"] = name
7
+ end
8
+
9
+ def get_name()
10
+ self.send("name")
11
+ end
12
+
13
+ def set_enabled(enabled)
14
+ self["enabled"] = enabled
15
+ end
16
+
17
+ def get_enabled()
18
+ self.send("enabled")
19
+ end
20
+
21
+ def set_last_insert_time(last_insert_time)
22
+ self["last_insert_time"] = last_insert_time
23
+ end
24
+
25
+ def get_last_insert_time()
26
+ self.send("last_insert_time")
27
+ end
28
+
29
+ def set_last_insert_date(last_insert_date)
30
+ self["last_insert_date"] = last_insert_date
31
+ end
32
+
33
+ def get_last_insert_date()
34
+ self.send("last_insert_date")
35
+ end
36
+
37
+ def set_tags(tags)
38
+ self["tags"] = tags
39
+ end
40
+
41
+ def get_tags()
42
+ self.send("tags")
43
+ end
5
44
  end
6
45
  end
7
46
 
@@ -3,6 +3,29 @@ require 'atsd/models/entity'
3
3
 
4
4
  module ATSD
5
5
  class EntityGroup < BaseModel
6
+ def set_name(name)
7
+ self["name"] = name
8
+ end
9
+
10
+ def get_name()
11
+ self.send("name")
12
+ end
13
+
14
+ def set_expression(expression)
15
+ self["expression"] = expression
16
+ end
17
+
18
+ def get_expression()
19
+ self.send("expression")
20
+ end
21
+
22
+ def set_tags(tags)
23
+ self["tags"] = tags
24
+ end
25
+
26
+ def get_tags()
27
+ self.send("tags")
28
+ end
6
29
  end
7
30
  end
8
31
 
@@ -2,6 +2,214 @@ require 'atsd/models/base_model'
2
2
 
3
3
  module ATSD
4
4
  class Metric < BaseModel
5
+
6
+ def set_name(name)
7
+ self["name"] = name
8
+ end
9
+
10
+ def get_name()
11
+ self.send("name")
12
+ end
13
+
14
+ def set_label(label)
15
+ self["label"] = label
16
+ end
17
+
18
+ def get_label()
19
+ self.send("label")
20
+ end
21
+
22
+ def set_enabled(enabled)
23
+ self["enabled"] = enabled
24
+ end
25
+
26
+ def get_enabled()
27
+ self.send("enabled")
28
+ end
29
+
30
+ def set_data_type(data_type)
31
+ self["data_type"] = data_type
32
+ end
33
+
34
+ def get_data_type()
35
+ self.send("data_type")
36
+ end
37
+
38
+ def set_time_precision(time_precision)
39
+ self["time_precision"] = time_precision
40
+ end
41
+
42
+ def get_time_precision()
43
+ self.send("time_precision")
44
+ end
45
+
46
+ def set_persistent(persistent)
47
+ self["persistent"] = persistent
48
+ end
49
+
50
+ def get_persistent()
51
+ self.send("persistent")
52
+ end
53
+
54
+ def set_counter(counter)
55
+ self["counter"] = counter
56
+ end
57
+
58
+ def get_counter()
59
+ self.send("counter")
60
+ end
61
+
62
+ def set_filter(filter)
63
+ self["filter"] = filter
64
+ end
65
+
66
+ def get_filter()
67
+ self.send("filter")
68
+ end
69
+
70
+ def set_min_value(min_value)
71
+ self["min_value"] = min_value
72
+ end
73
+
74
+ def get_min_value()
75
+ self.send("min_value")
76
+ end
77
+
78
+ def set_max_value(max_value)
79
+ self["max_value"] = max_value
80
+ end
81
+
82
+ def get_max_value()
83
+ self.send("max_value")
84
+ end
85
+
86
+ def set_invalid_action(invalid_action)
87
+ self["invalid_action"] = invalid_action
88
+ end
89
+
90
+ def get_invalid_action()
91
+ self.send("invalid_action")
92
+ end
93
+
94
+ def set_description(description)
95
+ self["description"] = description
96
+ end
97
+
98
+ def get_description()
99
+ self.send("description")
100
+ end
101
+
102
+ def set_retention_interval(retention_interval)
103
+ self["retention_interval"] = retention_interval
104
+ end
105
+
106
+ def get_retention_interval()
107
+ self.send("retention_interval")
108
+ end
109
+
110
+ def set_last_insert_time(last_insert_time)
111
+ self["last_insert_time"] = last_insert_time
112
+ end
113
+
114
+ def get_last_insert_time()
115
+ self.send("last_insert_time")
116
+ end
117
+
118
+ def get_last_insert_date()
119
+ Time.at(self.send("last_insert_time")/1000)
120
+ end
121
+
122
+ # def set_last_insert_date(last_insert_date)
123
+ # self["last_insert_date"] = last_insert_date
124
+ # end
125
+
126
+ def set_versioned(versioned)
127
+ self["versioned"] = versioned
128
+ end
129
+
130
+ def get_versioned()
131
+ self.send("versioned")
132
+ end
133
+
134
+ def set_tags(tags)
135
+ self["tags"] = tags
136
+ end
137
+
138
+ def get_tags()
139
+ self.send("tags")
140
+ end
141
+
142
+ end
143
+
144
+ module DataType
145
+ SHORT = 'SHORT'
146
+ INTEGER = 'INTEGER'
147
+ FLOAT = 'FLOAT'
148
+ LONG = 'LONG'
149
+ DOUBLE = 'DOUBLE'
150
+ end
151
+
152
+ module TimePrecision
153
+ SECONDS = 'SECONDS'
154
+ MILLISECONDS = 'MILLISECONDS'
155
+ end
156
+
157
+ module InvalidAction
158
+ NONE = 'NONE'
159
+ DISCARD = 'DISCARD'
160
+ TRANSFORM = 'TRANSFORM'
161
+ RAISE_ERROR = 'RAISE_ERROR'
5
162
  end
163
+
164
+ # class Enum
165
+ # def self.keys
166
+ # constants
167
+ # end
168
+ #
169
+ # def self.values
170
+ # @values ||= constants.map { |const| const_get(const) }
171
+ # end
172
+ # end
173
+ # class Enum
174
+ # def self.keys
175
+ # constants
176
+ # end
177
+ #
178
+ # def self.values
179
+ # @values ||= constants.map { |const| const_get(const) }
180
+ # end
181
+ # end
182
+ #
183
+ # class Data_Type < Enum
184
+ # SHORT='SHORT'
185
+ # INTEGER='INTEGER'
186
+ # FLOAT='FLOAT'
187
+ # LONG='LONG'
188
+ # DOUBLE='DOUBLE'
189
+ # end
190
+ #
191
+ # class Time_Precision < Enum
192
+ # SECONDS='SECONDS'
193
+ # MILLISECONDS='MILLISECONDS'
194
+ # end
195
+ #
196
+ # class Invalid_Action < Enum
197
+ # NONE='NONE'
198
+ # DISCARD='DISCARD'
199
+ # TRANSFORM='TRANSFORM'
200
+ # RAISE_ERROR='RAISE_ERROR'
201
+ # end
202
+
6
203
  end
7
204
 
205
+
206
+
207
+
208
+
209
+
210
+
211
+
212
+
213
+
214
+
215
+
@@ -4,5 +4,59 @@ module ATSD
4
4
  # Time Series model
5
5
  class Series < BaseModel
6
6
  end
7
+
8
+ class Sample < BaseModel
9
+
10
+ TO_MILLISECONDS_LAMBDA = ->(v) do
11
+ case v
12
+ when Time
13
+ v.to_i * 1_000
14
+ else
15
+ v.to_i
16
+ end
17
+ end
18
+
19
+ coerce_key :t, TO_MILLISECONDS_LAMBDA
20
+
21
+ def set_time(time)
22
+ self["t"] = time
23
+ end
24
+
25
+ def get_time()
26
+ self.send("t")
27
+ end
28
+
29
+ def get_date()
30
+ Time.at(self.send("t")/1000)
31
+ end
32
+
33
+ def set_value(value)
34
+ self["v"] = value
35
+ end
36
+
37
+ def get_value()
38
+ self.send("v")
39
+ end
40
+
41
+ end
42
+
43
+ class Version < BaseModel
44
+
45
+ def set_source(source)
46
+ self["source"] = source
47
+ end
48
+
49
+ def get_source()
50
+ self.send("source")
51
+ end
52
+
53
+ def set_status(status)
54
+ self["status"] = status
55
+ end
56
+
57
+ def get_status()
58
+ self.send("status")
59
+ end
60
+ end
7
61
  end
8
62
 
@@ -12,6 +12,22 @@ module ATSD
12
12
  @client = client
13
13
  end
14
14
 
15
+
16
+ # @!method type(type)
17
+ # specifies source for underlying data
18
+ # @param [String] type see {Type} for possible values
19
+ # @return [self]
20
+
21
+ TO_MILLISECONDS_LAMBDA = ->(v) do
22
+ case v
23
+ when Time
24
+ v.to_i * 1_000
25
+ else
26
+ v.to_i
27
+ end
28
+ end
29
+
30
+
15
31
  # Build request parameters hash
16
32
  # @return [Hash]
17
33
  def to_request_hash
@@ -31,6 +47,7 @@ module ATSD
31
47
  # @raise [APIError]
32
48
  def result
33
49
  @result ||= execute
50
+ @result
34
51
  end
35
52
 
36
53
  protected
@@ -4,97 +4,20 @@ module ATSD
4
4
  # Class for building and executing Series Query
5
5
  # @see https://axibase.com/atsd/api/#series:-query
6
6
  class SeriesQuery < BaseQuery
7
-
8
- # @!method type(type)
9
- # specifies source for underlying data
10
- # @param [String] type see {Type} for possible values
11
- # @return [self]
12
-
13
- # `type` parameter possible values
14
- module Type
15
- HISTORY = 'HISTORY' # default
16
- FORECAST = 'FORECAST'
17
- FORECAST_DEVIATION = 'FORECAST_DEVIATION'
18
- end
19
-
20
- # `join.type` parameter possible values
21
- module JoinType
22
- COUNT = 'COUNT'
23
- MIN = 'MIN'
24
- MAX = 'MAX'
25
- AVG = 'AVG'
26
- SUM = 'SUM'
27
- PERCENTILE_999 = 'PERCENTILE_999'
28
- PERCENTILE_995 = 'PERCENTILE_995'
29
- PERCENTILE_99 = 'PERCENTILE_99'
30
- PERCENTILE_95 = 'PERCENTILE_95'
31
- PERCENTILE_90 = 'PERCENTILE_90'
32
- PERCENTILE_75 = 'PERCENTILE_75'
33
- PERCENTILE_50 = 'PERCENTILE_50'
34
- STANDARD_DEVIATION = 'STANDARD_DEVIATION'
35
- end
36
-
37
- # `join.interpolate` parameter possible values
38
- module JoinInterpolate
39
- STEP = 'STEP' # default
40
- NONE = 'NONE'
41
- LINEAR = 'LINEAR'
42
- end
43
-
44
- # `aggregate.type` parameter possible values
45
- module AggregateType
46
- DETAIL = 'DETAIL'
47
- COUNT = 'COUNT'
48
- MIN = 'MIN'
49
- MAX = 'MAX'
50
- AVG = 'AVG'
51
- SUM = 'SUM'
52
- PERCENTILE_999 = 'PERCENTILE_999'
53
- PERCENTILE_995 = 'PERCENTILE_995'
54
- PERCENTILE_99 = 'PERCENTILE_99'
55
- PERCENTILE_95 = 'PERCENTILE_95'
56
- PERCENTILE_90 = 'PERCENTILE_90'
57
- PERCENTILE_75 = 'PERCENTILE_75'
58
- PERCENTILE_50 = 'PERCENTILE_50'
59
- STANDARD_DEVIATION = 'STANDARD_DEVIATION'
60
- FIRST = 'FIRST'
61
- LAST = 'LAST'
62
- DELTA = 'DELTA'
63
- WAVG = 'WAVG'
64
- WTAVG = 'WTAVG'
65
- THRESHOLD_COUNT = 'THRESHOLD_COUNT'
66
- THRESHOLD_DURATION = 'THRESHOLD_DURATION'
67
- THRESHOLD_PERCENT = 'THRESHOLD_PERCENT'
68
- end
69
-
70
- # `aggregate.interpolate` parameter possible values
71
- module AggregateInterpolate
72
- STEP = 'STEP'
73
- NONE = 'NONE'
74
- LINEAR = 'LINEAR'
75
- end
76
-
77
- # interval's unit possible values
78
- module Interval
79
- MILLISECOND = 'MILLISECOND'
80
- SECOND = 'SECOND'
81
- MINUTE = 'MINUTE'
82
- HOUR = 'HOUR'
83
- DAY = 'DAY'
84
- WEEK = 'WEEK'
85
- MONTH = 'MONTH'
86
- QUARTER = 'QUARTER'
87
- YEAR = 'YEAR'
88
- end
89
-
90
- TO_MILLISECONDS_LAMBDA = ->(v) do
91
- case v
92
- when Time
93
- v.to_i * 1_000
94
- else
95
- v.to_i
96
- end
97
- end
7
+ #
8
+ # # @!method type(type)
9
+ # # specifies source for underlying data
10
+ # # @param [String] type see {Type} for possible values
11
+ # # @return [self]
12
+ #
13
+ # TO_MILLISECONDS_LAMBDA = ->(v) do
14
+ # case v
15
+ # when Time
16
+ # v.to_i * 1_000
17
+ # else
18
+ # v.to_i
19
+ # end
20
+ # end
98
21
 
99
22
  coerce_key :end_time, TO_MILLISECONDS_LAMBDA
100
23
  coerce_key :start_time, TO_MILLISECONDS_LAMBDA
@@ -146,5 +69,83 @@ module ATSD
146
69
  results.each { |r| queries_by_id[r.request_id].result << r }
147
70
  end
148
71
  end
72
+
73
+ # `type` parameter possible values
74
+ module Type
75
+ HISTORY = 'HISTORY' # default
76
+ FORECAST = 'FORECAST'
77
+ FORECAST_DEVIATION = 'FORECAST_DEVIATION'
78
+ end
79
+
80
+ # `join.type` parameter possible values
81
+ module JoinType
82
+ COUNT = 'COUNT'
83
+ MIN = 'MIN'
84
+ MAX = 'MAX'
85
+ AVG = 'AVG'
86
+ SUM = 'SUM'
87
+ PERCENTILE_999 = 'PERCENTILE_999'
88
+ PERCENTILE_995 = 'PERCENTILE_995'
89
+ PERCENTILE_99 = 'PERCENTILE_99'
90
+ PERCENTILE_95 = 'PERCENTILE_95'
91
+ PERCENTILE_90 = 'PERCENTILE_90'
92
+ PERCENTILE_75 = 'PERCENTILE_75'
93
+ PERCENTILE_50 = 'PERCENTILE_50'
94
+ STANDARD_DEVIATION = 'STANDARD_DEVIATION'
95
+ end
96
+
97
+ # `join.interpolate` parameter possible values
98
+ module JoinInterpolate
99
+ STEP = 'STEP' # default
100
+ NONE = 'NONE'
101
+ LINEAR = 'LINEAR'
102
+ end
103
+
104
+ # `aggregate.type` parameter possible values
105
+ module AggregateType
106
+ DETAIL = 'DETAIL'
107
+ COUNT = 'COUNT'
108
+ MIN = 'MIN'
109
+ MAX = 'MAX'
110
+ AVG = 'AVG'
111
+ SUM = 'SUM'
112
+ PERCENTILE_999 = 'PERCENTILE_999'
113
+ PERCENTILE_995 = 'PERCENTILE_995'
114
+ PERCENTILE_99 = 'PERCENTILE_99'
115
+ PERCENTILE_95 = 'PERCENTILE_95'
116
+ PERCENTILE_90 = 'PERCENTILE_90'
117
+ PERCENTILE_75 = 'PERCENTILE_75'
118
+ PERCENTILE_50 = 'PERCENTILE_50'
119
+ STANDARD_DEVIATION = 'STANDARD_DEVIATION'
120
+ FIRST = 'FIRST'
121
+ LAST = 'LAST'
122
+ DELTA = 'DELTA'
123
+ WAVG = 'WAVG'
124
+ WTAVG = 'WTAVG'
125
+ THRESHOLD_COUNT = 'THRESHOLD_COUNT'
126
+ THRESHOLD_DURATION = 'THRESHOLD_DURATION'
127
+ THRESHOLD_PERCENT = 'THRESHOLD_PERCENT'
128
+ end
129
+
130
+ # `aggregate.interpolate` parameter possible values
131
+ module AggregateInterpolate
132
+ STEP = 'STEP'
133
+ NONE = 'NONE'
134
+ LINEAR = 'LINEAR'
135
+ end
136
+
137
+ # interval's unit possible values
138
+ module Interval
139
+ MILLISECOND = 'MILLISECOND'
140
+ SECOND = 'SECOND'
141
+ MINUTE = 'MINUTE'
142
+ HOUR = 'HOUR'
143
+ DAY = 'DAY'
144
+ WEEK = 'WEEK'
145
+ MONTH = 'MONTH'
146
+ QUARTER = 'QUARTER'
147
+ YEAR = 'YEAR'
148
+ end
149
+
149
150
  end
150
151
 
@@ -10,13 +10,15 @@ module ATSD
10
10
  #
11
11
  # @param [String, Entity] entity
12
12
  # @param [String, Metric] metric
13
+ # @param [Fixnum] start_time
14
+ # @param [Fixnum] end_time
13
15
  # @param [Hash] options other query parameters
14
16
  # @return [SeriesQuery]
15
- def query(entity, metric, options = {})
17
+ def query(entity, metric, start_time, end_time, options = {})
16
18
  query = SeriesQuery.new @client
17
19
  entity = entity.name if entity.is_a? Entity
18
20
  metric = metric.name if metric.is_a? Metric
19
- options.merge! entity: entity, metric: metric
21
+ options.merge! entity: entity, metric: metric, start_time: start_time, end_time: end_time
20
22
  options.each { |option, value| query[option] = value }
21
23
  query
22
24
  end
@@ -28,7 +30,9 @@ module ATSD
28
30
  # @raise [APIError]
29
31
  def insert(series)
30
32
  series = Utils.ensure_array(series).map do |s|
31
- s = Series.new(s) if s.is_a? Hash
33
+ if s.is_a? Hash
34
+ s = Series.new(s)
35
+ end
32
36
  s.to_request_hash
33
37
  end
34
38
  @client.series_insert series
data/lib/atsd/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module ATSD
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atsd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Axibase Corporation
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-04-17 00:00:00.000000000 Z
11
+ date: 2015-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -256,7 +256,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
256
256
  version: '0'
257
257
  requirements: []
258
258
  rubyforge_project:
259
- rubygems_version: 2.4.6
259
+ rubygems_version: 2.4.5.1
260
260
  signing_key:
261
261
  specification_version: 4
262
262
  summary: Axibase Time-Series Database Client for Ruby.