influxdb 0.6.1 → 0.6.2
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/.rubocop.yml +4 -0
- data/.travis.yml +15 -13
- data/CHANGELOG.md +5 -0
- data/influxdb.gemspec +1 -1
- data/lib/influxdb.rb +1 -0
- data/lib/influxdb/client/http.rb +3 -1
- data/lib/influxdb/config.rb +1 -0
- data/lib/influxdb/logging.rb +1 -0
- data/lib/influxdb/max_queue.rb +1 -0
- data/lib/influxdb/point_value.rb +7 -6
- data/lib/influxdb/query/core.rb +2 -2
- data/lib/influxdb/query/measurement.rb +1 -0
- data/lib/influxdb/query/series.rb +1 -0
- data/lib/influxdb/timestamp_conversion.rb +23 -0
- data/lib/influxdb/version.rb +1 -1
- data/lib/influxdb/writer/async.rb +2 -0
- data/spec/influxdb/cases/query_batch_spec.rb +26 -26
- data/spec/influxdb/cases/query_cluster_spec.rb +2 -1
- data/spec/influxdb/cases/query_continuous_query_spec.rb +6 -4
- data/spec/influxdb/cases/query_core_spec.rb +2 -2
- data/spec/influxdb/cases/query_series_spec.rb +4 -4
- data/spec/influxdb/cases/query_with_params_spec.rb +2 -2
- data/spec/influxdb/cases/querying_issue_7000_spec.rb +34 -14
- data/spec/influxdb/cases/querying_spec.rb +155 -60
- data/spec/influxdb/cases/retry_requests_spec.rb +11 -11
- data/spec/influxdb/cases/show_field_keys_spec.rb +5 -5
- data/spec/influxdb/cases/udp_client_spec.rb +1 -1
- data/spec/influxdb/cases/write_points_spec.rb +19 -19
- data/spec/influxdb/client_spec.rb +4 -4
- data/spec/influxdb/config_spec.rb +9 -9
- data/spec/influxdb/point_value_spec.rb +8 -8
- data/spec/influxdb/time_conversion_spec.rb +26 -0
- data/spec/spec_helper.rb +1 -0
- metadata +8 -5
@@ -4,10 +4,10 @@ require "json"
|
|
4
4
|
describe InfluxDB::Client do
|
5
5
|
let(:subject) do
|
6
6
|
described_class.new "database", {
|
7
|
-
host:
|
8
|
-
port:
|
9
|
-
username:
|
10
|
-
password:
|
7
|
+
host: "influxdb.test",
|
8
|
+
port: 9999,
|
9
|
+
username: "username",
|
10
|
+
password: "password",
|
11
11
|
time_precision: "s"
|
12
12
|
}.merge(args)
|
13
13
|
end
|
@@ -27,9 +27,9 @@ describe InfluxDB::Client do
|
|
27
27
|
context "with single series with multiple points" do
|
28
28
|
let(:response) do
|
29
29
|
{ "results" => [{ "statement_id" => 0,
|
30
|
-
"series"
|
31
|
-
|
32
|
-
|
30
|
+
"series" => [{ "name" => "cpu", "tags" => { "region" => "us" },
|
31
|
+
"columns" => %w[time temp value],
|
32
|
+
"values" => [["2015-07-07T14:58:37Z", 92, 0.3445], ["2015-07-07T14:59:09Z", 68, 0.8787]] }] }] }
|
33
33
|
end
|
34
34
|
let(:expected_result) do
|
35
35
|
[{ "name" => "cpu", "tags" => { "region" => "us" },
|
@@ -46,13 +46,21 @@ describe InfluxDB::Client do
|
|
46
46
|
context "with series with different tags" do
|
47
47
|
let(:response) do
|
48
48
|
{ "results" => [{ "statement_id" => 0,
|
49
|
-
"series"
|
50
|
-
|
49
|
+
"series" => [{ "name" => "cpu",
|
50
|
+
"tags" => { "region" => "pl" },
|
51
|
+
"columns" => %w[time temp value],
|
52
|
+
"values" => [["2015-07-07T15:13:04Z", 34, 0.343443]] },
|
53
|
+
{ "name" => "cpu",
|
54
|
+
"tags" => { "region" => "us" },
|
55
|
+
"columns" => %w[time temp value],
|
56
|
+
"values" => [["2015-07-07T14:58:37Z", 92, 0.3445], ["2015-07-07T14:59:09Z", 68, 0.8787]] }] }] }
|
51
57
|
end
|
52
58
|
let(:expected_result) do
|
53
|
-
[{ "name"
|
59
|
+
[{ "name" => "cpu",
|
60
|
+
"tags" => { "region" => "pl" },
|
54
61
|
"values" => [{ "time" => "2015-07-07T15:13:04Z", "temp" => 34, "value" => 0.343443 }] },
|
55
|
-
{ "name"
|
62
|
+
{ "name" => "cpu",
|
63
|
+
"tags" => { "region" => "us" },
|
56
64
|
"values" => [{ "time" => "2015-07-07T14:58:37Z", "temp" => 92, "value" => 0.3445 },
|
57
65
|
{ "time" => "2015-07-07T14:59:09Z", "temp" => 68, "value" => 0.8787 }] }]
|
58
66
|
end
|
@@ -66,16 +74,36 @@ describe InfluxDB::Client do
|
|
66
74
|
context "with multiple series with different tags" do
|
67
75
|
let(:response) do
|
68
76
|
{ "results" => [{ "statement_id" => 0,
|
69
|
-
"series"
|
70
|
-
|
71
|
-
|
72
|
-
|
77
|
+
"series" => [{ "name" => "access_times.service_1",
|
78
|
+
"tags" => { "code" => "200", "result" => "failure", "status" => "OK" },
|
79
|
+
"columns" => %w[time value],
|
80
|
+
"values" => [["2015-07-08T07:15:22Z", 327]] },
|
81
|
+
{ "name" => "access_times.service_1",
|
82
|
+
"tags" => { "code" => "500", "result" => "failure", "status" => "Internal Server Error" },
|
83
|
+
"columns" => %w[time value],
|
84
|
+
"values" => [["2015-07-08T06:15:22Z", 873]] },
|
85
|
+
{ "name" => "access_times.service_2",
|
86
|
+
"tags" => { "code" => "200", "result" => "failure", "status" => "OK" },
|
87
|
+
"columns" => %w[time value],
|
88
|
+
"values" => [["2015-07-08T07:15:22Z", 943]] },
|
89
|
+
{ "name" => "access_times.service_2",
|
90
|
+
"tags" => { "code" => "500", "result" => "failure", "status" => "Internal Server Error" },
|
91
|
+
"columns" => %w[time value],
|
92
|
+
"values" => [["2015-07-08T06:15:22Z", 606]] }] }] }
|
73
93
|
end
|
74
94
|
let(:expected_result) do
|
75
|
-
[{ "name"
|
76
|
-
|
77
|
-
|
78
|
-
{ "name"
|
95
|
+
[{ "name" => "access_times.service_1",
|
96
|
+
"tags" => { "code" => "200", "result" => "failure", "status" => "OK" },
|
97
|
+
"values" => [{ "time" => "2015-07-08T07:15:22Z", "value" => 327 }] },
|
98
|
+
{ "name" => "access_times.service_1",
|
99
|
+
"tags" => { "code" => "500", "result" => "failure", "status" => "Internal Server Error" },
|
100
|
+
"values" => [{ "time" => "2015-07-08T06:15:22Z", "value" => 873 }] },
|
101
|
+
{ "name" => "access_times.service_2",
|
102
|
+
"tags" => { "code" => "200", "result" => "failure", "status" => "OK" },
|
103
|
+
"values" => [{ "time" => "2015-07-08T07:15:22Z", "value" => 943 }] },
|
104
|
+
{ "name" => "access_times.service_2",
|
105
|
+
"tags" => { "code" => "500", "result" => "failure", "status" => "Internal Server Error" },
|
106
|
+
"values" => [{ "time" => "2015-07-08T06:15:22Z", "value" => 606 }] }]
|
79
107
|
end
|
80
108
|
let(:query) { "SELECT * FROM /access_times.*/" }
|
81
109
|
|
@@ -87,12 +115,20 @@ describe InfluxDB::Client do
|
|
87
115
|
context "with multiple series for explicit value only" do
|
88
116
|
let(:response) do
|
89
117
|
{ "results" => [{ "statement_id" => 0,
|
90
|
-
"series"
|
91
|
-
|
118
|
+
"series" => [{ "name" => "access_times.service_1",
|
119
|
+
"columns" => %w[time value],
|
120
|
+
"values" => [["2015-07-08T06:15:22Z", 873], ["2015-07-08T07:15:22Z", 327]] },
|
121
|
+
{ "name" => "access_times.service_2",
|
122
|
+
"columns" => %w[time value],
|
123
|
+
"values" => [["2015-07-08T06:15:22Z", 606], ["2015-07-08T07:15:22Z", 943]] }] }] }
|
92
124
|
end
|
93
125
|
let(:expected_result) do
|
94
|
-
[{ "name"
|
95
|
-
|
126
|
+
[{ "name" => "access_times.service_1",
|
127
|
+
"tags" => nil,
|
128
|
+
"values" => [{ "time" => "2015-07-08T06:15:22Z", "value" => 873 }, { "time" => "2015-07-08T07:15:22Z", "value" => 327 }] },
|
129
|
+
{ "name" => "access_times.service_2",
|
130
|
+
"tags" => nil,
|
131
|
+
"values" => [{ "time" => "2015-07-08T06:15:22Z", "value" => 606 }, { "time" => "2015-07-08T07:15:22Z", "value" => 943 }] }]
|
96
132
|
end
|
97
133
|
let(:query) { "SELECT value FROM /access_times.*/" }
|
98
134
|
|
@@ -104,14 +140,22 @@ describe InfluxDB::Client do
|
|
104
140
|
context "with a block" do
|
105
141
|
let(:response) do
|
106
142
|
{ "results" => [{ "statement_id" => 0,
|
107
|
-
"series"
|
108
|
-
|
143
|
+
"series" => [{ "name" => "cpu",
|
144
|
+
"tags" => { "region" => "pl" },
|
145
|
+
"columns" => %w[time temp value],
|
146
|
+
"values" => [["2015-07-07T15:13:04Z", 34, 0.343443]] },
|
147
|
+
{ "name" => "cpu",
|
148
|
+
"tags" => { "region" => "us" },
|
149
|
+
"columns" => %w[time temp value],
|
150
|
+
"values" => [["2015-07-07T14:58:37Z", 92, 0.3445], ["2015-07-07T14:59:09Z", 68, 0.8787]] }] }] }
|
109
151
|
end
|
110
152
|
|
111
153
|
let(:expected_result) do
|
112
|
-
[{ "name"
|
154
|
+
[{ "name" => "cpu",
|
155
|
+
"tags" => { "region" => "pl" },
|
113
156
|
"values" => [{ "time" => "2015-07-07T15:13:04Z", "temp" => 34, "value" => 0.343443 }] },
|
114
|
-
{ "name"
|
157
|
+
{ "name" => "cpu",
|
158
|
+
"tags" => { "region" => "us" },
|
115
159
|
"values" => [{ "time" => "2015-07-07T14:58:37Z", "temp" => 92, "value" => 0.3445 },
|
116
160
|
{ "time" => "2015-07-07T14:59:09Z", "temp" => 68, "value" => 0.8787 }] }]
|
117
161
|
end
|
@@ -132,13 +176,21 @@ describe InfluxDB::Client do
|
|
132
176
|
|
133
177
|
let(:response) do
|
134
178
|
{ "results" => [{ "statement_id" => 0,
|
135
|
-
"series"
|
136
|
-
|
179
|
+
"series" => [{ "name" => "cpu",
|
180
|
+
"tags" => { "region" => "pl" },
|
181
|
+
"columns" => %w[time temp value],
|
182
|
+
"values" => [[1_438_580_576, 34, 0.343443]] },
|
183
|
+
{ "name" => "cpu",
|
184
|
+
"tags" => { "region" => "us" },
|
185
|
+
"columns" => %w[time temp value],
|
186
|
+
"values" => [[1_438_612_976, 92, 0.3445], [1_438_612_989, 68, 0.8787]] }] }] }
|
137
187
|
end
|
138
188
|
let(:expected_result) do
|
139
|
-
[{ "name"
|
189
|
+
[{ "name" => "cpu",
|
190
|
+
"tags" => { "region" => "pl" },
|
140
191
|
"values" => [{ "time" => 1_438_580_576, "temp" => 34, "value" => 0.343443 }] },
|
141
|
-
{ "name"
|
192
|
+
{ "name" => "cpu",
|
193
|
+
"tags" => { "region" => "us" },
|
142
194
|
"values" => [{ "time" => 1_438_612_976, "temp" => 92, "value" => 0.3445 },
|
143
195
|
{ "time" => 1_438_612_989, "temp" => 68, "value" => 0.8787 }] }]
|
144
196
|
end
|
@@ -155,10 +207,15 @@ describe InfluxDB::Client do
|
|
155
207
|
|
156
208
|
let(:response) do
|
157
209
|
{ "results" => [{ "statement_id" => 0,
|
158
|
-
"series"
|
210
|
+
"series" => [{ "name" => "cpu",
|
211
|
+
"tags" => { "region" => "pl" },
|
212
|
+
"columns" => %w[time temp value],
|
213
|
+
"values" => [[1_438_580_576, 34, 0.343443]] }] }] }
|
159
214
|
end
|
160
215
|
let(:expected_result) do
|
161
|
-
[{ "name"
|
216
|
+
[{ "name" => "cpu",
|
217
|
+
"tags" => { "region" => "pl" },
|
218
|
+
"values" => [{ "time" => 1_438_580_576, "temp" => 34, "value" => 0.343443 }] }]
|
162
219
|
end
|
163
220
|
let(:query) { 'SELECT * FROM cpu' }
|
164
221
|
|
@@ -170,12 +227,14 @@ describe InfluxDB::Client do
|
|
170
227
|
context "with database" do
|
171
228
|
let(:extra_params) { { db: 'overriden_db' } }
|
172
229
|
let(:response) do
|
173
|
-
{ "results" => [{ "series" => [{ "name"
|
230
|
+
{ "results" => [{ "series" => [{ "name" => "cpu",
|
231
|
+
"tags" => { "region" => "us" },
|
174
232
|
"columns" => %w[time temp value],
|
175
|
-
"values"
|
233
|
+
"values" => [["2015-07-07T14:58:37Z", 92, 0.3445], ["2015-07-07T14:59:09Z", 68, 0.8787]] }] }] }
|
176
234
|
end
|
177
235
|
let(:expected_result) do
|
178
|
-
[{ "name"
|
236
|
+
[{ "name" => "cpu",
|
237
|
+
"tags" => { "region" => "us" },
|
179
238
|
"values" => [{ "time" => "2015-07-07T14:58:37Z", "temp" => 92, "value" => 0.3445 },
|
180
239
|
{ "time" => "2015-07-07T14:59:09Z", "temp" => 68, "value" => 0.8787 }] }]
|
181
240
|
end
|
@@ -191,19 +250,23 @@ describe InfluxDB::Client do
|
|
191
250
|
context "with single series with multiple points" do
|
192
251
|
let(:response) do
|
193
252
|
{ "results" => [{ "statement_id" => 0,
|
194
|
-
"series"
|
195
|
-
|
196
|
-
|
253
|
+
"series" => [{ "name" => "cpu",
|
254
|
+
"tags" => { "region" => "us" },
|
255
|
+
"columns" => %w[time temp value],
|
256
|
+
"values" => [["2015-07-07T14:58:37Z", 92, 0.3445], ["2015-07-07T14:59:09Z", 68, 0.8787]] }] },
|
197
257
|
{ "statement_id" => 1,
|
198
|
-
"series"
|
199
|
-
|
200
|
-
|
258
|
+
"series" => [{ "name" => "memory",
|
259
|
+
"tags" => { "region" => "us" },
|
260
|
+
"columns" => %w[time free total],
|
261
|
+
"values" => [["2015-07-07T14:58:37Z", 96_468_992, 134_217_728], ["2015-07-07T14:59:09Z", 71_303_168, 134_217_728]] }] }] }
|
201
262
|
end
|
202
263
|
let(:expected_result) do
|
203
|
-
[{ "name"
|
264
|
+
[{ "name" => "cpu",
|
265
|
+
"tags" => { "region" => "us" },
|
204
266
|
"values" => [{ "time" => "2015-07-07T14:58:37Z", "temp" => 92, "value" => 0.3445 },
|
205
267
|
{ "time" => "2015-07-07T14:59:09Z", "temp" => 68, "value" => 0.8787 }] },
|
206
|
-
{ "name"
|
268
|
+
{ "name" => "memory",
|
269
|
+
"tags" => { "region" => "us" },
|
207
270
|
"values" => [{ "time" => "2015-07-07T14:58:37Z", "free" => 92 * 2**20, "total" => 128 * 2**20 },
|
208
271
|
{ "time" => "2015-07-07T14:59:09Z", "free" => 68 * 2**20, "total" => 128 * 2**20 }] }]
|
209
272
|
end
|
@@ -217,21 +280,37 @@ describe InfluxDB::Client do
|
|
217
280
|
context "with series with different tags" do
|
218
281
|
let(:response) do
|
219
282
|
{ "results" => [{ "statement_id" => 0,
|
220
|
-
"series"
|
221
|
-
|
283
|
+
"series" => [{ "name" => "cpu",
|
284
|
+
"tags" => { "region" => "pl" },
|
285
|
+
"columns" => %w[time temp value],
|
286
|
+
"values" => [["2015-07-07T15:13:04Z", 34, 0.343443]] },
|
287
|
+
{ "name" => "cpu",
|
288
|
+
"tags" => { "region" => "us" },
|
289
|
+
"columns" => %w[time temp value],
|
290
|
+
"values" => [["2015-07-07T14:58:37Z", 92, 0.3445], ["2015-07-07T14:59:09Z", 68, 0.8787]] }] },
|
222
291
|
{ "statement_id" => 1,
|
223
|
-
"series"
|
224
|
-
|
292
|
+
"series" => [{ "name" => "memory",
|
293
|
+
"tags" => { "region" => "pl" },
|
294
|
+
"columns" => %w[time free total],
|
295
|
+
"values" => [["2015-07-07T15:13:04Z", 35_651_584, 134_217_728]] },
|
296
|
+
{ "name" => "memory",
|
297
|
+
"tags" => { "region" => "us" },
|
298
|
+
"columns" => %w[time free total],
|
299
|
+
"values" => [["2015-07-07T14:58:37Z", 96_468_992, 134_217_728], ["2015-07-07T14:59:09Z", 71_303_168, 134_217_728]] }] }] }
|
225
300
|
end
|
226
301
|
let(:expected_result) do
|
227
|
-
[{ "name"
|
302
|
+
[{ "name" => "cpu",
|
303
|
+
"tags" => { "region" => "pl" },
|
228
304
|
"values" => [{ "time" => "2015-07-07T15:13:04Z", "temp" => 34, "value" => 0.343443 }] },
|
229
|
-
{ "name"
|
305
|
+
{ "name" => "cpu",
|
306
|
+
"tags" => { "region" => "us" },
|
230
307
|
"values" => [{ "time" => "2015-07-07T14:58:37Z", "temp" => 92, "value" => 0.3445 },
|
231
308
|
{ "time" => "2015-07-07T14:59:09Z", "temp" => 68, "value" => 0.8787 }] },
|
232
|
-
{ "name"
|
309
|
+
{ "name" => "memory",
|
310
|
+
"tags" => { "region" => "pl" },
|
233
311
|
"values" => [{ "time" => "2015-07-07T15:13:04Z", "free" => 34 * 2**20, "total" => 128 * 2**20 }] },
|
234
|
-
{ "name"
|
312
|
+
{ "name" => "memory",
|
313
|
+
"tags" => { "region" => "us" },
|
235
314
|
"values" => [{ "time" => "2015-07-07T14:58:37Z", "free" => 92 * 2**20, "total" => 128 * 2**20 },
|
236
315
|
{ "time" => "2015-07-07T14:59:09Z", "free" => 68 * 2**20, "total" => 128 * 2**20 }] }]
|
237
316
|
end
|
@@ -245,22 +324,38 @@ describe InfluxDB::Client do
|
|
245
324
|
context "with a block" do
|
246
325
|
let(:response) do
|
247
326
|
{ "results" => [{ "statement_id" => 0,
|
248
|
-
"series"
|
249
|
-
|
327
|
+
"series" => [{ "name" => "cpu",
|
328
|
+
"tags" => { "region" => "pl" },
|
329
|
+
"columns" => %w[time temp value],
|
330
|
+
"values" => [["2015-07-07T15:13:04Z", 34, 0.343443]] },
|
331
|
+
{ "name" => "cpu",
|
332
|
+
"tags" => { "region" => "us" },
|
333
|
+
"columns" => %w[time temp value],
|
334
|
+
"values" => [["2015-07-07T14:58:37Z", 92, 0.3445], ["2015-07-07T14:59:09Z", 68, 0.8787]] }] },
|
250
335
|
{ "statement_id" => 1,
|
251
|
-
"series"
|
252
|
-
|
336
|
+
"series" => [{ "name" => "memory",
|
337
|
+
"tags" => { "region" => "pl" },
|
338
|
+
"columns" => %w[time free total],
|
339
|
+
"values" => [["2015-07-07T15:13:04Z", 35_651_584, 134_217_728]] },
|
340
|
+
{ "name" => "memory",
|
341
|
+
"tags" => { "region" => "us" },
|
342
|
+
"columns" => %w[time free total],
|
343
|
+
"values" => [["2015-07-07T14:58:37Z", 96_468_992, 134_217_728], ["2015-07-07T14:59:09Z", 71_303_168, 134_217_728]] }] }] }
|
253
344
|
end
|
254
345
|
|
255
346
|
let(:expected_result) do
|
256
|
-
[{ "name"
|
347
|
+
[{ "name" => "cpu",
|
348
|
+
"tags" => { "region" => "pl" },
|
257
349
|
"values" => [{ "time" => "2015-07-07T15:13:04Z", "temp" => 34, "value" => 0.343443 }] },
|
258
|
-
{ "name"
|
350
|
+
{ "name" => "cpu",
|
351
|
+
"tags" => { "region" => "us" },
|
259
352
|
"values" => [{ "time" => "2015-07-07T14:58:37Z", "temp" => 92, "value" => 0.3445 },
|
260
353
|
{ "time" => "2015-07-07T14:59:09Z", "temp" => 68, "value" => 0.8787 }] },
|
261
|
-
{ "name"
|
354
|
+
{ "name" => "memory",
|
355
|
+
"tags" => { "region" => "pl" },
|
262
356
|
"values" => [{ "time" => "2015-07-07T15:13:04Z", "free" => 34 * 2**20, "total" => 128 * 2**20 }] },
|
263
|
-
{ "name"
|
357
|
+
{ "name" => "memory",
|
358
|
+
"tags" => { "region" => "us" },
|
264
359
|
"values" => [{ "time" => "2015-07-07T14:58:37Z", "free" => 92 * 2**20, "total" => 128 * 2**20 },
|
265
360
|
{ "time" => "2015-07-07T14:59:09Z", "free" => 68 * 2**20, "total" => 128 * 2**20 }] }]
|
266
361
|
end
|
@@ -6,10 +6,10 @@ describe InfluxDB::Client do
|
|
6
6
|
described_class.new(
|
7
7
|
"database",
|
8
8
|
{
|
9
|
-
host:
|
10
|
-
port:
|
11
|
-
username:
|
12
|
-
password:
|
9
|
+
host: "influxdb.test",
|
10
|
+
port: 9999,
|
11
|
+
username: "username",
|
12
|
+
password: "password",
|
13
13
|
time_precision: "s"
|
14
14
|
}.merge(args)
|
15
15
|
)
|
@@ -22,7 +22,7 @@ describe InfluxDB::Client do
|
|
22
22
|
describe "retrying requests" do
|
23
23
|
let(:series) { "cpu" }
|
24
24
|
let(:data) do
|
25
|
-
{ tags:
|
25
|
+
{ tags: { region: 'us', host: 'server_1' },
|
26
26
|
values: { temp: 88, value: 54 } }
|
27
27
|
end
|
28
28
|
let(:body) do
|
@@ -34,9 +34,9 @@ describe InfluxDB::Client do
|
|
34
34
|
before do
|
35
35
|
allow(client).to receive(:log)
|
36
36
|
stub_request(:post, "http://influxdb.test:9999/write").with(
|
37
|
-
query:
|
37
|
+
query: { u: "username", p: "password", precision: 's', db: database },
|
38
38
|
headers: { "Content-Type" => "application/octet-stream" },
|
39
|
-
body:
|
39
|
+
body: body
|
40
40
|
).to_raise(Timeout::Error)
|
41
41
|
end
|
42
42
|
|
@@ -74,9 +74,9 @@ describe InfluxDB::Client do
|
|
74
74
|
before do
|
75
75
|
stub_request(:post, "http://influxdb.test:9999/write")
|
76
76
|
.with(
|
77
|
-
query:
|
77
|
+
query: { u: "username", p: "password", precision: 's', db: database },
|
78
78
|
headers: { "Content-Type" => "application/octet-stream" },
|
79
|
-
body:
|
79
|
+
body: body
|
80
80
|
)
|
81
81
|
.to_raise(Timeout::Error).then
|
82
82
|
.to_raise(Timeout::Error).then
|
@@ -93,9 +93,9 @@ describe InfluxDB::Client do
|
|
93
93
|
|
94
94
|
it "raise an exception if the server didn't return 200" do
|
95
95
|
stub_request(:post, "http://influxdb.test:9999/write").with(
|
96
|
-
query:
|
96
|
+
query: { u: "username", p: "password", precision: 's', db: database },
|
97
97
|
headers: { "Content-Type" => "application/octet-stream" },
|
98
|
-
body:
|
98
|
+
body: body
|
99
99
|
).to_return(status: 401)
|
100
100
|
|
101
101
|
expect { client.write_point(series, data) }.to raise_error(InfluxDB::AuthenticationError)
|
@@ -43,13 +43,13 @@ describe InfluxDB::Client do
|
|
43
43
|
let(:expected_result) do
|
44
44
|
{
|
45
45
|
"measurement_a" => {
|
46
|
-
"a_string_field"
|
47
|
-
"a_boolean_field"
|
48
|
-
"a_float_field"
|
49
|
-
"an_integer_field"
|
46
|
+
"a_string_field" => ["string"],
|
47
|
+
"a_boolean_field" => ["boolean"],
|
48
|
+
"a_float_field" => ["float"],
|
49
|
+
"an_integer_field" => ["integer"],
|
50
50
|
},
|
51
51
|
"measurement_b" => {
|
52
|
-
"another_string"
|
52
|
+
"another_string" => ["string"],
|
53
53
|
}
|
54
54
|
}
|
55
55
|
end
|
@@ -17,7 +17,7 @@ describe InfluxDB::Client do
|
|
17
17
|
describe "#write_point" do
|
18
18
|
let(:series) { "cpu" }
|
19
19
|
let(:data) do
|
20
|
-
{ tags:
|
20
|
+
{ tags: { region: 'us', host: 'server_1' },
|
21
21
|
values: { temp: 88, value: 54 } }
|
22
22
|
end
|
23
23
|
let(:body) do
|
@@ -26,9 +26,9 @@ describe InfluxDB::Client do
|
|
26
26
|
|
27
27
|
before do
|
28
28
|
stub_request(:post, "http://influxdb.test:9999/write").with(
|
29
|
-
query:
|
29
|
+
query: { u: "username", p: "password", precision: 's', db: database },
|
30
30
|
headers: { "Content-Type" => "application/octet-stream" },
|
31
|
-
body:
|
31
|
+
body: body
|
32
32
|
).to_return(status: 204)
|
33
33
|
end
|
34
34
|
|
@@ -48,10 +48,10 @@ describe InfluxDB::Client do
|
|
48
48
|
context "with multiple series" do
|
49
49
|
let(:data) do
|
50
50
|
[{ series: 'cpu',
|
51
|
-
tags:
|
51
|
+
tags: { region: 'us', host: 'server_1' },
|
52
52
|
values: { temp: 88, value: 54 } },
|
53
53
|
{ series: 'gpu',
|
54
|
-
tags:
|
54
|
+
tags: { region: 'uk', host: 'server_5' },
|
55
55
|
values: { value: 0.5435345 } }]
|
56
56
|
end
|
57
57
|
let(:body) do
|
@@ -62,9 +62,9 @@ describe InfluxDB::Client do
|
|
62
62
|
|
63
63
|
before do
|
64
64
|
stub_request(:post, "http://influxdb.test:9999/write").with(
|
65
|
-
query:
|
65
|
+
query: { u: "username", p: "password", precision: 's', db: database },
|
66
66
|
headers: { "Content-Type" => "application/octet-stream" },
|
67
|
-
body:
|
67
|
+
body: body
|
68
68
|
).to_return(status: 204)
|
69
69
|
end
|
70
70
|
|
@@ -88,9 +88,9 @@ describe InfluxDB::Client do
|
|
88
88
|
|
89
89
|
before do
|
90
90
|
stub_request(:post, "http://influxdb.test:9999/write").with(
|
91
|
-
query:
|
91
|
+
query: { u: "username", p: "password", precision: 's', db: database },
|
92
92
|
headers: { "Content-Type" => "application/octet-stream" },
|
93
|
-
body:
|
93
|
+
body: body
|
94
94
|
).to_return(status: 204)
|
95
95
|
end
|
96
96
|
|
@@ -101,11 +101,11 @@ describe InfluxDB::Client do
|
|
101
101
|
|
102
102
|
context "with time precision set to milisceconds" do
|
103
103
|
let(:data) do
|
104
|
-
[{ series:
|
105
|
-
values:
|
104
|
+
[{ series: 'cpu',
|
105
|
+
values: { temp: 88, value: 54 },
|
106
106
|
timestamp: (Time.now.to_f * 1000).to_i },
|
107
|
-
{ series:
|
108
|
-
values:
|
107
|
+
{ series: 'gpu',
|
108
|
+
values: { value: 0.5435345 },
|
109
109
|
timestamp: (Time.now.to_f * 1000).to_i }]
|
110
110
|
end
|
111
111
|
|
@@ -117,9 +117,9 @@ describe InfluxDB::Client do
|
|
117
117
|
|
118
118
|
before do
|
119
119
|
stub_request(:post, "http://influxdb.test:9999/write").with(
|
120
|
-
query:
|
120
|
+
query: { u: "username", p: "password", precision: 'ms', db: database },
|
121
121
|
headers: { "Content-Type" => "application/octet-stream" },
|
122
|
-
body:
|
122
|
+
body: body
|
123
123
|
).to_return(status: 204)
|
124
124
|
end
|
125
125
|
it "should POST multiple points" do
|
@@ -143,9 +143,9 @@ describe InfluxDB::Client do
|
|
143
143
|
|
144
144
|
before do
|
145
145
|
stub_request(:post, "http://influxdb.test:9999/write").with(
|
146
|
-
query:
|
146
|
+
query: { u: "username", p: "password", precision: 's', db: database, rp: 'rp_1_hour' },
|
147
147
|
headers: { "Content-Type" => "application/octet-stream" },
|
148
|
-
body:
|
148
|
+
body: body
|
149
149
|
).to_return(status: 204)
|
150
150
|
end
|
151
151
|
it "should POST multiple points" do
|
@@ -169,9 +169,9 @@ describe InfluxDB::Client do
|
|
169
169
|
|
170
170
|
before do
|
171
171
|
stub_request(:post, "http://influxdb.test:9999/write").with(
|
172
|
-
query:
|
172
|
+
query: { u: "username", p: "password", precision: 's', db: 'overriden_db' },
|
173
173
|
headers: { "Content-Type" => "application/octet-stream" },
|
174
|
-
body:
|
174
|
+
body: body
|
175
175
|
).to_return(status: 204)
|
176
176
|
end
|
177
177
|
it "should POST multiple points" do
|