influxdb 0.3.13 → 0.3.14

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: 01adedbe7674717e14ed72845cfff4e156f2689a
4
- data.tar.gz: ceefc5493edfa1144ec139d2dc07dc0ae5fe1db4
3
+ metadata.gz: ae726ac300f9a2011eba6e9ac4e6085637cf914d
4
+ data.tar.gz: ed8ecb52b432e865b83fd4d52d7b16c8200f38f9
5
5
  SHA512:
6
- metadata.gz: b86ea8d1c86d8f90e5d11bca3654d7e4462071a126ecbc2bf737514538235da8e0e91836fc12b290c5d8a5c968a5b14a7d1f5308743157762c0796d505b8c52a
7
- data.tar.gz: 7564b0e19b8e80eb82734054481371459900608324a3d5d844f16680867f3cddf581c4d35e23ed98a1451acd2757465e26884807f28c0e3f63fa21e478b3ebb8
6
+ metadata.gz: abcaa0deb749051a1dfd578f4f10686b6fab9f607a59105747f4cf9f35e556de8831c36e1e72b7d01358816cf45859dda54d52f1830601f080c13b12a1badb52
7
+ data.tar.gz: 4bba860e2fc1bea053025979288d255d40e2cb775a11a1e59f4231284b439b560c5b4d7ef8bbfffc6f703ecd934dc77f8f2674bd049e71ad8b6aa83566128a04
@@ -9,6 +9,7 @@ AllCops:
9
9
  - 'smoke/**/*'
10
10
  DisplayCopNames: true
11
11
  StyleGuideCopsOnly: false
12
+ TargetRubyVersion: 1.9
12
13
 
13
14
  Rails:
14
15
  Enabled: false
@@ -2,15 +2,17 @@ sudo: required
2
2
  dist: trusty
3
3
  language: ruby
4
4
  before_install:
5
- - gem install bundler
6
- - gem update bundler
5
+ - gem update --system --no-doc
6
+ - gem install bundler --no-doc
7
+ - gem update bundler --no-doc
7
8
  - smoke/provision.sh
8
9
  rvm:
9
10
  - 1.9.3
10
11
  - 2.0.0
11
12
  - 2.1.10
12
- - 2.2.4
13
- - 2.3.1
13
+ - 2.2.5
14
+ - 2.3.3
15
+ - 2.4.0
14
16
  - ruby-head
15
17
  env:
16
18
  - TEST_TASK=spec
@@ -19,29 +21,22 @@ matrix:
19
21
  allow_failures:
20
22
  - rvm: jruby-head
21
23
  - rvm: ruby-head
22
- - rvm: jruby-9.0.5.0
23
- - rvm: 2.3.1
24
+ - rvm: jruby-9.1.5.0
25
+ - rvm: 2.4.0
24
26
  env: TEST_TASK=smoke influx_version=nightly channel=nightlies
25
27
  include:
26
- - rvm: 2.3.1
28
+ - rvm: 2.4.0
27
29
  env: TEST_TASK=rubocop
28
- - rvm: jruby-9.0.5.0
29
- env: JRUBY_OPTS='--client -J-XX:+TieredCompilation -J-XX:TieredStopAtLevel=1 -J-Xss2m -J-Xmx256M'
30
+ - rvm: jruby-9.1.5.0
30
31
  - rvm: jruby-head
31
32
  env: JRUBY_OPTS='--client -J-XX:+TieredCompilation -J-XX:TieredStopAtLevel=1 -J-Xss2m -J-Xmx256M'
32
- - rvm: 2.3.1
33
- env: TEST_TASK=smoke influx_version=0.10.3-1 pkghash=96244557d9bb7485ddc9d084ff7ce783
34
- - rvm: 2.3.1
35
- env: TEST_TASK=smoke influx_version=0.11.1-1 pkghash=f4cf8363125038dff038ced6b16bcafd
36
- - rvm: 2.3.1
37
- env: TEST_TASK=smoke influx_version=0.12.2-1 pkghash=f28bb1c57d52dc1593dca45b86be5913
38
- - rvm: 2.3.1
39
- env: TEST_TASK=smoke influx_version=0.13.0 pkghash=4f0aa76fee22cf4c18e2a0779ba4f462
40
- - rvm: 2.3.1
33
+ - rvm: 2.4.0
41
34
  env: TEST_TASK=smoke influx_version=1.0.2 pkghash=3e4c349cb57507913d9abda1459bdbed
