atsd 1.0.2 → 1.0.3
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 +125 -97
- data/lib/atsd/models/base_model.rb +0 -13
- data/lib/atsd/models/metric.rb +0 -43
- data/lib/atsd/services/series_service.rb +25 -0
- data/lib/atsd/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6966f668083fa1ddfc4447cfd12ab2c187d9c149
|
4
|
+
data.tar.gz: 2a2195ada45085173516415e97b427453e36da42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db845e86a01054d31b0d49e7a1a85e775ecc678ff937de85b73452b83824469805dda3b00662436718a08b1bb73aacfa7332563500ae51b334ef50f84079fc4e
|
7
|
+
data.tar.gz: c5560702a4400b30c6f2eec42373757160a93e0d46fc5bb1b9506c5447b63b764497006cc3b0dc0b74b309fd0e3459af9e479cba41e7faf41ccd376fdd8392d5
|
data/README.md
CHANGED
@@ -18,7 +18,7 @@ Then execute:
|
|
18
18
|
|
19
19
|
$ bundle
|
20
20
|
|
21
|
-
|
21
|
+
Alternatively, you can install atsd gem manually:
|
22
22
|
|
23
23
|
$ gem install atsd
|
24
24
|
|
@@ -65,7 +65,7 @@ Or install manually:
|
|
65
65
|
|
66
66
|
## Usage
|
67
67
|
|
68
|
-
To start using the gem you need to create an ATSD instance:
|
68
|
+
To start using the gem you need to create an `ATSD` class instance:
|
69
69
|
|
70
70
|
```ruby
|
71
71
|
require 'atsd'
|
@@ -79,70 +79,63 @@ atsd = ATSD.new :url => "#{API_ENDPOINT}/api/v1",
|
|
79
79
|
|
80
80
|
#### Authorization
|
81
81
|
In order to use the API you need to specify `:basic_auth` option in one
|
82
|
-
of the following
|
82
|
+
of the following ways:
|
83
83
|
|
84
84
|
- `"login:password"`
|
85
85
|
- `{ :login => 'login', :password => 'password' }`
|
86
86
|
|
87
87
|
#### SSL
|
88
|
-
ATSD
|
89
|
-
See [Faraday Wiki](https://github.com/lostisland/faraday/wiki/Setting-up-SSL-certificates) on how
|
90
|
-
|
88
|
+
Connecting to ATSD via SSL requires extra configuration if your ATSD instance runs on a self-signed SSL certificate.
|
89
|
+
See [Faraday Wiki](https://github.com/lostisland/faraday/wiki/Setting-up-SSL-certificates) on how to setup SSL.
|
90
|
+
As a workaround you can specify `ssl: { verify: false }` option in the client.
|
91
|
+
|
91
92
|
|
92
93
|
#### Logging
|
93
94
|
|
94
95
|
- To use a custom logger specify it in the `:logger` option.
|
95
|
-
- To use default STDOUT logger set `:logger` option to `true`.
|
96
|
-
|
97
|
-
#### Faraday Middleware
|
98
|
-
|
99
|
-
```ruby
|
100
|
-
ATSD.new url: end_point, basic_auth: basic_auth do |builder|
|
101
|
-
builder.insert_after(FaradayMiddleware::ParseJson, VCR::Middleware::Faraday)
|
102
|
-
# ...
|
103
|
-
end
|
104
|
-
```
|
96
|
+
- To use the default STDOUT logger set `:logger` option to `true`.
|
105
97
|
|
106
98
|
### Services
|
107
99
|
Once you instantiated the ATSD class, you can use different services.
|
108
|
-
Each service represents a particular
|
109
|
-
|
110
|
-
entity groups.
|
100
|
+
Each service represents a particular object type in Axibase Time Series Database.
|
101
|
+
The following services are currently implemented:
|
111
102
|
|
112
|
-
|
103
|
+
- series_service,
|
104
|
+
- properties_service,
|
105
|
+
- alerts_service,
|
106
|
+
- metrics_service,
|
107
|
+
- entities_service,
|
108
|
+
- entity_groups_service.
|
113
109
|
|
114
110
|
#### Query builders
|
115
|
-
Query objects created by
|
111
|
+
Query objects created by services provide convenient methods to build complex queries.
|
116
112
|
They support method chaining and automatically translate snake_styled properties
|
117
113
|
to CamelCase used in the API. For example, `end_time` property in ruby code becomes `endTime` in json request.
|
118
114
|
|
119
115
|
#### Series Service
|
120
116
|
|
121
|
-
|
117
|
+
Basic query:
|
122
118
|
|
123
119
|
```ruby
|
120
|
+
require 'time'
|
124
121
|
series_service = atsd.series_service
|
125
122
|
# => #<ATSD::SeriesService:0x007f82a4446c08
|
126
|
-
|
127
|
-
|
128
|
-
# => {:entity=>"ubuntu", :metric=>"meminfo.memfree"}
|
123
|
+
query = series_service.query('sensor-1', 'temperature', Time.parse("2015-11-17T12:00:00Z"), Time.parse("2015-11-17T19:00:00Z"))
|
124
|
+
# => {:entity=>"sensor-1", :metric=>"temperature", :start_time=>1447750800000, :end_time=>1447776000000}
|
129
125
|
|
130
126
|
query.class
|
131
127
|
# => ATSD::SeriesQuery
|
132
128
|
|
133
|
-
query.end_time(Time.now)
|
134
|
-
# => {:entity=>"ubuntu", :metric=>"meminfo.memfree", :end_time=>1428303004000}
|
135
|
-
|
136
129
|
query.execute
|
137
|
-
# => [{:entity=>"
|
138
|
-
# :metric=>"
|
130
|
+
# => [{:entity=>"sensor-1",
|
131
|
+
# :metric=>"temperature",
|
139
132
|
# :tags=>{},
|
140
133
|
# :type=>"HISTORY",
|
141
134
|
# :aggregate=>{"type"=>"DETAIL"},
|
142
135
|
# :data=>
|
143
|
-
# [{"t"=>1428301869000, "v"=>
|
144
|
-
# {"t"=>1428301884000, "v"=>
|
145
|
-
# {"t"=>1428301899000, "v"=>
|
136
|
+
# [{"t"=>1428301869000, "v"=>24.0},
|
137
|
+
# {"t"=>1428301884000, "v"=>23.0},
|
138
|
+
# {"t"=>1428301899000, "v"=>23.5},
|
146
139
|
# ...
|
147
140
|
|
148
141
|
query.result
|
@@ -150,50 +143,89 @@ query.result
|
|
150
143
|
|
151
144
|
s = query.result.first
|
152
145
|
s.entity
|
153
|
-
# => "
|
146
|
+
# => "sensor-1"
|
154
147
|
```
|
155
148
|
|
156
|
-
|
149
|
+
Aggregated query:
|
157
150
|
|
158
151
|
```ruby
|
159
152
|
query.aggregate(types:[SeriesQuery::AggregateType::AVG], interval:{count:1, unit:SeriesQuery::Interval::HOUR})
|
160
|
-
# => {:entity=>"
|
161
|
-
# :metric=>"
|
153
|
+
# => {:entity=>"sensor-1",
|
154
|
+
# :metric=>"temperature",
|
162
155
|
# :end_time=>1428303004000,
|
163
156
|
# :aggregate=>{:types=>["AVG"], :interval=>{:count=>1, :unit=>"HOUR"}}}
|
164
157
|
|
165
158
|
query.execute
|
166
|
-
# => [{:entity=>"
|
167
|
-
# :metric=>"
|
159
|
+
# => [{:entity=>"sensor-1",
|
160
|
+
# :metric=>"temperature",
|
168
161
|
# :tags=>{},
|
169
162
|
# :type=>"HISTORY",
|
170
163
|
# :aggregate=>{"type"=>"AVG", "interval"=>{"count"=>1, "unit"=>"HOUR"}},
|
171
|
-
# :data=>[{"t"=>1428300000000, "v"=>
|
164
|
+
# :data=>[{"t"=>1428300000000, "v"=>23.57}]}]
|
172
165
|
```
|
173
166
|
|
174
167
|
Query with Versions:
|
175
168
|
|
176
169
|
```ruby
|
177
|
-
query = atsd.series_service.query("sensor-
|
170
|
+
query = atsd.series_service.query("sensor-2", "pressure", Time.parse("2015-11-17T12:00:00Z"), Time.parse("2015-11-17T19:00:00Z"), {:versioned => true})
|
178
171
|
query.execute
|
172
|
+
template = "%23s, %13s, %23s, %17s, %17s\n"
|
173
|
+
output = sprintf(template, "sample_time", "sample_value", "version_time", "version_source", "version_status")
|
174
|
+
query.result.each do |data|
|
175
|
+
samples = data.data.sort_by{|sample| sample["version"]["t"]}
|
176
|
+
samples.each {|sample| output << sprintf(template, Time.at(sample["t"]/1000).strftime("%Y-%m-%dT%H:%M:%SZ"), sample["v"], Time.at(sample["version"]["t"]/1000).strftime("%Y-%m-%dT%H:%M:%SZ"), sample["version"]["source"], sample["version"]["status"]) }
|
177
|
+
end
|
178
|
+
puts output
|
179
|
+
sample_time, sample_value, version_time, version_source, version_status
|
180
|
+
2015-11-17T17:00:00Z, 7.0, 2015-11-18T19:19:57Z, gateway-1, normal
|
181
|
+
2015-11-17T18:00:00Z, 17.0, 2015-11-18T19:19:57Z, gateway-1, error
|
182
|
+
2015-11-17T17:00:00Z, 7.0, 2015-11-18T19:22:05Z, gateway-1, normal
|
183
|
+
2015-11-17T18:00:00Z, 17.0, 2015-11-18T19:22:05Z, gateway-1, error
|
184
|
+
2015-11-17T17:00:00Z, 7.0, 2015-11-18T19:23:28Z, gateway-1, normal
|
185
|
+
2015-11-17T18:00:00Z, 17.0, 2015-11-18T19:23:28Z, gateway-1, error
|
186
|
+
2015-11-17T17:00:00Z, 7.0, 2015-11-18T19:36:18Z, gateway-1, normal
|
187
|
+
2015-11-17T18:00:00Z, 17.0, 2015-11-18T19:36:18Z, gateway-1, error
|
188
|
+
2015-11-17T17:00:00Z, 7.0, 2015-11-18T19:37:02Z, gateway-1, normal
|
189
|
+
2015-11-17T18:00:00Z, 17.0, 2015-11-18T19:37:02Z, gateway-1, error
|
190
|
+
2015-11-17T17:00:00Z, 7.0, 2015-11-18T20:41:10Z, gateway-1, normal
|
191
|
+
2015-11-17T18:00:00Z, 17.0, 2015-11-18T20:41:10Z, gateway-1, error
|
192
|
+
2015-11-17T17:00:00Z, 7.0, 2015-11-18T20:45:57Z, gateway-1, normal
|
193
|
+
2015-11-17T18:00:00Z, 17.0, 2015-11-18T20:45:57Z, gateway-1, error
|
194
|
+
2015-11-17T17:00:00Z, 7.0, 2015-11-19T11:25:40Z, gateway-1, normal
|
195
|
+
2015-11-17T18:00:00Z, 17.0, 2015-11-19T11:25:40Z, gateway-1, error
|
196
|
+
2015-11-17T17:00:00Z, 7.0, 2015-11-19T11:29:36Z, gateway-1, normal
|
197
|
+
2015-11-17T18:00:00Z, 17.0, 2015-11-19T11:29:36Z, gateway-1, error
|
198
|
+
2015-11-17T17:00:00Z, 7.0, 2015-11-19T11:32:35Z, gateway-1, normal
|
199
|
+
2015-11-17T18:00:00Z, 17.0, 2015-11-19T11:32:35Z, gateway-1, error
|
179
200
|
```
|
180
201
|
|
181
|
-
|
202
|
+
Inserting series:
|
182
203
|
|
183
204
|
```ruby
|
184
205
|
s = Series.new
|
185
|
-
s.entity = '
|
186
|
-
s.metric = '
|
187
|
-
s.data = [ {t:
|
206
|
+
s.entity = 'sensor-1'
|
207
|
+
s.metric = 'temperature'
|
208
|
+
s.data = [ {t: Time.now.to_i*1000, v: 22} ]
|
209
|
+
series_service.insert(s)
|
210
|
+
```
|
211
|
+
|
212
|
+
Inserting series using Sample class:
|
213
|
+
|
214
|
+
```ruby
|
215
|
+
s = Series.new
|
216
|
+
s.entity = 'sensor-1'
|
217
|
+
s.metric = 'pressure'
|
218
|
+
sample = Sample.new :t => Time.parse("2015-11-17T17:00:00Z"), :v => 7, :version => {:status => "normal", :source => "gateway-1"}
|
219
|
+
s.data = [ sample ]
|
188
220
|
series_service.insert(s)
|
189
221
|
```
|
190
222
|
|
191
223
|
Inserting Series with Versions:
|
192
224
|
|
193
225
|
```ruby
|
194
|
-
sample_1 = Sample.new :t => Time.
|
195
|
-
sample_2 = Sample.new :t => Time.
|
196
|
-
series = Series.new :entity => "sensor-1", :metric => "
|
226
|
+
sample_1 = Sample.new :t => Time.parse("2015-11-17T17:00:00Z"), :v => 7, :version => {:status => "normal", :source => "gateway-1"}
|
227
|
+
sample_2 = Sample.new :t => Time.parse("2015-11-17T18:00:00Z"), :v => 17, :version => {:status => "error", :source => "gateway-1"}
|
228
|
+
series = Series.new :entity => "sensor-1", :metric => "pressure", :data => [sample_1, sample_2]
|
197
229
|
atsd.series_service.insert(series)
|
198
230
|
```
|
199
231
|
|
@@ -201,22 +233,22 @@ atsd.series_service.insert(series)
|
|
201
233
|
|
202
234
|
data.csv contents:
|
203
235
|
```plain
|
204
|
-
time,
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
236
|
+
time, pressure, temperature
|
237
|
+
1447228800000, 39, 29.23
|
238
|
+
1447315200000, 32, 29.24
|
239
|
+
1447401600000, 40, 29.23
|
240
|
+
1447488000000, 37, 29.25
|
241
|
+
1447574400000, 39, 29.26
|
242
|
+
1447660800000, 37, 29.21
|
243
|
+
1447747200000, 38, 29.20
|
244
|
+
1447833600000, 36, 29.23
|
245
|
+
1447920000000, 37, 29.25
|
246
|
+
1448006400000, 38, 29.25
|
215
247
|
```
|
216
248
|
|
217
|
-
Inserting
|
249
|
+
Inserting CSV data from file:
|
218
250
|
```ruby
|
219
|
-
series_service.csv_insert('
|
251
|
+
series_service.csv_insert('sensor-1', File.read('/path/to/data.csv'), { :user => 'beta' })
|
220
252
|
```
|
221
253
|
|
222
254
|
#### Properties Service
|
@@ -226,21 +258,21 @@ properties_service = atsd.properties_service
|
|
226
258
|
# => #<ATSD::PropertiesService:0x007f82a456e6f8
|
227
259
|
|
228
260
|
property = Property.new
|
229
|
-
property.entity = '
|
230
|
-
property.type = '
|
231
|
-
property.
|
232
|
-
property.
|
261
|
+
property.entity = 'sensor-1'
|
262
|
+
property.type = 'sensor_type'
|
263
|
+
property.tags = {"location":"NUR","site":"building-1"}
|
264
|
+
property.keys = {"id": "ch-15"}
|
233
265
|
properties_service.insert(property)
|
234
266
|
|
235
|
-
properties_service.query('
|
236
|
-
# => [{:type=>"
|
237
|
-
# :entity=>"
|
238
|
-
# :
|
267
|
+
properties_service.query('sensor-1', 'sensor_type').execute
|
268
|
+
# => [{:type=>"sensor_type",
|
269
|
+
# :entity=>"sensor-1",
|
270
|
+
# :tags=>{"location"=>"NUR", "site"=>"building-1"},
|
239
271
|
# :timestamp=>1428304255068,
|
240
|
-
# :
|
272
|
+
# :keys=>{"id"=>"ch-15"}}]
|
241
273
|
|
242
274
|
properties_service.delete(property)
|
243
|
-
properties_service.query('
|
275
|
+
properties_service.query('sensor-1', 'sensor_type').execute
|
244
276
|
# => []
|
245
277
|
```
|
246
278
|
|
@@ -256,7 +288,7 @@ alerts_service.query.execute
|
|
256
288
|
# :text_value=>"447660",
|
257
289
|
# :tags=>{},
|
258
290
|
# :metric=>"meminfo.active",
|
259
|
-
# :entity=>"
|
291
|
+
# :entity=>"sensor-1",
|
260
292
|
# :severity=>3,
|
261
293
|
# :rule=>"My rule!",
|
262
294
|
# :repeat_count=>5,
|
@@ -269,7 +301,7 @@ alerts_service.query.execute
|
|
269
301
|
# :text_value=>"447660",
|
270
302
|
# :tags=>{},
|
271
303
|
# :metric=>"meminfo.active",
|
272
|
-
# :entity=>"
|
304
|
+
# :entity=>"sensor-1",
|
273
305
|
# :severity=>3,
|
274
306
|
# ...
|
275
307
|
```
|
@@ -298,25 +330,23 @@ metrics_service.list
|
|
298
330
|
# ...
|
299
331
|
|
300
332
|
metrics_service.entity_and_tags('df.disk_size')
|
301
|
-
# => [{:entity=>"
|
302
|
-
# {:entity=>"
|
303
|
-
#
|
304
|
-
#
|
305
|
-
# {:entity=>"
|
306
|
-
# {:entity=>"
|
307
|
-
# {:entity=>"
|
308
|
-
# {:entity=>"ubuntu", :tags=>{"file_system"=>"udev", "mount_point"=>"/dev"}, :last_insert_time=>1428328928000},
|
309
|
-
# {:entity=>"ubuntu", :tags=>{"file_system"=>"tmpfs", "mount_point"=>"/run"}, :last_insert_time=>1428328928000}]
|
333
|
+
# => [{:entity=>"server-1", :tags=>{"file_system"=>"/dev/sda1", "mount_point"=>"/"}, :last_insert_time=>1428328928000},
|
334
|
+
# {:entity=>"server-1", :tags=>{"file_system"=>"none", "mount_point"=>"/sys/fs/cgroup"}, :last_insert_time=>1428328928000},
|
335
|
+
# {:entity=>"server-1", :tags=>{"file_system"=>"none", "mount_point"=>"/run/lock"}, :last_insert_time=>1428328928000},
|
336
|
+
# {:entity=>"server-1", :tags=>{"file_system"=>"none", "mount_point"=>"/run/shm"}, :last_insert_time=>1428328928000},
|
337
|
+
# {:entity=>"server-2", :tags=>{"file_system"=>"none", "mount_point"=>"/run/user"}, :last_insert_time=>1428328928000},
|
338
|
+
# {:entity=>"server-2", :tags=>{"file_system"=>"udev", "mount_point"=>"/dev"}, :last_insert_time=>1428328928000},
|
339
|
+
# {:entity=>"server-2", :tags=>{"file_system"=>"tmpfs", "mount_point"=>"/run"}, :last_insert_time=>1428328928000}]
|
310
340
|
|
311
341
|
metric = Metric.new
|
312
342
|
# => {}
|
313
|
-
metric.name = "
|
314
|
-
# => "
|
343
|
+
metric.name = "energy_usage"
|
344
|
+
# => "energy_usaget"
|
315
345
|
metric.versioned = true
|
316
346
|
# => true
|
317
347
|
metrics_service.create_or_replace(metric)
|
318
|
-
metrics_service.get("
|
319
|
-
# => {:name=>"
|
348
|
+
metrics_service.get("energy_usage")
|
349
|
+
# => {:name=>"energy_usage", :enabled=>true, :data_type=>"FLOAT", :counter=>false, :persistent=>true, :tags=>{}, :time_precision=>"MILLISECONDS", :retention_interval=>0, :invalid_action=>"NONE", :versioned=>true}
|
320
350
|
|
321
351
|
```
|
322
352
|
|
@@ -326,16 +356,16 @@ metrics_service.get("cpu_count")
|
|
326
356
|
entities_service = atsd.entities_service
|
327
357
|
# => #<ATSD::EntitiesService:0x007f82a45b40b8
|
328
358
|
|
329
|
-
entities_service.list
|
359
|
+
entities_service.list(:limit => 10)
|
330
360
|
# => [{:name=>"atsd", :enabled=>true, :last_insert_time=>1428304482631},
|
331
361
|
# {:name=>"mine", :enabled=>true},
|
332
|
-
# {:name=>"test_entity", :enabled=>true, :last_insert_time=>
|
333
|
-
# {:name=>"
|
362
|
+
# {:name=>"test_entity", :enabled=>true, :last_insert_time=>1428304489000},
|
363
|
+
# {:name=>"sensor-1", :enabled=>true, :last_insert_time=>1428304489000}]
|
334
364
|
|
335
|
-
entities_service.get('
|
336
|
-
# => {:name=>"
|
365
|
+
entities_service.get('sensor-1')
|
366
|
+
# => {:name=>"sensor-1", :enabled=>true, :last_insert_time=>1428304499000, :tags=>{}}
|
337
367
|
|
338
|
-
entities_service.metrics('
|
368
|
+
entities_service.metrics('server-1')
|
339
369
|
# => [{:name=>"df.disk_size",
|
340
370
|
# :enabled=>true,
|
341
371
|
# :data_type=>"FLOAT",
|
@@ -349,11 +379,11 @@ entities_service.metrics('ubuntu')
|
|
349
379
|
# :enabled=>true,
|
350
380
|
# ...
|
351
381
|
|
352
|
-
entities_service.delete(entities_service.get('
|
382
|
+
entities_service.delete(entities_service.get('server-1')) # or entities_service.delete('server-1')
|
353
383
|
entities_service.list
|
354
384
|
# => [{:name=>"atsd", :enabled=>true, :last_insert_time=>1428304482631},
|
355
385
|
# {:name=>"test_entity", :enabled=>true, :last_insert_time=>1000000000},
|
356
|
-
# {:name=>"
|
386
|
+
# {:name=>"sensor-1", :enabled=>true, :last_insert_time=>1428304489000}]
|
357
387
|
```
|
358
388
|
#### Entity Groups Service
|
359
389
|
|
@@ -382,14 +412,12 @@ fields.
|
|
382
412
|
Gem also provides an `ATSD::Client` class. It is a simple API wrapper
|
383
413
|
which uses [Faraday](https://github.com/lostisland/faraday) to handle HTTP-related routines.
|
384
414
|
All services are built on top of it.
|
385
|
-
Client has 1-to-1 mapping for all REST methods specified on https://axibase.com/atsd/api.
|
386
415
|
|
387
416
|
You can access `Faraday::Connection` object using the `connection` field of the client if necessary.
|
388
417
|
|
389
418
|
## Development
|
390
419
|
|
391
420
|
After checking out the repository, run `bin/setup` to install dependencies.
|
392
|
-
Then run `bin/console` for an interactive prompt that will allow you to experiment.
|
421
|
+
Then run `bin/console` for an interactive prompt that will allow you to experiment with the client.
|
393
422
|
|
394
423
|
To install this gem onto your local machine, run `bundle exec rake install`.
|
395
|
-
|
@@ -20,19 +20,6 @@ module ATSD
|
|
20
20
|
end
|
21
21
|
hash
|
22
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
|
36
23
|
end
|
37
24
|
end
|
38
25
|
|
data/lib/atsd/models/metric.rb
CHANGED
@@ -119,10 +119,6 @@ module ATSD
|
|
119
119
|
Time.at(self.send("last_insert_time")/1000)
|
120
120
|
end
|
121
121
|
|
122
|
-
# def set_last_insert_date(last_insert_date)
|
123
|
-
# self["last_insert_date"] = last_insert_date
|
124
|
-
# end
|
125
|
-
|
126
122
|
def set_versioned(versioned)
|
127
123
|
self["versioned"] = versioned
|
128
124
|
end
|
@@ -161,45 +157,6 @@ module ATSD
|
|
161
157
|
RAISE_ERROR = 'RAISE_ERROR'
|
162
158
|
end
|
163
159
|
|
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
|
-
|
203
160
|
end
|
204
161
|
|
205
162
|
|
@@ -53,5 +53,30 @@ module ATSD
|
|
53
53
|
entity = entity.name if entity.is_a? Entity
|
54
54
|
@client.series_csv_insert(entity, data, tags)
|
55
55
|
end
|
56
|
+
|
57
|
+
# Post json
|
58
|
+
# @param [Hash] config - Hash containing url, login and password keys, e.g. {:url => "http://www.example.com:8088/api/v1", :login => "login", :password => "password"}
|
59
|
+
# @param [String] payload Body - ready to be parsed by ATSD server
|
60
|
+
# @return server response body
|
61
|
+
# @raise [APIError]
|
62
|
+
def self.post_payload(config,payload)
|
63
|
+
url = config[:url]
|
64
|
+
login, password = config[:login],config[:password]
|
65
|
+
|
66
|
+
@connection = Faraday.new url do |builder|
|
67
|
+
builder.headers['User-Agent'] = "ATSD Ruby Client v#{VERSION}"
|
68
|
+
builder.basic_auth login, password
|
69
|
+
builder.request :json
|
70
|
+
|
71
|
+
builder.response :errors_handler
|
72
|
+
builder.response :json, :content_type => 'application/json'
|
73
|
+
|
74
|
+
builder.adapter Faraday.default_adapter
|
75
|
+
end
|
76
|
+
response = @connection.post do |req|
|
77
|
+
req.body = payload
|
78
|
+
end
|
79
|
+
response
|
80
|
+
end
|
56
81
|
end
|
57
82
|
end
|
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.3
|
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-11-
|
11
|
+
date: 2015-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|