atsd 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +113 -51
- data/lib/atsd/atsd.rb +2 -0
- data/lib/atsd/client.rb +111 -42
- data/lib/atsd/models/base_model.rb +7 -2
- data/lib/atsd/models/message.rb +7 -0
- data/lib/atsd/models/metric.rb +1 -0
- data/lib/atsd/models/series.rb +1 -8
- data/lib/atsd/queries/messages_query.rb +31 -0
- data/lib/atsd/services/alerts_service.rb +25 -0
- data/lib/atsd/services/entities_service.rb +11 -0
- data/lib/atsd/services/entity_groups_service.rb +1 -12
- data/lib/atsd/services/messages_service.rb +50 -0
- data/lib/atsd/services/metrics_service.rb +7 -10
- data/lib/atsd/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9048a6df918c13c0735a88772e2f6ec0efd03ebd
|
4
|
+
data.tar.gz: 7145ea2cfe5149d9c6e49f168f944158eb71dd46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 679adcba7de6756e40f1ed2ab250a537d2173be3b68bd8096cacd64211dbb2db1817c8be612e658326eb994e4ec1ac5eb2c7f81ddc0d18a5160a1f99fd515dd6
|
7
|
+
data.tar.gz: b56edd97517d94ab36e9fcc6e188a6f02f6fa9952f7b6aa0a887d78f0720cc8e47f2afcb23e92ab65ee48d117af096d48bcd5a8826fb07c90c4d1571dd229f71
|
data/README.md
CHANGED
@@ -26,42 +26,53 @@ Alternatively, you can install atsd gem manually:
|
|
26
26
|
|
27
27
|
### Data API
|
28
28
|
- Series
|
29
|
-
-
|
30
|
-
-
|
31
|
-
-
|
29
|
+
- query
|
30
|
+
- insert
|
31
|
+
- csv insert
|
32
|
+
- url query
|
32
33
|
- Properties
|
33
|
-
-
|
34
|
-
-
|
35
|
-
-
|
34
|
+
- query
|
35
|
+
- insert
|
36
|
+
- url query
|
37
|
+
- type query
|
38
|
+
- delete
|
39
|
+
- Messages
|
40
|
+
- insert
|
41
|
+
- query
|
42
|
+
- statistics
|
36
43
|
- Alerts
|
37
|
-
-
|
38
|
-
-
|
39
|
-
-
|
44
|
+
- query
|
45
|
+
- update
|
46
|
+
- delete
|
47
|
+
- history query
|
40
48
|
|
41
49
|
### Meta API
|
42
|
-
-
|
43
|
-
-
|
44
|
-
-
|
45
|
-
-
|
46
|
-
-
|
47
|
-
-
|
48
|
-
-
|
49
|
-
-
|
50
|
-
-
|
51
|
-
-
|
52
|
-
-
|
53
|
-
-
|
54
|
-
-
|
50
|
+
- Metric
|
51
|
+
- get
|
52
|
+
- list
|
53
|
+
- update
|
54
|
+
- create or replace
|
55
|
+
- delete
|
56
|
+
- series
|
57
|
+
- Entity
|
58
|
+
- get
|
59
|
+
- list
|
60
|
+
- update
|
61
|
+
- create or replace
|
62
|
+
- delete
|
63
|
+
- entity groups
|
64
|
+
- metrics
|
65
|
+
- property types
|
55
66
|
- Entity Group
|
56
|
-
-
|
57
|
-
-
|
58
|
-
-
|
59
|
-
-
|
60
|
-
-
|
61
|
-
-
|
62
|
-
-
|
63
|
-
-
|
64
|
-
-
|
67
|
+
- get
|
68
|
+
- list
|
69
|
+
- update
|
70
|
+
- create or replace
|
71
|
+
- delete
|
72
|
+
- get entities
|
73
|
+
- add entities
|
74
|
+
- replace entities
|
75
|
+
- delete entities
|
65
76
|
|
66
77
|
## Usage
|
67
78
|
|
@@ -102,6 +113,7 @@ The following services are currently implemented:
|
|
102
113
|
|
103
114
|
- series_service,
|
104
115
|
- properties_service,
|
116
|
+
- messages_service,
|
105
117
|
- alerts_service,
|
106
118
|
- metrics_service,
|
107
119
|
- entities_service,
|
@@ -215,7 +227,7 @@ Inserting series using Sample class:
|
|
215
227
|
s = Series.new
|
216
228
|
s.entity = 'sensor-1'
|
217
229
|
s.metric = 'pressure'
|
218
|
-
sample = Sample.new :
|
230
|
+
sample = Sample.new :date => "2015-11-17T17:00:00Z", :value => 7, :version => {:status => "normal", :source => "gateway-1"}
|
219
231
|
s.data = [ sample ]
|
220
232
|
series_service.insert(s)
|
221
233
|
```
|
@@ -223,8 +235,8 @@ series_service.insert(s)
|
|
223
235
|
Inserting Series with Versions:
|
224
236
|
|
225
237
|
```ruby
|
226
|
-
sample_1 = Sample.new :date =>
|
227
|
-
sample_2 = Sample.new :date =>
|
238
|
+
sample_1 = Sample.new :date => "2015-11-17T17:00:00Z", :value => 7, :version => {:status => "normal", :source => "gateway-1"}
|
239
|
+
sample_2 = Sample.new :date => "2015-11-17T18:00:00Z", :value => 17, :version => {:status => "error", :source => "gateway-1"}
|
228
240
|
series = Series.new :entity => "sensor-1", :metric => "pressure", :data => [sample_1, sample_2]
|
229
241
|
atsd.series_service.insert(series)
|
230
242
|
```
|
@@ -254,7 +266,7 @@ series_service.csv_insert('sensor-1', File.read('/path/to/data.csv'), { :user =>
|
|
254
266
|
Retrieving series values CSV and JSON format:
|
255
267
|
|
256
268
|
```ruby
|
257
|
-
series_service.url_query('json','nurswgvml007','cpu_busy', :startDate => 'previous_minute')
|
269
|
+
series_service.url_query('json','nurswgvml007','cpu_busy', :startDate => 'previous_minute', :endDate => 'now')
|
258
270
|
# => {"series"=>
|
259
271
|
# [{"entity"=>"nurswgvml007",
|
260
272
|
# "metric"=>"cpu_busy",
|
@@ -262,7 +274,7 @@ series_service.url_query('json','nurswgvml007','cpu_busy', :startDate => 'previo
|
|
262
274
|
# "type"=>"HISTORY",
|
263
275
|
# "aggregate"=>{"type"=>"DETAIL"},
|
264
276
|
# "data"=>[{"t"=>1464688814000, "v"=>3.03}, {"t"=>1464688830000, "v"=>5}, {"t"=>1464688846000, "v"=>9}, {"t"=>1464688862000, "v"=>4.04}, {"t"=>1464688878000, "v"=>5.05}]}]}
|
265
|
-
series_service.url_query('csv','nurswgvml007','cpu_busy', :startDate => 'previous_minute')
|
277
|
+
series_service.url_query('csv','nurswgvml007','cpu_busy', :startDate => 'previous_minute', :endDate => 'now')
|
266
278
|
=> "time,entity,metric,value\r\n1464688862000,nurswgvml007,cpu_busy,4.04\r\n1464688878000,nurswgvml007,cpu_busy,5.05\r\n1464688894000,nurswgvml007,cpu_busy,10.2\r\n1464688910000,nurswgvml007,cpu_busy,45.95\r\n1464688926000,nurswgvml007,cpu_busy,21.36\r\n1464688942000,nurswgvml007,cpu_busy,4.04\r\n"
|
267
279
|
```
|
268
280
|
|
@@ -275,7 +287,7 @@ properties_service = atsd.properties_service
|
|
275
287
|
property = Property.new :entity => 'sensor-1', :type => 'sensor_type', :tags => {"location":"NUR","site":"building-1"}, :key => {"id": "ch-15"}
|
276
288
|
properties_service.insert(property)
|
277
289
|
|
278
|
-
properties_service.query('sensor-1', 'sensor_type', :start_date =>
|
290
|
+
properties_service.query('sensor-1', 'sensor_type', :start_date => '2015-11-17T17:00:00Z', :end_date => '2016-01-17T17:00:00Z').execute
|
279
291
|
# => [{:type=>"sensor_type",
|
280
292
|
# :entity=>"sensor-1",
|
281
293
|
# :tags=>{"location"=>"NUR", "site"=>"building-1"},
|
@@ -283,7 +295,7 @@ properties_service.query('sensor-1', 'sensor_type', :start_date => "2015-11-17T1
|
|
283
295
|
# :key=>{"id"=>"ch-15"}}]
|
284
296
|
|
285
297
|
properties_service.delete(property)
|
286
|
-
properties_service.query('sensor-1', 'sensor_type', :start_date => '2015-11-17T17:00:00Z').execute
|
298
|
+
properties_service.query('sensor-1', 'sensor_type', :start_date => '2015-11-17T17:00:00Z', :end_date => '2016-01-17T17:00:00Z').execute
|
287
299
|
# => []
|
288
300
|
|
289
301
|
properties_service.type_query('sensor-1')
|
@@ -299,6 +311,42 @@ properties_service.url_query('nurswgvml007','network')
|
|
299
311
|
# {"type"=>"network", "entity"=>"nurswgvml007", "key"=>{"id"=>"lo"}, "tags"=>{"network_i/o.read-kb/s"=>"2.7", "network_i/o.write-kb/s"=>"2.7", "network_packets.read/s"=>"6.7", "network_packets.write/s"=>"6.7"}, "timestamp"=>1464680627000}]
|
300
312
|
|
301
313
|
|
314
|
+
```
|
315
|
+
#### Messages Service
|
316
|
+
|
317
|
+
```ruby
|
318
|
+
messages_service = atsd.messages_service
|
319
|
+
# => #<ATSD::MessagesService:0x000000024156e8
|
320
|
+
|
321
|
+
message = Message.new entity: "sensor-1", type: "logger", message: "Processing file"
|
322
|
+
messages_service.insert(message)
|
323
|
+
|
324
|
+
messages_service.query("sensor-1", :limit => 5, :endDate => "now", :interval => {:count => 5, :unit => "MINUTE"}).execute
|
325
|
+
# => [{"entity"=>"sensor-1", "type"=>"logger", "source"=>"default", "severity"=>"NORMAL", "message"=>"Processing file", "date"=>"2016-06-27T14:13:17.580Z"}]
|
326
|
+
|
327
|
+
messages_service.stats_query(:entity => "sensor-1", :startDate => "current_day", :endDate => "now")
|
328
|
+
# => [{"entity"=>"sensor-1", "metric"=>"message-count", "tags"=>{}, "type"=>"HISTORY", "aggregate"=>{"type"=>"COUNT", "interval"=>{"count"=>51363229, "unit"=>"MILLISECOND"}}, "data"=>[{"d"=>"2016-06-27T00:00:00.000Z", "v"=>1}]}]
|
329
|
+
|
330
|
+
messages_service.stats_query(:entity => "sensor-1", :startDate => "current_day", :endDate => "now", :groupKeys => "type")
|
331
|
+
# => [{"entity"=>"sensor-1", "metric"=>"message-count", "tags"=>{"type"=>"backup"}, "type"=>"HISTORY", "aggregate"=>{"type"=>"COUNT", "interval"=>{"count"=>50071806, "unit"=>"MILLISECOND"}}, "data"=>[{"d"=>"2016-06-27T00:00:00.000Z", "v"=>4}]},
|
332
|
+
# {"entity"=>"sensor-1", "metric"=>"message-count", "tags"=>{"type"=>"logger"}, "type"=>"HISTORY", "aggregate"=>{"type"=>"COUNT", "interval"=>{"count"=>50071806, "unit"=>"MILLISECOND"}}, "data"=>[{"d"=>"2016-06-27T00:00:00.000Z", "v"=>1485}]},
|
333
|
+
# {"entity"=>"sensor-1", "metric"=>"message-count", "tags"=>{"type"=>"security"}, "type"=>"HISTORY", "aggregate"=>{"type"=>"COUNT", "interval"=>{"count"=>50071806, "unit"=>"MILLISECOND"}}, "data"=>[{"d"=>"2016-06-27T00:00:00.000Z", "v"=>272}]}]
|
334
|
+
|
335
|
+
messages_service.stats_query(:entity => "sensor-1", :startDate => "current_day", :endDate => "now", "groupKeys" => "type", "aggregate" => {"type" => "COUNT", "period" => {"count" => 12, "unit" => "HOUR"}})
|
336
|
+
# => [{"entity"=>"sensor-1", "metric"=>"message-count", "tags"=>{"type"=>"backup"}, "type"=>"HISTORY", "aggregate"=>{"type"=>"COUNT", "period"=>{"count"=>12, "unit"=>"HOUR"}}, "data"=>[{"d"=>"2016-06-27T00:00:00.000Z", "v"=>4}]},
|
337
|
+
# {"entity"=>"sensor-1",
|
338
|
+
# "metric"=>"message-count",
|
339
|
+
# "tags"=>{"type"=>"logger"},
|
340
|
+
# "type"=>"HISTORY",
|
341
|
+
# "aggregate"=>{"type"=>"COUNT", "period"=>{"count"=>12, "unit"=>"HOUR"}},
|
342
|
+
# "data"=>[{"d"=>"2016-06-27T00:00:00.000Z", "v"=>1235}, {"d"=>"2016-06-27T12:00:00.000Z", "v"=>253}]},
|
343
|
+
# {"entity"=>"sensor-1",
|
344
|
+
# "metric"=>"message-count",
|
345
|
+
# "tags"=>{"type"=>"security"},
|
346
|
+
# "type"=>"HISTORY",
|
347
|
+
# "aggregate"=>{"type"=>"COUNT", "period"=>{"count"=>12, "unit"=>"HOUR"}},
|
348
|
+
# "data"=>[{"d"=>"2016-06-27T00:00:00.000Z", "v"=>232}, {"d"=>"2016-06-27T12:00:00.000Z", "v"=>40}]}]
|
349
|
+
|
302
350
|
```
|
303
351
|
|
304
352
|
#### Alerts Service
|
@@ -307,8 +355,7 @@ properties_service.url_query('nurswgvml007','network')
|
|
307
355
|
alerts_service = atsd.alerts_service
|
308
356
|
# => #<ATSD::AlertsService:0x007faf7c0efdc0
|
309
357
|
|
310
|
-
alerts_service.query(:entity => "sensor-1", :metrics => ["meminfo.active"], :start_date =>
|
311
|
-
alerts_service.query.execute
|
358
|
+
alerts_service.query(:entity => "sensor-1", :metrics => ["meminfo.active"], :start_date => '2015-11-17T17:00:00Z', :end_date => '2016-01-17T17:00:00Z').execute
|
312
359
|
# => [{"entity"=>"sensor-1",
|
313
360
|
# "tags"=>{},
|
314
361
|
# "repeatCount"=>79,
|
@@ -347,14 +394,16 @@ metrics_service.list(:limit => 10)
|
|
347
394
|
# :persistent=>true,
|
348
395
|
# ...
|
349
396
|
|
350
|
-
metrics_service.
|
351
|
-
# => [{
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
#
|
397
|
+
metrics_service.series("disk_used", "entity" => "nurswgvml007")
|
398
|
+
# => => [{"metric"=>"disk_used", "entity"=>"nurswgvml007", "tags"=>{"file_system"=>"/dev/mapper/vg_nurswgvml007-lv_root", "mount_point"=>"/"}, "lastInsertDate"=>"2016-06-21T11:47:17.000Z"},
|
399
|
+
{"metric"=>"disk_used", "entity"=>"nurswgvml007", "tags"=>{"file_system"=>"10.102.0.2:/home/store/share", "mount_point"=>"/mnt/share"}, "lastInsertDate"=>"2015-12-25T14:09:49.000Z"},
|
400
|
+
{"metric"=>"disk_used", "entity"=>"nurswgvml007", "tags"=>{"file_system"=>"//u113452.your-backup.de/backup", "mount_point"=>"/mnt/u113452"}, "lastInsertDate"=>"2016-06-21T11:47:17.000Z"}]
|
401
|
+
|
402
|
+
|
403
|
+
metrics_service.series("disk_used", "entity" => "nurswgvml007", "tags.mount_point" => "/")
|
404
|
+
# => [{"metric"=>"disk_used", "entity"=>"nurswgvml007",
|
405
|
+
"tags"=>{"file_system"=>"/dev/mapper/vg_nurswgvml007-lv_root", "mount_point"=>"/"},
|
406
|
+
"lastInsertDate"=>"2016-06-21T11:36:16.000Z"}]
|
358
407
|
|
359
408
|
metric = Metric.new
|
360
409
|
# => {}
|
@@ -402,6 +451,12 @@ entities_service.list
|
|
402
451
|
# => [{:name=>"atsd", :enabled=>true, :last_insert_time=>1428304482631},
|
403
452
|
# {:name=>"test_entity", :enabled=>true, :last_insert_time=>1000000000},
|
404
453
|
# {:name=>"sensor-1", :enabled=>true, :last_insert_time=>1428304489000}]
|
454
|
+
|
455
|
+
entities_service.entity_groups("nurswgvml007")
|
456
|
+
# => [{"name"=>"VMware VMs", "tags"=>{}},
|
457
|
+
# {"name"=>"java-loggers", "tags"=>{}},
|
458
|
+
# {"name"=>"java-virtual-machine", "tags"=>{}},
|
459
|
+
# {"name"=>"jetty-web-server", "tags"=>{}},
|
405
460
|
```
|
406
461
|
#### Entity Groups Service
|
407
462
|
|
@@ -414,12 +469,19 @@ entity_groups_service.list
|
|
414
469
|
# => [{:name=>"group1"}]
|
415
470
|
|
416
471
|
entity_groups_service.add_entities('group1', [{name:'entity1'},{name:'entity2'}])
|
417
|
-
entity_groups_service.
|
472
|
+
entity_groups_service.get_entities(entity_groups_service.get('group1'))
|
418
473
|
# => [{:name=>"entity1", :enabled=>true}, {:name=>"entity2", :enabled=>true}]
|
419
474
|
|
420
|
-
entity_groups_service.
|
421
|
-
entity_groups_service.
|
475
|
+
entity_groups_service.delete_entities('group1', [{name:'entity1'},{name:'entity2'}])
|
476
|
+
entity_groups_service.get_entities('group1')
|
422
477
|
# => []
|
478
|
+
|
479
|
+
entity_groups_service.get_entities("java-loggers", :limit => 3, :timeFormat => "iso")
|
480
|
+
# => [{"name"=>"-last-https-test-drive", "enabled"=>true, "lastInsertDate"=>"2016-05-19T11:22:05.710Z"},
|
481
|
+
# {"name"=>"12364bc005b2", "enabled"=>true, "lastInsertDate"=>"2016-05-19T22:26:50.432Z"},
|
482
|
+
# {"name"=>"1d99e87f5a89", "enabled"=>true, "lastInsertDate"=>"2016-04-18T16:53:51.563Z"}]
|
483
|
+
|
484
|
+
|
423
485
|
```
|
424
486
|
|
425
487
|
### Errors
|
data/lib/atsd/atsd.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'atsd/client'
|
2
2
|
require 'atsd/services/series_service'
|
3
3
|
require 'atsd/services/properties_service'
|
4
|
+
require 'atsd/services/messages_service'
|
4
5
|
require 'atsd/services/alerts_service'
|
5
6
|
require 'atsd/services/metrics_service'
|
6
7
|
require 'atsd/services/entities_service'
|
@@ -46,6 +47,7 @@ module ATSD
|
|
46
47
|
|
47
48
|
service :series_service, SeriesService
|
48
49
|
service :properties_service, PropertiesService
|
50
|
+
service :messages_service, MessagesService
|
49
51
|
service :alerts_service, AlertsService
|
50
52
|
service :metrics_service, MetricsService
|
51
53
|
service :entities_service, EntitiesService
|
data/lib/atsd/client.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'atsd/middleware/errors_handler'
|
2
2
|
require 'active_support/core_ext/hash/keys'
|
3
|
+
require 'uri'
|
3
4
|
|
4
5
|
module ATSD
|
5
6
|
|
@@ -42,6 +43,7 @@ module ATSD
|
|
42
43
|
# @param [Hash, Array<Hash>] queries query or array of queries
|
43
44
|
# @return [Array<Hash>] time series
|
44
45
|
# @raise [APIError]
|
46
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/data/series/query.md for details
|
45
47
|
def series_query(queries)
|
46
48
|
response = @connection.post 'series/query', Utils.ensure_array(queries)
|
47
49
|
response.body
|
@@ -55,10 +57,10 @@ module ATSD
|
|
55
57
|
# @param [Hash] parameters other query parameters
|
56
58
|
# @return [Array<Hash>] time series
|
57
59
|
# @raise [APIError]
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
response = @connection.get url
|
60
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/data/series/url-query.md for details
|
61
|
+
def series_url_query(format, entity, metric, parameters ={})
|
62
|
+
url = "series/#{CGI.escape(format)}/#{CGI.escape(entity)}/#{CGI.escape(metric)}?"
|
63
|
+
response = @connection.get url, parameters
|
62
64
|
response.body
|
63
65
|
end
|
64
66
|
|
@@ -67,6 +69,7 @@ module ATSD
|
|
67
69
|
# @param [Hash, Array<Hash>] series series or array of series
|
68
70
|
# @return true
|
69
71
|
# @raise [APIError]
|
72
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/data/series/insert.md for details
|
70
73
|
def series_insert(series)
|
71
74
|
@connection.post 'series/insert', Utils.ensure_array(series)
|
72
75
|
true
|
@@ -82,9 +85,10 @@ module ATSD
|
|
82
85
|
# @param [Hash] tags tag=value hash
|
83
86
|
# @return [true]
|
84
87
|
# @raise [APIError]
|
88
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/data/series/csv-insert.md for details
|
85
89
|
def series_csv_insert(entity, data, tags = {})
|
86
90
|
request = @connection.build_request(:post) do |req|
|
87
|
-
req.url("series/csv/#{entity}", tags)
|
91
|
+
req.url("series/csv/#{CGI.escape(entity)}", tags)
|
88
92
|
req.headers["Content-Type"] = 'text/csv'
|
89
93
|
req.body = data
|
90
94
|
end
|
@@ -93,11 +97,46 @@ module ATSD
|
|
93
97
|
true
|
94
98
|
end
|
95
99
|
|
100
|
+
# Query messages
|
101
|
+
#
|
102
|
+
# @param [Hash, Array<Hash>] queries query or array of queries
|
103
|
+
# @return [Array<Hash>] array of messages
|
104
|
+
# @raise [APIError]
|
105
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/data/messages/query.md for details
|
106
|
+
def messages_query(queries = nil)
|
107
|
+
response = @connection.post 'messages/query', Utils.ensure_array(queries)
|
108
|
+
response.body
|
109
|
+
end
|
110
|
+
|
111
|
+
# Insert messages
|
112
|
+
#
|
113
|
+
# @param [Hash, Array<Hash>] messages message or array of messages
|
114
|
+
# @return true
|
115
|
+
# @raise [APIError]
|
116
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/data/messages/insert.md for details
|
117
|
+
def messages_insert(messages)
|
118
|
+
@connection.post 'messages/insert', Utils.ensure_array(messages)
|
119
|
+
true
|
120
|
+
end
|
121
|
+
|
122
|
+
# Statistics query
|
123
|
+
#
|
124
|
+
# @param [Hash] parameters
|
125
|
+
# @return [Array<Hash>] time series
|
126
|
+
# @raise [APIError]
|
127
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/data/messages/stats-query.md for details
|
128
|
+
def messages_stat_query(parameters = {})
|
129
|
+
print parameters
|
130
|
+
response = @connection.post 'messages/stats/query', Utils.ensure_array(parameters)
|
131
|
+
response.body
|
132
|
+
end
|
133
|
+
|
96
134
|
# Query properties
|
97
135
|
#
|
98
136
|
# @param [Hash, Array<Hash>] queries query or array of queries
|
99
137
|
# @return [Array<Hash>] array of properties
|
100
138
|
# @raise [APIError]
|
139
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/data/properties/query.md for details
|
101
140
|
def properties_query(queries = nil)
|
102
141
|
response = @connection.post 'properties/query', Utils.ensure_array(queries)
|
103
142
|
response.body
|
@@ -109,18 +148,20 @@ module ATSD
|
|
109
148
|
# @param [String] type
|
110
149
|
# @return [Array<Hash>] array of properties
|
111
150
|
# @raise [APIError]
|
151
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/data/properties/url-query.md for details
|
112
152
|
def properties_for_entity_and_type(entity, type)
|
113
|
-
response = @connection.get "properties/#{entity}/types/#{type}"
|
153
|
+
response = @connection.get "properties/#{CGI.escape(entity)}/types/#{CGI.escape(type)}"
|
114
154
|
response.body
|
115
155
|
end
|
116
156
|
|
117
157
|
# Returns array of property types for the entity.
|
118
158
|
#
|
119
|
-
# @param [String]
|
159
|
+
# @param [String] entity
|
120
160
|
# @return [Array<Hash>] array of properties
|
121
161
|
# @raise [APIError]
|
162
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/data/properties/type-query.md for details
|
122
163
|
def properties_for_entity(entity)
|
123
|
-
response = @connection.get "properties/#{entity}/types"
|
164
|
+
response = @connection.get "properties/#{CGI.escape(entity)}/types"
|
124
165
|
response.body
|
125
166
|
end
|
126
167
|
|
@@ -129,6 +170,7 @@ module ATSD
|
|
129
170
|
# @param [Hash, Array<Hash>] properties property or array of properties
|
130
171
|
# @return true
|
131
172
|
# @raise [APIError]
|
173
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/data/properties/insert.md for details
|
132
174
|
def properties_insert(properties)
|
133
175
|
@connection.post 'properties/insert', Utils.ensure_array(properties)
|
134
176
|
true
|
@@ -139,6 +181,7 @@ module ATSD
|
|
139
181
|
# @param [Hash, Array<Hash>] properties
|
140
182
|
# @return true
|
141
183
|
# @raise [APIError]
|
184
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/data/properties/delete.md for details
|
142
185
|
def properties_delete(properties)
|
143
186
|
@connection.post 'properties/delete', Utils.ensure_array(properties)
|
144
187
|
end
|
@@ -148,6 +191,7 @@ module ATSD
|
|
148
191
|
# @param [Hash, Array<Hash>] queries query or array of queries
|
149
192
|
# @return [Array<Hash>] alerts
|
150
193
|
# @raise [APIError]
|
194
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/data/alerts/query.md for details
|
151
195
|
def alerts_query(queries = nil)
|
152
196
|
response = @connection.post 'alerts/query', Utils.ensure_array(queries)
|
153
197
|
response.body
|
@@ -158,6 +202,7 @@ module ATSD
|
|
158
202
|
# @param [Hash, Array<Hash>] actions action or array of actions
|
159
203
|
# @return [true]
|
160
204
|
# @raise [APIError]
|
205
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/data/alerts/update.md for details
|
161
206
|
def alerts_update(actions)
|
162
207
|
@connection.post 'alerts/update', Utils.ensure_array(actions)
|
163
208
|
true
|
@@ -168,6 +213,7 @@ module ATSD
|
|
168
213
|
# @param [Hash, Array<Hash>] actions action or array of actions
|
169
214
|
# @return [true]
|
170
215
|
# @raise [APIError]
|
216
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/data/alerts/delete.md for details
|
171
217
|
def alerts_delete(actions)
|
172
218
|
@connection.post 'alerts/delete', Utils.ensure_array(actions)
|
173
219
|
true
|
@@ -178,6 +224,7 @@ module ATSD
|
|
178
224
|
# @param [Hash, Array<Hash>] queries query or array of queries
|
179
225
|
# @return [Array<Hash>] history records
|
180
226
|
# @raise [APIError]
|
227
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/data/alerts/history-query.md for details
|
181
228
|
def alerts_history_query(queries = nil)
|
182
229
|
response = @connection.post 'alerts/history/query', Utils.ensure_array(queries)
|
183
230
|
response.body
|
@@ -188,6 +235,7 @@ module ATSD
|
|
188
235
|
# @param [Hash] parameters
|
189
236
|
# @return [Array<Hash>]
|
190
237
|
# @raise [APIError]
|
238
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/meta/metric/list.md for details
|
191
239
|
def metrics_list(parameters = {})
|
192
240
|
response = @connection.get 'metrics', parameters
|
193
241
|
response.body
|
@@ -198,8 +246,9 @@ module ATSD
|
|
198
246
|
# @param [String] metric
|
199
247
|
# @return [Hash]
|
200
248
|
# @raise [APIError]
|
249
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/meta/metric/get.md for details
|
201
250
|
def metrics_get(metric)
|
202
|
-
response = @connection.get "metrics/#{metric}"
|
251
|
+
response = @connection.get "metrics/#{CGI.escape(metric)}"
|
203
252
|
response.body
|
204
253
|
end
|
205
254
|
|
@@ -213,8 +262,9 @@ module ATSD
|
|
213
262
|
# @param [Hash] body
|
214
263
|
# @return [true]
|
215
264
|
# @raise [APIError]
|
265
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/meta/metric/create-or-replace.md for details
|
216
266
|
def metrics_create_or_replace(metric, body)
|
217
|
-
@connection.put "metrics/#{metric}", body
|
267
|
+
@connection.put "metrics/#{CGI.escape(metric)}", body
|
218
268
|
true
|
219
269
|
end
|
220
270
|
|
@@ -227,8 +277,9 @@ module ATSD
|
|
227
277
|
# @param [Hash] body
|
228
278
|
# @return [true]
|
229
279
|
# @raise [APIError]
|
280
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/meta/metric/update.md for details
|
230
281
|
def metrics_update(metric, body)
|
231
|
-
@connection.patch "metrics/#{metric}", body
|
282
|
+
@connection.patch "metrics/#{CGI.escape(metric)}", body
|
232
283
|
true
|
233
284
|
end
|
234
285
|
|
@@ -238,20 +289,22 @@ module ATSD
|
|
238
289
|
# @param [String] metric
|
239
290
|
# @return [true]
|
240
291
|
# @raise [APIError]
|
292
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/meta/metric/delete.md for details
|
241
293
|
def metrics_delete(metric)
|
242
|
-
@connection.delete "metrics/#{metric}"
|
294
|
+
@connection.delete "metrics/#{CGI.escape(metric)}"
|
243
295
|
true
|
244
296
|
end
|
245
297
|
|
246
|
-
# Returns a list of
|
247
|
-
#
|
298
|
+
# Returns a list of series for the metric.
|
299
|
+
# Each series is identified with metric name, entity name, and optional series tags.
|
248
300
|
#
|
249
301
|
# @param [String] metric
|
250
302
|
# @param [Hash] parameters
|
251
303
|
# @return [Array]
|
252
304
|
# @raise [APIError]
|
253
|
-
|
254
|
-
|
305
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/meta/metric/series.md for details
|
306
|
+
def metrics_series(metric, parameters = {})
|
307
|
+
response = @connection.get "metrics/#{CGI.escape(metric)}/series", parameters
|
255
308
|
response.body
|
256
309
|
end
|
257
310
|
|
@@ -260,6 +313,7 @@ module ATSD
|
|
260
313
|
# @param [Hash] parameters
|
261
314
|
# @return [Array<Hash>]
|
262
315
|
# @raise [APIError]
|
316
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/meta/entity/list.md for details
|
263
317
|
def entities_list(parameters = {})
|
264
318
|
response = @connection.get 'entities', parameters
|
265
319
|
response.body
|
@@ -270,8 +324,9 @@ module ATSD
|
|
270
324
|
# @param [String] entity
|
271
325
|
# @return [Hash]
|
272
326
|
# @raise [APIError]
|
327
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/meta/entity/get.md for details
|
273
328
|
def entities_get(entity)
|
274
|
-
response = @connection.get "entities/#{entity}"
|
329
|
+
response = @connection.get "entities/#{CGI.escape(entity)}"
|
275
330
|
response.body
|
276
331
|
end
|
277
332
|
|
@@ -281,8 +336,9 @@ module ATSD
|
|
281
336
|
# @param [Hash] body
|
282
337
|
# @return [true]
|
283
338
|
# @raise [APIError]
|
339
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/meta/entity/create-or-replace.md for details
|
284
340
|
def entities_create_or_replace(entity, body)
|
285
|
-
@connection.put "entities/#{entity}", body
|
341
|
+
@connection.put "entities/#{CGI.escape(entity)}", body
|
286
342
|
true
|
287
343
|
end
|
288
344
|
|
@@ -292,8 +348,9 @@ module ATSD
|
|
292
348
|
# @param [Hash] body
|
293
349
|
# @return [true]
|
294
350
|
# @raise [APIError]
|
351
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/meta/entity/update.md for details
|
295
352
|
def entities_update(entity, body)
|
296
|
-
@connection.patch "entities/#{entity}", body
|
353
|
+
@connection.patch "entities/#{CGI.escape(entity)}", body
|
297
354
|
true
|
298
355
|
end
|
299
356
|
|
@@ -302,19 +359,32 @@ module ATSD
|
|
302
359
|
# @param [String] entity
|
303
360
|
# @return [true]
|
304
361
|
# @raise [APIError]
|
362
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/meta/entity/delete.md for details
|
305
363
|
def entities_delete(entity)
|
306
|
-
@connection.delete "entities/#{entity}"
|
364
|
+
@connection.delete "entities/#{CGI.escape(entity)}"
|
307
365
|
true
|
308
366
|
end
|
309
367
|
|
368
|
+
# Entity groups entity.
|
369
|
+
#
|
370
|
+
# @param [String] entity
|
371
|
+
# @return [Array]
|
372
|
+
# @raise [APIError]
|
373
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/meta/entity/entity-groups.md for details
|
374
|
+
def entities_entity_groups(entity, parameters = {})
|
375
|
+
response = @connection.get "entities/#{CGI.escape(entity)}/groups", parameters
|
376
|
+
response.body
|
377
|
+
end
|
378
|
+
|
310
379
|
# Property types for entity
|
311
380
|
#
|
312
381
|
# @param [String] entity
|
313
382
|
# @param [Hash] parameters
|
314
383
|
# @return [Array]
|
315
384
|
# @raise [APIError]
|
385
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/meta/entity/property-types.md for details
|
316
386
|
def entities_property_types(entity, parameters = {})
|
317
|
-
response = @connection.get "entities/#{entity}/property-types", parameters
|
387
|
+
response = @connection.get "entities/#{CGI.escape(entity)}/property-types", parameters
|
318
388
|
response.body
|
319
389
|
end
|
320
390
|
|
@@ -324,8 +394,9 @@ module ATSD
|
|
324
394
|
# @param [Hash] parameters
|
325
395
|
# @return [Array]
|
326
396
|
# @raise [APIError]
|
397
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/meta/entity/metrics.md for details
|
327
398
|
def entities_metrics(entity, parameters = {})
|
328
|
-
response = @connection.get "entities/#{entity}/metrics", parameters
|
399
|
+
response = @connection.get "entities/#{CGI.escape(entity)}/metrics", parameters
|
329
400
|
response.body
|
330
401
|
end
|
331
402
|
|
@@ -334,6 +405,7 @@ module ATSD
|
|
334
405
|
# @param [Hash] parameters
|
335
406
|
# @return [Array]
|
336
407
|
# @raise [APIError]
|
408
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/meta/entity-group/list.md for details
|
337
409
|
def entity_groups_list(parameters = {})
|
338
410
|
response = @connection.get 'entity-groups', parameters
|
339
411
|
response.body
|
@@ -344,8 +416,9 @@ module ATSD
|
|
344
416
|
# @param [String] entity_group
|
345
417
|
# @return [Hash]
|
346
418
|
# @raise [APIError]
|
419
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/meta/entity-group/get.md for details
|
347
420
|
def entity_groups_get(entity_group)
|
348
|
-
response = @connection.get "entity-groups/#{entity_group}"
|
421
|
+
response = @connection.get "entity-groups/#{CGI.escape(entity_group)}"
|
349
422
|
response.body
|
350
423
|
end
|
351
424
|
|
@@ -355,8 +428,9 @@ module ATSD
|
|
355
428
|
# @param [Hash] body
|
356
429
|
# @return [true]
|
357
430
|
# @raise [APIError]
|
431
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/meta/entity-group/create-or-replace.md for details
|
358
432
|
def entity_groups_create_or_replace(entity_group, body)
|
359
|
-
@connection.put "entity-groups/#{entity_group}", body
|
433
|
+
@connection.put "entity-groups/#{CGI.escape(entity_group)}", body
|
360
434
|
true
|
361
435
|
end
|
362
436
|
|
@@ -366,8 +440,9 @@ module ATSD
|
|
366
440
|
# @param [Hash] body
|
367
441
|
# @return [true]
|
368
442
|
# @raise [APIError]
|
443
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/meta/entity-group/update.md for details
|
369
444
|
def entity_groups_update(entity_group, body)
|
370
|
-
@connection.patch "entity-groups/#{entity_group}", body
|
445
|
+
@connection.patch "entity-groups/#{CGI.escape(entity_group)}", body
|
371
446
|
true
|
372
447
|
end
|
373
448
|
|
@@ -376,8 +451,9 @@ module ATSD
|
|
376
451
|
# @param [String] entity_group
|
377
452
|
# @return [true]
|
378
453
|
# @raise [APIError]
|
454
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/meta/entity-group/delete.md for details
|
379
455
|
def entity_groups_delete(entity_group)
|
380
|
-
@connection.delete "entity-groups/#{entity_group}"
|
456
|
+
@connection.delete "entity-groups/#{CGI.escape(entity_group)}"
|
381
457
|
true
|
382
458
|
end
|
383
459
|
|
@@ -387,8 +463,9 @@ module ATSD
|
|
387
463
|
# @param [Hash] parameters
|
388
464
|
# @return [Array]
|
389
465
|
# @raise [APIError]
|
466
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/meta/entity-group/get-entities.md for details
|
390
467
|
def entity_groups_get_entities(entity_group, parameters = {})
|
391
|
-
response = @connection.get "entity-groups/#{entity_group}/entities", parameters
|
468
|
+
response = @connection.get "entity-groups/#{CGI.escape(entity_group)}/entities", parameters
|
392
469
|
response.body
|
393
470
|
end
|
394
471
|
|
@@ -399,9 +476,11 @@ module ATSD
|
|
399
476
|
# @param [Hash] parameters
|
400
477
|
# @return [true]
|
401
478
|
# @raise [APIError]
|
479
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/meta/entity-group/add-entities.md for details
|
402
480
|
def entity_groups_add_entities(entity_group, entities, parameters = {})
|
403
|
-
@connection.patch "entity-groups/#{entity_group}/entities", [
|
481
|
+
@connection.patch "entity-groups/#{CGI.escape(entity_group)}/entities", [
|
404
482
|
parameters.merge(:action => 'add',
|
483
|
+
:createEntities => true,
|
405
484
|
:entities => entities)
|
406
485
|
]
|
407
486
|
true
|
@@ -414,8 +493,9 @@ module ATSD
|
|
414
493
|
# @param [Hash] parameters
|
415
494
|
# @return [true]
|
416
495
|
# @raise [APIError]
|
496
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/meta/entity-group/replace-entities.md for details
|
417
497
|
def entity_groups_replace_entities(entity_group, entities, parameters = {})
|
418
|
-
@connection.put "entity-groups/#{entity_group}/entities", entities
|
498
|
+
@connection.put "entity-groups/#{CGI.escape(entity_group)}/entities", entities
|
419
499
|
true
|
420
500
|
end
|
421
501
|
|
@@ -425,25 +505,14 @@ module ATSD
|
|
425
505
|
# @param [Array] entities
|
426
506
|
# @return [true]
|
427
507
|
# @raise [APIError]
|
508
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/meta/entity-group/delete-entities.md for details
|
428
509
|
def entity_groups_delete_entities(entity_group, entities)
|
429
|
-
@connection.patch "entity-groups/#{entity_group}/entities", [
|
510
|
+
@connection.patch "entity-groups/#{CGI.escape(entity_group)}/entities", [
|
430
511
|
{:action => 'delete', :entities => entities}
|
431
512
|
]
|
432
513
|
true
|
433
514
|
end
|
434
515
|
|
435
|
-
# Delete all entities in entity group.
|
436
|
-
#
|
437
|
-
# @param [String] entity_group
|
438
|
-
# @return [true]
|
439
|
-
# @raise [APIError]
|
440
|
-
def entity_groups_delete_all_entities(entity_group)
|
441
|
-
@connection.patch "entity-groups/#{entity_group}/entities", [
|
442
|
-
{:action => 'delete-all'}
|
443
|
-
]
|
444
|
-
true
|
445
|
-
end
|
446
|
-
|
447
516
|
private
|
448
517
|
|
449
518
|
def extract_basic_auth(options)
|
@@ -23,11 +23,16 @@ module ATSD
|
|
23
23
|
|
24
24
|
# Converts time and value keys as t and v respectively
|
25
25
|
# for the rest operates as a superclass method
|
26
|
-
def []=(key,value)
|
26
|
+
def []=(key, value)
|
27
27
|
key = :v if key.to_s == 'value'
|
28
|
+
case value
|
29
|
+
when Time
|
30
|
+
value = value.iso8601
|
31
|
+
else
|
32
|
+
value = value
|
33
|
+
end
|
28
34
|
super(key, value)
|
29
35
|
end
|
30
|
-
|
31
36
|
end
|
32
37
|
end
|
33
38
|
|
data/lib/atsd/models/metric.rb
CHANGED
data/lib/atsd/models/series.rb
CHANGED
@@ -23,19 +23,12 @@ module ATSD
|
|
23
23
|
self.send('v')
|
24
24
|
end
|
25
25
|
|
26
|
-
# Converts
|
26
|
+
# Converts date as d
|
27
27
|
# for the rest operates as a superclass method
|
28
28
|
def []=(key,value)
|
29
29
|
if key.to_s == 'date'
|
30
30
|
key = :d
|
31
|
-
case value
|
32
|
-
when Time
|
33
|
-
value = value.iso8601
|
34
|
-
else
|
35
|
-
value = value
|
36
|
-
end
|
37
31
|
end
|
38
|
-
key = :v if key.to_s == 'value'
|
39
32
|
super(key, value)
|
40
33
|
end
|
41
34
|
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'atsd/queries/base_query'
|
2
|
+
|
3
|
+
module ATSD
|
4
|
+
# Class for building and executing Messages Query
|
5
|
+
# @see https://github.com/axibase/atsd-docs/blob/master/api/data/messages/query.md
|
6
|
+
class MessagesQuery < BaseQuery
|
7
|
+
TO_ISO_LAMBDA = ->(v) do
|
8
|
+
case v
|
9
|
+
when Time
|
10
|
+
v.iso8601
|
11
|
+
else
|
12
|
+
v
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
coerce_key :end_date, TO_ISO_LAMBDA
|
17
|
+
coerce_key :start_date, TO_ISO_LAMBDA
|
18
|
+
|
19
|
+
# @return [Array<Property>]
|
20
|
+
def result
|
21
|
+
super
|
22
|
+
end
|
23
|
+
|
24
|
+
# @return (see #result)
|
25
|
+
def execute
|
26
|
+
result = @client.messages_query to_request_hash
|
27
|
+
@result = result.map { |json| Message.new json }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
@@ -16,6 +16,20 @@ module ATSD
|
|
16
16
|
query
|
17
17
|
end
|
18
18
|
|
19
|
+
# Change acknowledgement status of the specified alerts.
|
20
|
+
#
|
21
|
+
# @param [Array<Hash, Alert>, Hash, Alert] alerts
|
22
|
+
# @return [self]
|
23
|
+
# @raise [APIError]
|
24
|
+
def update(alerts)
|
25
|
+
alerts = Utils.ensure_array(alerts).map do |alert|
|
26
|
+
{ :id => id_for_alert(alert),
|
27
|
+
:acknowledged => acknowledged_for_alert(alert)}
|
28
|
+
end
|
29
|
+
return if alerts.count == 0
|
30
|
+
@client.alerts_update alerts
|
31
|
+
end
|
32
|
+
|
19
33
|
# Delete alerts
|
20
34
|
#
|
21
35
|
# @param [Array<Hash, Alert>, Hash, Alert] alerts
|
@@ -53,5 +67,16 @@ module ATSD
|
|
53
67
|
alert.id
|
54
68
|
end
|
55
69
|
end
|
70
|
+
|
71
|
+
def acknowledged_for_alert(alert)
|
72
|
+
case alert
|
73
|
+
when Alert
|
74
|
+
alert.acknowledged
|
75
|
+
when Hash
|
76
|
+
alert[:acknowledged] || alert['acknowledged']
|
77
|
+
else
|
78
|
+
false
|
79
|
+
end
|
80
|
+
end
|
56
81
|
end
|
57
82
|
end
|
@@ -79,6 +79,17 @@ module ATSD
|
|
79
79
|
self
|
80
80
|
end
|
81
81
|
|
82
|
+
# Returns an array of Entity Groups to which the entity belongs.
|
83
|
+
# Entity-group tags are included in the reponse.
|
84
|
+
#
|
85
|
+
# @param [Hash, Entity, String] entity entity or name
|
86
|
+
# @return [Array<EntityGroup>]
|
87
|
+
# @raise [APIError]
|
88
|
+
def entity_groups(entity)
|
89
|
+
result = @client.entities_entity_groups(name_for_entity entity)
|
90
|
+
result.map { |json| EntityGroup.new json }
|
91
|
+
end
|
92
|
+
|
82
93
|
# Returns an array of property types for the entity.
|
83
94
|
#
|
84
95
|
# @param [String, Hash, Entity] entity
|
@@ -90,7 +90,7 @@ module ATSD
|
|
90
90
|
# Limit response to first N entities, ordered by name.
|
91
91
|
# @return [Array<Entity>]
|
92
92
|
# @raise [APIError]
|
93
|
-
def
|
93
|
+
def get_entities(entity_group, parameters = {})
|
94
94
|
entity_group = name_for_entity_group(entity_group)
|
95
95
|
parameters = parameters.camelize_keys
|
96
96
|
@client.entity_groups_get_entities(entity_group, parameters).map do |json|
|
@@ -157,17 +157,6 @@ module ATSD
|
|
157
157
|
self
|
158
158
|
end
|
159
159
|
|
160
|
-
# Delete all entities from entity group.
|
161
|
-
#
|
162
|
-
# @param [String, EntityGroup, Hash] entity_group
|
163
|
-
# @return [self]
|
164
|
-
# @raise [APIError]
|
165
|
-
def delete_all_entities(entity_group)
|
166
|
-
entity_group = name_for_entity_group(entity_group)
|
167
|
-
@client.entity_groups_delete_all_entities(entity_group)
|
168
|
-
self
|
169
|
-
end
|
170
|
-
|
171
160
|
private
|
172
161
|
|
173
162
|
def name_for_entity_group(entity_group)
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'atsd/services/base_service'
|
2
|
+
require 'atsd/queries/messages_query'
|
3
|
+
require 'atsd/models/message'
|
4
|
+
require 'atsd/models/entity'
|
5
|
+
|
6
|
+
module ATSD
|
7
|
+
class MessagesService < BaseService
|
8
|
+
# Create query builder for messages.
|
9
|
+
#
|
10
|
+
# @param [String, Entity] entity
|
11
|
+
# @param [Hash] options other query parameters
|
12
|
+
# @return [MessagesQuery]
|
13
|
+
def query(entity, options = {})
|
14
|
+
query = MessagesQuery.new @client
|
15
|
+
entity = entity.name if entity.is_a? Entity
|
16
|
+
options.merge! entity: entity
|
17
|
+
options.each { |option, value| query[option] = value }
|
18
|
+
query
|
19
|
+
end
|
20
|
+
|
21
|
+
# Insert messages.
|
22
|
+
#
|
23
|
+
# @param [Array<Message, Hash>, Message, Hash] messages
|
24
|
+
# @return [self]
|
25
|
+
# @raise [APIError]
|
26
|
+
def insert(messages)
|
27
|
+
messages = Utils.ensure_array(messages).map do |s|
|
28
|
+
s = Message.new(s) if s.is_a? Hash
|
29
|
+
s.to_request_hash
|
30
|
+
end
|
31
|
+
@client.messages_insert messages
|
32
|
+
self
|
33
|
+
end
|
34
|
+
|
35
|
+
# Retrieve message counters for the specified filters as series.
|
36
|
+
#
|
37
|
+
# @param [Hash] options parameters
|
38
|
+
# @return [self]
|
39
|
+
# @raise [APIError]
|
40
|
+
def stats_query(options)
|
41
|
+
options[:metric] = 'message-count'
|
42
|
+
options = Utils.ensure_array(options).map do |s|
|
43
|
+
s = Message.new(s) if s.is_a? Hash
|
44
|
+
s.to_request_hash
|
45
|
+
end
|
46
|
+
result = @client.messages_stat_query(options)
|
47
|
+
result.map { |json| Series.new json }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -76,19 +76,16 @@ module ATSD
|
|
76
76
|
self
|
77
77
|
end
|
78
78
|
|
79
|
-
# Returns a list of
|
80
|
-
#
|
79
|
+
# Returns a list of series for the metric. Each series
|
80
|
+
# is identified with metric name, entity name and optional
|
81
|
+
# series tags
|
81
82
|
#
|
82
83
|
# @param [Hash, Metric, String] metric
|
83
|
-
# @
|
84
|
-
# @return [Array<Entity>]
|
84
|
+
# @return [Array<Series>]
|
85
85
|
# @raise [APIError]
|
86
|
-
def
|
87
|
-
|
88
|
-
|
89
|
-
params[:entity] = name_for_entity(entity) if entity
|
90
|
-
result = @client.metrics_entity_and_tags(metric, params)
|
91
|
-
result.map { |json| Entity.new json }
|
86
|
+
def series(metric, params = {})
|
87
|
+
result = @client.metrics_series(name_for_metric(metric), params)
|
88
|
+
result.map { |json| Series.new json }
|
92
89
|
end
|
93
90
|
|
94
91
|
private
|
data/lib/atsd/version.rb
CHANGED
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.
|
4
|
+
version: 1.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Axibase Corporation
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -217,18 +217,21 @@ files:
|
|
217
217
|
- lib/atsd/models/base_model.rb
|
218
218
|
- lib/atsd/models/entity.rb
|
219
219
|
- lib/atsd/models/entity_group.rb
|
220
|
+
- lib/atsd/models/message.rb
|
220
221
|
- lib/atsd/models/metric.rb
|
221
222
|
- lib/atsd/models/property.rb
|
222
223
|
- lib/atsd/models/series.rb
|
223
224
|
- lib/atsd/queries/alerts_history_query.rb
|
224
225
|
- lib/atsd/queries/alerts_query.rb
|
225
226
|
- lib/atsd/queries/base_query.rb
|
227
|
+
- lib/atsd/queries/messages_query.rb
|
226
228
|
- lib/atsd/queries/properties_query.rb
|
227
229
|
- lib/atsd/queries/series_query.rb
|
228
230
|
- lib/atsd/services/alerts_service.rb
|
229
231
|
- lib/atsd/services/base_service.rb
|
230
232
|
- lib/atsd/services/entities_service.rb
|
231
233
|
- lib/atsd/services/entity_groups_service.rb
|
234
|
+
- lib/atsd/services/messages_service.rb
|
232
235
|
- lib/atsd/services/metrics_service.rb
|
233
236
|
- lib/atsd/services/properties_service.rb
|
234
237
|
- lib/atsd/services/series_service.rb
|