42
- - rvm: 2.3.1
35
+ - rvm: 2.4.0
43
36
  env: TEST_TASK=smoke influx_version=1.1.0 pkghash=682904c350ecfc2a60ec9c6c08453ef2
44
- - rvm: 2.3.1
37
+ - rvm: 2.4.0
38
+ env: TEST_TASK=smoke influx_version=1.2.0 pkghash=f79959802930c7e9d6e81ffd366c0629
39
+ - rvm: 2.4.0
45
40
  env: TEST_TASK=smoke influx_version=nightly channel=nightlies
46
41
  fail_fast: true
47
42
  addons:
@@ -6,6 +6,13 @@ For the full commit log, [see here](https://github.com/influxdata/influxdb-ruby/
6
6
 
7
7
  - None.
8
8
 
9
+ ## v0.3.14, released 2017-02-06
10
+
11
+ - Added option `discard_write_errors` to silently ignore errors when writing
12
+ to the server (#182, @mickey).
13
+ - Added `#list_series` and `#delete_series` to `InfluxDB::Client` (#183-186,
14
+ @wrcola).
15
+
9
16
  ## v0.3.13, released 2016-11-23
10
17
 
11
18
  - You can now `InfluxDB::Client#query`, `#write_points`, `#write_point` and
data/README.md CHANGED
@@ -470,6 +470,21 @@ data = {
470
470
  influxdb.write_point(name, data)
471
471
  ```
472
472
 
473
+ Discard write errors:
474
+
475
+ ``` ruby
476
+ require 'influxdb'
477
+ host = '127.0.0.1'
478
+ port = 4444
479
+
480
+ influxdb = InfluxDB::Client.new(
481
+ udp: { host: host, port: port },
482
+ discard_write_errors: true
483
+ )
484
+
485
+ influxdb.write_point('hitchhiker', { values: { value: 666 } })
486
+ ```
487
+
473
488
  ### Reading data
474
489
 
475
490
  #### Querying
@@ -14,6 +14,7 @@ require "influxdb/query/database"
14
14
  require "influxdb/query/user"
15
15
  require "influxdb/query/continuous_query"
16
16
  require "influxdb/query/retention_policy"
17
+ require "influxdb/query/series"
17
18
 
18
19
  require "influxdb/client/http"
19
20
  require "influxdb/client"
@@ -15,6 +15,7 @@ module InfluxDB
15
15
  include InfluxDB::Query::User
16
16
  include InfluxDB::Query::ContinuousQuery
17
17
  include InfluxDB::Query::RetentionPolicy
18
+ include InfluxDB::Query::Series
18
19
 
19
20
  # Initializes a new InfluxDB client
20
21
  #
@@ -22,7 +22,8 @@ module InfluxDB
22
22
  :prefix,
23
23
  :chunk_size,
24
24
  :denormalize,
25
- :epoch
25
+ :epoch,
26
+ :discard_write_errors
26
27
 
27
28
  attr_reader :async, :udp
28
29
 
@@ -109,8 +110,9 @@ module InfluxDB
109
110
  end
110
111
 
111
112
  def extract_writer_options!(opts)
112
- @async = opts.fetch :async, false
113
- @udp = opts.fetch :udp, false
113
+ @async = opts.fetch :async, false
114
+ @udp = opts.fetch :udp, false
115
+ @discard_write_errors = opts.fetch :discard_write_errors, false
114
116
  end
115
117
 
116
118
  def extract_query_options!(opts)
@@ -55,6 +55,10 @@ module InfluxDB
55
55
  data = data.is_a?(Array) ? data : [data]
56
56
  payload = generate_payload(data)
57
57
  writer.write(payload, precision, retention_policy, database)
58
+ rescue => e
59
+ raise e unless config.discard_write_errors
60
+
61
+ log :error, "Cannot write data: #{e.inspect}"
58
62
  end
59
63
 
60
64
  # Example:
@@ -118,7 +122,9 @@ module InfluxDB
118
122
  end
119
123
 
120
124
  def execute(query, options = {})
121
- url = full_url("/query", q: query)
125
+ params = { q: query }
126
+ params[:db] = options.delete(:db) if options.key?(:db)
127
+ url = full_url("/query".freeze, params)
122
128
  get(url, options)
123
129
  end
124
130
 
@@ -0,0 +1,18 @@
1
+ module InfluxDB
2
+ module Query
3
+ module Series # :nodoc:
4
+ def delete_series(name)
5
+ execute("DROP SERIES FROM #{name}", db: config.database)
6
+ end
7
+
8
+ def list_series
9
+ resp = execute("SHOW SERIES".freeze, parse: true, db: config.database)
10
+ resp = fetch_series(resp)
11
+ raw_values(resp[0])
12
+ .fetch('values'.freeze, [])
13
+ .map { |val| val[0].split(',')[0] }
14
+ .uniq
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1,3 +1,3 @@
1
1
  module InfluxDB # :nodoc:
2
- VERSION = "0.3.13".freeze
2
+ VERSION = "0.3.14".freeze
3
3
  end
@@ -110,7 +110,7 @@ module InfluxDB
110
110
  log :debug, "Found data in the queue! (#{data.length} points)"
111
111
  client.write(data.join("\n"), nil)
112
112
  rescue => e
113
- puts "Cannot write data: #{e.inspect}"
113
+ log :error, "Cannot write data: #{e.inspect}"
114
114
  end
115
115
 
116
116
  break if queue.length > max_post_points
@@ -50,7 +50,10 @@ describe InfluxDB::Client do
50
50
  end
51
51
 
52
52
  describe "#list_cluster_admins" do
53
- let(:response) { { "results" => [{ "series" => [{ "columns" => %w(user admin), "values" => [["dbadmin", true], ["foobar", false]] }] }] } }
53
+ let(:response) do
54
+ { "results" => [{ "statement_id" => 0,
55
+ "series" => [{ "columns" => %w(user admin), "values" => [["dbadmin", true], ["foobar", false]] }] }] }
56
+ end
54
57
  let(:expected_result) { ["dbadmin"] }
55
58
 
56
59
  before do
@@ -21,7 +21,8 @@ describe InfluxDB::Client do
21
21
  let(:query) { "SHOW CONTINUOUS QUERIES" }
22
22
  let(:database) { "testdb" }
23
23
  let(:response) do
24
- { "results" => [{ "series" => [{ "name" => "otherdb", "columns" => %w(name query),
24
+ { "results" => [{ "statement_id" => 0,
25
+ "series" => [{ "name" => "otherdb", "columns" => %w(name query),
25
26
  "values" => [["clicks_per_hour", "CREATE CONTINUOUS QUERY clicks_per_hour ON otherdb BEGIN SELECT count(name) INTO \"otherdb\".\"default\".clicksCount_1h FROM \"otherdb\".\"default\".clicks GROUP BY time(1h) END"]] },
26
27
  { "name" => "testdb", "columns" => %w(name query),
27
28
  "values" => [["event_counts", "CREATE CONTINUOUS QUERY event_counts ON testdb BEGIN SELECT count(type) INTO \"testdb\".\"default\".typeCount_10m_byType FROM \"testdb\".\"default\".events GROUP BY time(10m), type END"]] }] }] }
@@ -16,7 +16,8 @@ describe InfluxDB::Client do
16
16
  describe "#query" do
17
17
  let(:query) { "SELECT value FROM requests_per_minute WHERE time > 1437019900" }
18
18
  let(:response) do
19
- { "results" => [{ "series" => [{ "name" => "requests_per_minute",
19
+ { "results" => [{ "statement_id" => 0,
20
+ "series" => [{ "name" => "requests_per_minute",
20
21
  "columns" => %w(time value) }] }] }
21
22
  end
22
23
 
@@ -17,7 +17,7 @@ describe InfluxDB::Client do
17
17
 
18
18
  let(:args) { {} }
19
19
  let(:query) { nil }
20
- let(:response) { { "results" => [] } }
20
+ let(:response) { { "results" => [{ "statement_id" => 0 }] } }
21
21
 
22
22
  before do
23
23
  stub_request(:get, "http://influxdb.test:9999/query").with(
@@ -17,7 +17,7 @@ describe InfluxDB::Client do
17
17
 
18
18
  let(:args) { {} }
19
19
  let(:query) { nil }
20
- let(:response) { { "results" => [] } }
20
+ let(:response) { { "results" => [{ "statement_id" => 0 }] } }
21
21
 
22
22
  before do
23
23
  stub_request(:get, "http://influxdb.test:9999/query").with(
@@ -26,8 +26,8 @@ describe InfluxDB::Client do
26
26
  end
27
27
 
28
28
  describe "#list_retention_policies" do
29
- let(:response) { { "results" => [{ "series" => [{ "columns" => %w(name duration replicaN default), "values" => [["default", "0", 1, true], ["another", "1", 2, false]] }] }] } }
30
29
  let(:query) { "SHOW RETENTION POLICIES ON \"database\"" }
30
+ let(:response) { { "results" => [{ "statement_id" => 0, "series" => [{ "columns" => %w(name duration replicaN default), "values" => [["default", "0", 1, true], ["another", "1", 2, false]] }] }] } }
31
31
  let(:expected_result) { [{ "name" => "default", "duration" => "0", "replicaN" => 1, "default" => true }, { "name" => "another", "duration" => "1", "replicaN" => 2, "default" => false }] }
32
32
 
33
33
  it "should GET a list of retention policies" do
@@ -17,34 +17,36 @@ describe InfluxDB::Client do
17
17
 
18
18
  let(:args) { {} }
19
19
 
20
- ### TODO ###
21
-
22
- # describe "DELETE #delete_series" do
23
- # it "removes a series" do
24
- # stub_request(:delete, "http://influxdb.test:9999/db/database/series/foo").with(
25
- # query: { u: "username", p: "password" }
26
- # )
27
-
28
- # expect(subject.delete_series("foo")).to be_a(Net::HTTPOK)
29
- # end
30
- # end
31
-
32
- # describe "GET #list_series" do
33
- # it "returns a list of all series names" do
34
- # data = [
35
- # { "name" => "list_series_result",
36
- # "columns" => %w(time name),
37
- # "points" => [[0, 'a'], [0, 'b']]
38
- # }
39
- # ]
40
-
41
- # stub_request(:get, "http://influxdb.test:9999/db/database/series").with(
42
- # query: { u: "username", p: "password", q: "list series", time_precision: "s" }
43
- # ).to_return(
44
- # body: JSON.generate(data)
45
- # )
46
-
47
- # expect(subject.list_series).to eq %w(a b)
48
- # end
49
- # end
20
+ describe "GET #list_series" do
21
+ let(:response) { { "results" => [{ "series" => [{ "columns" => "key", "values" => [["series1,name=default,duration=0"], ["series2,name=another,duration=1"]] }] }] } }
22
+ let(:data) { %w(series1 series2) }
23
+ let(:query) { "SHOW SERIES" }
24
+
25
+ before do
26
+ stub_request(:get, "http://influxdb.test:9999/query").with(
27
+ query: { u: "username", p: "password", q: query, db: "database" }
28
+ ).to_return(
29
+ body: JSON.generate(response)
30
+ )
31
+ end
32
+
33
+ it "returns a list of all series names" do
34
+ expect(subject.list_series).to eq data
35
+ end
36
+ end
37
+
38
+ describe "#delete_series" do
39
+ let(:name) { "events" }
40
+ let(:query) { "DROP SERIES FROM #{name}" }
41
+
42
+ before do
43
+ stub_request(:get, "http://influxdb.test:9999/query").with(
44
+ query: { u: "username", p: "password", q: query, db: "database" }
45
+ )
46
+ end
47
+
48
+ it "should GET to remove a database" do
49
+ expect(subject.delete_series(name)).to be_a(Net::HTTPOK)
50
+ end
51
+ end
50
52
  end
@@ -17,7 +17,7 @@ describe InfluxDB::Client do
17
17
 
18
18
  let(:args) { {} }
19
19
  let(:query) { nil }
20
- let(:response) { { "results" => [] } }
20
+ let(:response) { { "results" => [{ "statement_id" => 0 }] } }
21
21
 
22
22
  before do
23
23
  stub_request(:get, "http://influxdb.test:9999/query").with(
@@ -98,8 +98,8 @@ describe InfluxDB::Client do
98
98
  end
99
99
 
100
100
  describe "#list_users" do
101
- let(:response) { { "results" => [{ "series" => [{ "columns" => %w(user admin), "values" => [["dbadmin", true], ["foobar", false]] }] }] } }
102
101
  let(:query) { "SHOW USERS" }
102
+ let(:response) { { "results" => [{ "statement_id" => 0, "series" => [{ "columns" => %w(user admin), "values" => [["dbadmin", true], ["foobar", false]] }] }] } }
103
103
  let(:expected_result) { [{ "username" => "dbadmin", "admin" => true }, { "username" => "foobar", "admin" => false }] }
104
104
 
105
105
  it "should GET a list of database users" do
@@ -19,7 +19,8 @@ describe InfluxDB::Client do
19
19
  let(:query_compiled) { "SELECT value FROM requests_per_minute WHERE time > 1437019900" }
20
20
 
21
21
  let(:response) do
22
- { "results" => [{ "series" => [{ "name" => "requests_per_minute",
22
+ { "results" => [{ "statement_id" => 0,
23
+ "series" => [{ "name" => "requests_per_minute",
23
24
  "columns" => %w(time value) }] }] }
24
25
  end
25
26
 
@@ -32,10 +32,12 @@ describe InfluxDB::Client do
32
32
  let(:extra_params) { { chunked: "true", chunk_size: "100" } }
33
33
 
34
34
  let(:response_line_1) do
35
- { "results" => [{ "series" => [{ "name" => "cpu", "tags" => { "region" => "pl" }, "columns" => %w(time temp value), "values" => [["2015-07-07T15:13:04Z", 34, 0.343443]] }] }] }
35
+ { "results" => [{ "statement_id" => 0,
36
+ "series" => [{ "name" => "cpu", "tags" => { "region" => "pl" }, "columns" => %w(time temp value), "values" => [["2015-07-07T15:13:04Z", 34, 0.343443]] }] }] }
36
37
  end
37
38
  let(:response_line_2) do
38
- { "results" => [{ "series" => [{ "name" => "cpu", "tags" => { "region" => "us" }, "columns" => %w(time temp value), "values" => [["2015-07-07T14:58:37Z", 92, 0.3445], ["2015-07-07T14:59:09Z", 68, 0.8787]] }] }] }
39
+ { "results" => [{ "statement_id" => 0,
40
+ "series" => [{ "name" => "cpu", "tags" => { "region" => "us" }, "columns" => %w(time temp value), "values" => [["2015-07-07T14:58:37Z", 92, 0.3445], ["2015-07-07T14:59:09Z", 68, 0.8787]] }] }] }
39
41
  end
40
42
  let(:response) do
41
43
  JSON.generate(response_line_1) + "\n" + JSON.generate(response_line_2)
@@ -59,16 +61,20 @@ describe InfluxDB::Client do
59
61
  let(:extra_params) { { chunked: "true", chunk_size: "100" } }
60
62
 
61
63
  let(:response_line_1) do
62
- { "results" => [{ "series" => [{ "name" => "access_times.service_1", "tags" => { "code" => "200", "result" => "failure", "status" => "OK" }, "columns" => %w(time value), "values" => [["2015-07-08T07:15:22Z", 327]] }] }] }
64
+ { "results" => [{ "statement_id" => 0,
65
+ "series" => [{ "name" => "access_times.service_1", "tags" => { "code" => "200", "result" => "failure", "status" => "OK" }, "columns" => %w(time value), "values" => [["2015-07-08T07:15:22Z", 327]] }] }] }
63
66
  end
64
67
  let(:response_line_2) do
65
- { "results" => [{ "series" => [{ "name" => "access_times.service_1", "tags" => { "code" => "500", "result" => "failure", "status" => "Internal Server Error" }, "columns" => %w(time value), "values" => [["2015-07-08T06:15:22Z", 873]] }] }] }
68
+ { "results" => [{ "statement_id" => 0,
69
+ "series" => [{ "name" => "access_times.service_1", "tags" => { "code" => "500", "result" => "failure", "status" => "Internal Server Error" }, "columns" => %w(time value), "values" => [["2015-07-08T06:15:22Z", 873]] }] }] }
66
70
  end
67
71
  let(:response_line_3) do
68
- { "results" => [{ "series" => [{ "name" => "access_times.service_2", "tags" => { "code" => "200", "result" => "failure", "status" => "OK" }, "columns" => %w(time value), "values" => [["2015-07-08T07:15:22Z", 943]] }] }] }
72
+ { "results" => [{ "statement_id" => 0,
73
+ "series" => [{ "name" => "access_times.service_2", "tags" => { "code" => "200", "result" => "failure", "status" => "OK" }, "columns" => %w(time value), "values" => [["2015-07-08T07:15:22Z", 943]] }] }] }
69
74
  end
70
75
  let(:response_line_4) do
71
- { "results" => [{ "series" => [{ "name" => "access_times.service_2", "tags" => { "code" => "500", "result" => "failure", "status" => "Internal Server Error" }, "columns" => %w(time value), "values" => [["2015-07-08T06:15:22Z", 606]] }] }] }
76
+ { "results" => [{ "statement_id" => 0,
77
+ "series" => [{ "name" => "access_times.service_2", "tags" => { "code" => "500", "result" => "failure", "status" => "Internal Server Error" }, "columns" => %w(time value), "values" => [["2015-07-08T06:15:22Z", 606]] }] }] }
72
78
  end
73
79
  let(:response) do
74
80
  JSON.generate(response_line_1) + "\n" + JSON.generate(response_line_2) + "\n" + JSON.generate(response_line_3) + "\n" + JSON.generate(response_line_4)
@@ -26,7 +26,8 @@ describe InfluxDB::Client do
26
26
  describe "#query" do
27
27
  context "with single series with multiple points" do
28
28
  let(:response) do
29
- { "results" => [{ "series" => [{ "name" => "cpu", "tags" => { "region" => "us" },
29
+ { "results" => [{ "statement_id" => 0,
30
+ "series" => [{ "name" => "cpu", "tags" => { "region" => "us" },
30
31
  "columns" => %w(time temp value),
31
32
  "values" => [["2015-07-07T14:58:37Z", 92, 0.3445], ["2015-07-07T14:59:09Z", 68, 0.8787]] }] }] }
32
33
  end
@@ -44,7 +45,8 @@ describe InfluxDB::Client do
44
45
 
45
46
  context "with series with different tags" do
46
47
  let(:response) do
47
- { "results" => [{ "series" => [{ "name" => "cpu", "tags" => { "region" => "pl" }, "columns" => %w(time temp value), "values" => [["2015-07-07T15:13:04Z", 34, 0.343443]] },
48
+ { "results" => [{ "statement_id" => 0,
49
+ "series" => [{ "name" => "cpu", "tags" => { "region" => "pl" }, "columns" => %w(time temp value), "values" => [["2015-07-07T15:13:04Z", 34, 0.343443]] },
48
50
  { "name" => "cpu", "tags" => { "region" => "us" }, "columns" => %w(time temp value), "values" => [["2015-07-07T14:58:37Z", 92, 0.3445], ["2015-07-07T14:59:09Z", 68, 0.8787]] }] }] }
49
51
  end
50
52
  let(:expected_result) do
@@ -63,7 +65,8 @@ describe InfluxDB::Client do
63
65
 
64
66
  context "with multiple series with different tags" do
65
67
  let(:response) do
66
- { "results" => [{ "series" => [{ "name" => "access_times.service_1", "tags" => { "code" => "200", "result" => "failure", "status" => "OK" }, "columns" => %w(time value), "values" => [["2015-07-08T07:15:22Z", 327]] },
68
+ { "results" => [{ "statement_id" => 0,
69
+ "series" => [{ "name" => "access_times.service_1", "tags" => { "code" => "200", "result" => "failure", "status" => "OK" }, "columns" => %w(time value), "values" => [["2015-07-08T07:15:22Z", 327]] },
67
70
  { "name" => "access_times.service_1", "tags" => { "code" => "500", "result" => "failure", "status" => "Internal Server Error" }, "columns" => %w(time value), "values" => [["2015-07-08T06:15:22Z", 873]] },
68
71
  { "name" => "access_times.service_2", "tags" => { "code" => "200", "result" => "failure", "status" => "OK" }, "columns" => %w(time value), "values" => [["2015-07-08T07:15:22Z", 943]] },
69
72
  { "name" => "access_times.service_2", "tags" => { "code" => "500", "result" => "failure", "status" => "Internal Server Error" }, "columns" => %w(time value), "values" => [["2015-07-08T06:15:22Z", 606]] }] }] }
@@ -83,7 +86,8 @@ describe InfluxDB::Client do
83
86
 
84
87
  context "with multiple series for explicit value only" do
85
88
  let(:response) do
86
- { "results" => [{ "series" => [{ "name" => "access_times.service_1", "columns" => %w(time value), "values" => [["2015-07-08T06:15:22Z", 873], ["2015-07-08T07:15:22Z", 327]] },
89
+ { "results" => [{ "statement_id" => 0,
90
+ "series" => [{ "name" => "access_times.service_1", "columns" => %w(time value), "values" => [["2015-07-08T06:15:22Z", 873], ["2015-07-08T07:15:22Z", 327]] },
87
91
  { "name" => "access_times.service_2", "columns" => %w(time value), "values" => [["2015-07-08T06:15:22Z", 606], ["2015-07-08T07:15:22Z", 943]] }] }] }
88
92
  end
89
93
  let(:expected_result) do
@@ -99,7 +103,8 @@ describe InfluxDB::Client do
99
103
 
100
104
  context "with a block" do
101
105
  let(:response) do
102
- { "results" => [{ "series" => [{ "name" => "cpu", "tags" => { "region" => "pl" }, "columns" => %w(time temp value), "values" => [["2015-07-07T15:13:04Z", 34, 0.343443]] },
106
+ { "results" => [{ "statement_id" => 0,
107
+ "series" => [{ "name" => "cpu", "tags" => { "region" => "pl" }, "columns" => %w(time temp value), "values" => [["2015-07-07T15:13:04Z", 34, 0.343443]] },
103
108
  { "name" => "cpu", "tags" => { "region" => "us" }, "columns" => %w(time temp value), "values" => [["2015-07-07T14:58:37Z", 92, 0.3445], ["2015-07-07T14:59:09Z", 68, 0.8787]] }] }] }
104
109
  end
105
110
 
@@ -126,7 +131,8 @@ describe InfluxDB::Client do
126
131
  let(:extra_params) { { epoch: 's' } }
127
132
 
128
133
  let(:response) do
129
- { "results" => [{ "series" => [{ "name" => "cpu", "tags" => { "region" => "pl" }, "columns" => %w(time temp value), "values" => [[1_438_580_576, 34, 0.343443]] },
134
+ { "results" => [{ "statement_id" => 0,
135
+ "series" => [{ "name" => "cpu", "tags" => { "region" => "pl" }, "columns" => %w(time temp value), "values" => [[1_438_580_576, 34, 0.343443]] },
130
136
  { "name" => "cpu", "tags" => { "region" => "us" }, "columns" => %w(time temp value), "values" => [[1_438_612_976, 92, 0.3445], [1_438_612_989, 68, 0.8787]] }] }] }
131
137
  end
132
138
  let(:expected_result) do
@@ -148,7 +154,8 @@ describe InfluxDB::Client do
148
154
  let(:extra_params) { { chunked: "true", chunk_size: "100" } }
149
155
 
150
156
  let(:response) do
151
- { "results" => [{ "series" => [{ "name" => "cpu", "tags" => { "region" => "pl" }, "columns" => %w(time temp value), "values" => [[1_438_580_576, 34, 0.343443]] }] }] }
157
+ { "results" => [{ "statement_id" => 0,
158
+ "series" => [{ "name" => "cpu", "tags" => { "region" => "pl" }, "columns" => %w(time temp value), "values" => [[1_438_580_576, 34, 0.343443]] }] }] }
152
159
  end
153
160
  let(:expected_result) do
154
161
  [{ "name" => "cpu", "tags" => { "region" => "pl" }, "values" => [{ "time" => 1_438_580_576, "temp" => 34, "value" => 0.343443 }] }]
@@ -183,10 +190,12 @@ describe InfluxDB::Client do
183
190
  describe "multiple select queries" do
184
191
  context "with single series with multiple points" do
185
192
  let(:response) do
186
- { "results" => [{ "series" => [{ "name" => "cpu", "tags" => { "region" => "us" },
193
+ { "results" => [{ "statement_id" => 0,
194
+ "series" => [{ "name" => "cpu", "tags" => { "region" => "us" },
187
195
  "columns" => %w(time temp value),
188
196
  "values" => [["2015-07-07T14:58:37Z", 92, 0.3445], ["2015-07-07T14:59:09Z", 68, 0.8787]] }] },
189
- { "series" => [{ "name" => "memory", "tags" => { "region" => "us" },
197
+ { "statement_id" => 1,
198
+ "series" => [{ "name" => "memory", "tags" => { "region" => "us" },
190
199
  "columns" => %w(time free total),
191
200
  "values" => [["2015-07-07T14:58:37Z", 96_468_992, 134_217_728], ["2015-07-07T14:59:09Z", 71_303_168, 134_217_728]] }] }] }
192
201
  end
@@ -207,9 +216,11 @@ describe InfluxDB::Client do
207
216
 
208
217
  context "with series with different tags" do
209
218
  let(:response) do
210
- { "results" => [{ "series" => [{ "name" => "cpu", "tags" => { "region" => "pl" }, "columns" => %w(time temp value), "values" => [["2015-07-07T15:13:04Z", 34, 0.343443]] },
219
+ { "results" => [{ "statement_id" => 0,
220
+ "series" => [{ "name" => "cpu", "tags" => { "region" => "pl" }, "columns" => %w(time temp value), "values" => [["2015-07-07T15:13:04Z", 34, 0.343443]] },
211
221
  { "name" => "cpu", "tags" => { "region" => "us" }, "columns" => %w(time temp value), "values" => [["2015-07-07T14:58:37Z", 92, 0.3445], ["2015-07-07T14:59:09Z", 68, 0.8787]] }] },
212
- { "series" => [{ "name" => "memory", "tags" => { "region" => "pl" }, "columns" => %w(time free total), "values" => [["2015-07-07T15:13:04Z", 35_651_584, 134_217_728]] },
222
+ { "statement_id" => 1,
223
+ "series" => [{ "name" => "memory", "tags" => { "region" => "pl" }, "columns" => %w(time free total), "values" => [["2015-07-07T15:13:04Z", 35_651_584, 134_217_728]] },
213
224
  { "name" => "memory", "tags" => { "region" => "us" }, "columns" => %w(time free total), "values" => [["2015-07-07T14:58:37Z", 96_468_992, 134_217_728], ["2015-07-07T14:59:09Z", 71_303_168, 134_217_728]] }] }] }
214
225
  end
215
226
  let(:expected_result) do
@@ -233,9 +244,11 @@ describe InfluxDB::Client do
233
244
 
234
245
  context "with a block" do
235
246
  let(:response) do
236
- { "results" => [{ "series" => [{ "name" => "cpu", "tags" => { "region" => "pl" }, "columns" => %w(time temp value), "values" => [["2015-07-07T15:13:04Z", 34, 0.343443]] },
247
+ { "results" => [{ "statement_id" => 0,
248
+ "series" => [{ "name" => "cpu", "tags" => { "region" => "pl" }, "columns" => %w(time temp value), "values" => [["2015-07-07T15:13:04Z", 34, 0.343443]] },
237
249
  { "name" => "cpu", "tags" => { "region" => "us" }, "columns" => %w(time temp value), "values" => [["2015-07-07T14:58:37Z", 92, 0.3445], ["2015-07-07T14:59:09Z", 68, 0.8787]] }] },
238
- { "series" => [{ "name" => "memory", "tags" => { "region" => "pl" }, "columns" => %w(time free total), "values" => [["2015-07-07T15:13:04Z", 35_651_584, 134_217_728]] },
250
+ { "statement_id" => 1,
251
+ "series" => [{ "name" => "memory", "tags" => { "region" => "pl" }, "columns" => %w(time free total), "values" => [["2015-07-07T15:13:04Z", 35_651_584, 134_217_728]] },
239
252
  { "name" => "memory", "tags" => { "region" => "us" }, "columns" => %w(time free total), "values" => [["2015-07-07T14:58:37Z", 96_468_992, 134_217_728], ["2015-07-07T14:59:09Z", 71_303_168, 134_217_728]] }] }] }
240
253
  end
241
254
 
@@ -8,7 +8,7 @@ describe InfluxDB::Client do
8
8
  describe "#write" do
9
9
  let(:message) { 'responses,region=eu value=5i' }
10
10
 
11
- it "sends a UPD packet" do
11
+ it "sends a UDP packet" do
12
12
  s = UDPSocket.new
13
13
  s.bind("localhost", 44_444)
14
14
 
@@ -16,6 +16,32 @@ describe InfluxDB::Client do
16
16
 
17
17
  rec_message = s.recvfrom(30).first
18
18
  expect(rec_message).to eq message
19
+
20
+ s.close
21
+ end
22
+ end
23
+
24
+ describe "#write with discard_write_errors" do
25
+ let(:client) do
26
+ described_class.new(
27
+ udp: { host: "localhost", port: 44_444 },
28
+ discard_write_errors: true
29
+ )
30
+ end
31
+
32
+ it "doesn't raise" do
33
+ s = UDPSocket.new
34
+ s.bind("localhost", 44_444)
35
+
36
+ client.write_point("responses", values: { value: 5 }, tags: { region: 'eu' })
37
+ s.close
38
+
39
+ client.write_point("responses", values: { value: 7 }, tags: { region: 'eu' })
40
+
41
+ allow(client).to receive(:log)
42
+ expect do
43
+ client.write_point("responses", values: { value: 7 }, tags: { region: 'eu' })
44
+ end.not_to raise_error
19
45
  end
20
46
  end
21
47
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: influxdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.13
4
+ version: 0.3.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Todd Persen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-23 00:00:00.000000000 Z
11
+ date: 2017-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -138,6 +138,7 @@ files:
138
138
  - lib/influxdb/query/core.rb
139
139
  - lib/influxdb/query/database.rb
140
140
  - lib/influxdb/query/retention_policy.rb
141
+ - lib/influxdb/query/series.rb
141
142
  - lib/influxdb/query/user.rb
142
143
  - lib/influxdb/version.rb
143
144
  - lib/influxdb/writer/async.rb
@@ -189,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
190
  version: '0'
190
191
  requirements: []
191
192
  rubyforge_project:
192
- rubygems_version: 2.5.1
193
+ rubygems_version: 2.6.10
193
194
  signing_key:
194
195
  specification_version: 4
195
196
  summary: Ruby library for InfluxDB.