influxdb 0.7.0 → 0.8.0
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 +5 -5
- data/.travis.yml +15 -14
- data/CHANGELOG.md +10 -1
- data/README.md +16 -1
- data/bin/provision.sh +2 -2
- data/lib/influxdb/client.rb +1 -1
- data/lib/influxdb/client/http.rb +11 -1
- data/lib/influxdb/config.rb +2 -0
- data/lib/influxdb/errors.rb +1 -0
- data/lib/influxdb/point_value.rb +3 -1
- data/lib/influxdb/query/core.rb +7 -3
- data/lib/influxdb/query/series.rb +6 -2
- data/lib/influxdb/version.rb +1 -1
- data/spec/influxdb/cases/async_client_spec.rb +2 -2
- data/spec/influxdb/cases/query_series_spec.rb +23 -7
- data/spec/influxdb/config_spec.rb +19 -0
- data/spec/influxdb/point_value_spec.rb +8 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e35aa9d868bebe5d807a839115e59b08519d13acb5e9e9b5670ae993916046da
|
4
|
+
data.tar.gz: 72df33e054794f0037630183bfb355144d0c3fc049e76ebca4a86e90400bf709
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13de608b885545523c03fc1da9922e31c7e7499bac3c51790b174cb8a0611a9f66dc98e0d1f91d1a12bb088a928c11cdc21d1725555cba2b623ed0aa34f2877d
|
7
|
+
data.tar.gz: bf50560b3838a9092af6ee8fff18acea15281e81d3f7353677a7510a508852d637d971bc67258570e1afb753b8752b66f6533e3e946a7f845937cc567c1d0cc7
|
data/.travis.yml
CHANGED
@@ -9,6 +9,7 @@ rvm:
|
|
9
9
|
- "2.4"
|
10
10
|
- "2.5"
|
11
11
|
- "2.6"
|
12
|
+
- "2.7"
|
12
13
|
- ruby-head
|
13
14
|
env:
|
14
15
|
- TEST_TASK=spec
|
@@ -18,37 +19,37 @@ matrix:
|
|
18
19
|
- rvm: jruby-head
|
19
20
|
- rvm: ruby-head
|
20
21
|
- rvm: jruby-9.1.17.0
|
21
|
-
- rvm: jruby-9.2.
|
22
|
-
- rvm: "2.
|
22
|
+
- rvm: jruby-9.2.9.0
|
23
|
+
- rvm: "2.7"
|
23
24
|
env: influx_version=nightly channel=nightlies
|
24
25
|
include:
|
25
|
-
- rvm: "2.
|
26
|
+
- rvm: "2.7"
|
26
27
|
env: TEST_TASK=rubocop
|
27
28
|
|
28
29
|
- rvm: jruby-9.1.17.0
|
29
30
|
env: JRUBY_OPTS='--client -J-XX:+TieredCompilation -J-XX:TieredStopAtLevel=1 -J-Xss2m -J-Xmx256M'
|
30
|
-
- rvm: jruby-9.2.
|
31
|
+
- rvm: jruby-9.2.9.0
|
31
32
|
env: JRUBY_OPTS='--client -J-XX:+TieredCompilation -J-XX:TieredStopAtLevel=1 -J-Xss2m -J-Xmx256M'
|
32
33
|
- rvm: jruby-head
|
33
34
|
env: JRUBY_OPTS='--client -J-XX:+TieredCompilation -J-XX:TieredStopAtLevel=1 -J-Xss2m -J-Xmx256M'
|
34
35
|
|
35
|
-
- rvm: "2.
|
36
|
+
- rvm: "2.7"
|
36
37
|
env: influx_version=1.0.2 pkghash=88f6c30fec2c6e612e802e23b9161fdfc7c5c29f6be036f0376326445aff0037
|
37
|
-
- rvm: "2.
|
38
|
+
- rvm: "2.7"
|
38
39
|
env: influx_version=1.1.5 pkghash=0ecb9385cc008f6e5094e6e8f8ea70522023a16d4397e401898f3973176d3b21
|
39
|
-
- rvm: "2.
|
40
|
+
- rvm: "2.7"
|
40
41
|
env: influx_version=1.2.4 pkghash=2fac8391e04aa1bec9151e8f0d8f18df030c866af2b4963ab7d86c6ddc172182
|
41
|
-
- rvm: "2.
|
42
|
+
- rvm: "2.7"
|
42
43
|
env: influx_version=1.3.8 pkghash=35c9cb2943bbde04aa5e94ad6d8caf5fc9b1480bdbcde7c34078de135cc4f788
|
43
|
-
- rvm: "2.
|
44
|
+
- rvm: "2.7"
|
44
45
|
env: influx_version=1.4.3 pkghash=0477080f1d1cf8e1242dc7318280b9010c4c45cf6a415a2a5de607ae17fa0359
|
45
|
-
- rvm: "2.
|
46
|
+
- rvm: "2.7"
|
46
47
|
env: influx_version=1.5.4 pkghash=fa6f8d3196d13ffc376d533581b534692c738181ce3427c53484c138d9e6b902
|
47
|
-
- rvm: "2.
|
48
|
+
- rvm: "2.7"
|
48
49
|
env: influx_version=1.6.4 pkghash=dbfa13a0f9e38a8e7b19294c30144903bb681ac0aba0a3a8f4f349c37d5de5f9
|
49
|
-
- rvm: "2.
|
50
|
-
env: influx_version=1.7.
|
51
|
-
- rvm: "2.
|
50
|
+
- rvm: "2.7"
|
51
|
+
env: influx_version=1.7.9 pkghash=02759d70cef670d336768fd38a9cf2f046a1bf40618be78ba215e7ce75b5075f
|
52
|
+
- rvm: "2.7"
|
52
53
|
env: influx_version=nightly channel=nightlies
|
53
54
|
addons:
|
54
55
|
apt:
|
data/CHANGELOG.md
CHANGED
@@ -2,7 +2,16 @@
|
|
2
2
|
|
3
3
|
For the full commit log, [see here](https://github.com/influxdata/influxdb-ruby/commits/master).
|
4
4
|
|
5
|
-
## v0.
|
5
|
+
## v0.8.0, released 2020-02-05
|
6
|
+
|
7
|
+
- Allow dropping of specific series from specific DBs (#233, @cantino)
|
8
|
+
- Add support for MRI 2.7 (#235, @jeffkowalski)
|
9
|
+
- Raise a LineProtocolError if attempting to write empty values as field
|
10
|
+
set is required. This adds descriptive feedback to the error "unable to
|
11
|
+
parse '{series},{tags} ': invalid field format" (#236, @todtb)
|
12
|
+
- Add support for configuring HTTP Proxy (#238, @epchris)
|
13
|
+
|
14
|
+
## v0.7.0, released 2019-01-11
|
6
15
|
|
7
16
|
- Drop support for Ruby 2.2, since Bundler dropped it and we want to use
|
8
17
|
Bundler in the development cycle as well.
|
data/README.md
CHANGED
@@ -94,6 +94,21 @@ url = "https://influxdb.example.com:8086/database_name?open_timeout=3"
|
|
94
94
|
influxdb = InfluxDB::Client.new url: url, open_timeout: 10
|
95
95
|
```
|
96
96
|
|
97
|
+
#### Using a custom HTTP Proxy
|
98
|
+
|
99
|
+
By default, the `Net::HTTP` proxy behavior is used (see [Net::HTTP Proxy][proxy])
|
100
|
+
You can optionally set a proxy address and port via the `proxy_addr` and
|
101
|
+
`proxy_port` options:
|
102
|
+
|
103
|
+
``` ruby
|
104
|
+
influxdb = InfluxDB::Client.new database,
|
105
|
+
host: "influxdb.domain.com",
|
106
|
+
proxy_addr: "your.proxy.addr",
|
107
|
+
proxy_port: 8080
|
108
|
+
```
|
109
|
+
|
110
|
+
[proxy]: https://docs.ruby-lang.org/en/2.7.0/Net/HTTP.html#class-Net::HTTP-label-Proxies
|
111
|
+
|
97
112
|
### Writing data
|
98
113
|
|
99
114
|
Write some data:
|
@@ -195,7 +210,7 @@ influxdb = InfluxDB::Client.new {
|
|
195
210
|
|
196
211
|
data = {
|
197
212
|
values: { value: 0 },
|
198
|
-
tags: { foo: 'bar', bar: 'baz' }
|
213
|
+
tags: { foo: 'bar', bar: 'baz' },
|
199
214
|
timestamp: Time.now.to_i
|
200
215
|
}
|
201
216
|
|
data/bin/provision.sh
CHANGED
@@ -36,7 +36,7 @@ echo "-- Download has SHA256 hash: ${sha2_sum}"
|
|
36
36
|
echo "== Installing"
|
37
37
|
|
38
38
|
sudo dpkg -i "${HOME}/${package_name}"
|
39
|
-
sudo
|
39
|
+
sudo service influxdb start || true
|
40
40
|
|
41
41
|
echo "-- waiting for daemon to start"
|
42
42
|
while ! curl --head --fail --silent http://localhost:8086/ping; do
|
@@ -78,7 +78,7 @@ if [ ! -f /etc/influxdb/influxdb.conf ]; then
|
|
78
78
|
fi
|
79
79
|
|
80
80
|
sudo sed -i 's/auth-enabled = false/auth-enabled = true/' /etc/influxdb/influxdb.conf
|
81
|
-
sudo
|
81
|
+
sudo service influxdb restart || true
|
82
82
|
|
83
83
|
echo "-- waiting for daemon to restart"
|
84
84
|
while ! curl --head --fail --silent http://localhost:8086/ping; do
|
data/lib/influxdb/client.rb
CHANGED
@@ -51,7 +51,7 @@ module InfluxDB
|
|
51
51
|
# +:retry+:: number of times a failed request should be retried. Defaults to infinite.
|
52
52
|
def initialize(database = nil, **opts)
|
53
53
|
opts[:database] = database if database.is_a? String
|
54
|
-
@config = InfluxDB::Config.new(opts)
|
54
|
+
@config = InfluxDB::Config.new(**opts)
|
55
55
|
@stopped = false
|
56
56
|
@writer = find_writer
|
57
57
|
|
data/lib/influxdb/client/http.rb
CHANGED
@@ -45,7 +45,7 @@ module InfluxDB
|
|
45
45
|
retry_count = 0
|
46
46
|
|
47
47
|
begin
|
48
|
-
http =
|
48
|
+
http = build_http(host, config.port)
|
49
49
|
http.open_timeout = config.open_timeout
|
50
50
|
http.read_timeout = config.read_timeout
|
51
51
|
|
@@ -133,6 +133,16 @@ module InfluxDB
|
|
133
133
|
end
|
134
134
|
store
|
135
135
|
end
|
136
|
+
|
137
|
+
# Builds an http instance, taking into account any configured
|
138
|
+
# proxy configuration
|
139
|
+
def build_http(host, port)
|
140
|
+
if config.proxy_addr
|
141
|
+
Net::HTTP.new(host, port, config.proxy_addr, config.proxy_port)
|
142
|
+
else
|
143
|
+
Net::HTTP.new(host, port)
|
144
|
+
end
|
145
|
+
end
|
136
146
|
end
|
137
147
|
# rubocop:enable Metrics/MethodLength
|
138
148
|
# rubocop:enable Metrics/AbcSize
|
data/lib/influxdb/config.rb
CHANGED
data/lib/influxdb/errors.rb
CHANGED
@@ -5,6 +5,7 @@ module InfluxDB # :nodoc:
|
|
5
5
|
Error = Class.new StandardError
|
6
6
|
AuthenticationError = Class.new Error
|
7
7
|
ConnectionError = Class.new Error
|
8
|
+
LineProtocolError = Class.new Error
|
8
9
|
SeriesNotFound = Class.new Error
|
9
10
|
JSONParserError = Class.new Error
|
10
11
|
QueryError = Class.new Error
|
data/lib/influxdb/point_value.rb
CHANGED
@@ -46,7 +46,9 @@ module InfluxDB
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def escape_values(values)
|
49
|
-
|
49
|
+
if values.nil? || values.empty?
|
50
|
+
raise InfluxDB::LineProtocolError, "Cannot create point with empty values".freeze
|
51
|
+
end
|
50
52
|
|
51
53
|
values.map do |k, v|
|
52
54
|
key = escape(k.to_s, :field_key)
|
data/lib/influxdb/query/core.rb
CHANGED
@@ -121,9 +121,13 @@ module InfluxDB
|
|
121
121
|
end
|
122
122
|
|
123
123
|
def generate_payload(data)
|
124
|
-
data.map
|
125
|
-
|
126
|
-
|
124
|
+
data.map { |point| generate_point(point) }.join("\n".freeze)
|
125
|
+
end
|
126
|
+
|
127
|
+
def generate_point(point)
|
128
|
+
InfluxDB::PointValue.new(point).dump
|
129
|
+
rescue InfluxDB::LineProtocolError => e
|
130
|
+
(log :error, "Cannot write data: #{e.inspect}") && nil
|
127
131
|
end
|
128
132
|
|
129
133
|
def execute(query, db: nil, **options)
|
@@ -1,8 +1,12 @@
|
|
1
1
|
module InfluxDB
|
2
2
|
module Query
|
3
3
|
module Series # :nodoc:
|
4
|
-
def delete_series(name)
|
5
|
-
|
4
|
+
def delete_series(name, where: nil, db: config.database)
|
5
|
+
if where
|
6
|
+
execute("DROP SERIES FROM \"#{name}\" WHERE #{where}", db: db)
|
7
|
+
else
|
8
|
+
execute("DROP SERIES FROM \"#{name}\"", db: db)
|
9
|
+
end
|
6
10
|
end
|
7
11
|
|
8
12
|
def list_series
|
data/lib/influxdb/version.rb
CHANGED
@@ -14,8 +14,8 @@ describe InfluxDB::Client do
|
|
14
14
|
it "sends writes to client" do
|
15
15
|
post_request = stub_request(:post, stub_url).to_return(status: 204)
|
16
16
|
|
17
|
-
(worker.max_post_points + 100).times do
|
18
|
-
subject.write_point('a', {})
|
17
|
+
(worker.max_post_points + 100).times do |i|
|
18
|
+
subject.write_point('a', values: { i: i })
|
19
19
|
end
|
20
20
|
|
21
21
|
# The timout code is fragile, and heavily dependent on system load
|
@@ -49,16 +49,32 @@ describe InfluxDB::Client do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
describe "#delete_series" do
|
52
|
-
|
53
|
-
|
52
|
+
describe "without a where clause" do
|
53
|
+
let(:name) { "events" }
|
54
|
+
let(:query) { "DROP SERIES FROM \"#{name}\"" }
|
54
55
|
|
55
|
-
|
56
|
-
|
57
|
-
|
56
|
+
before do
|
57
|
+
stub_request(:get, "http://influxdb.test:9999/query")
|
58
|
+
.with(query: { u: "username", p: "password", q: query, db: "database" })
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should GET to remove a database" do
|
62
|
+
expect(subject.delete_series(name)).to be_a(Net::HTTPOK)
|
63
|
+
end
|
58
64
|
end
|
59
65
|
|
60
|
-
|
61
|
-
|
66
|
+
describe "with a where clause" do
|
67
|
+
let(:name) { "events" }
|
68
|
+
let(:query) { "DROP SERIES FROM \"#{name}\" WHERE \"tag\"='value'" }
|
69
|
+
|
70
|
+
before do
|
71
|
+
stub_request(:get, "http://influxdb.test:9999/query")
|
72
|
+
.with(query: { u: "username", p: "password", q: query, db: "database" })
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should GET to remove a database" do
|
76
|
+
expect(subject.delete_series(name, where: "\"tag\"='value'")).to be_a(Net::HTTPOK)
|
77
|
+
end
|
62
78
|
end
|
63
79
|
end
|
64
80
|
end
|
@@ -20,6 +20,8 @@ describe InfluxDB::Config do
|
|
20
20
|
specify { expect(conf).not_to be_udp }
|
21
21
|
specify { expect(conf).not_to be_async }
|
22
22
|
specify { expect(conf.epoch).to be_falsey }
|
23
|
+
specify { expect(conf.proxy_addr).to be_nil }
|
24
|
+
specify { expect(conf.proxy_port).to be_nil }
|
23
25
|
end
|
24
26
|
|
25
27
|
context "with no database specified" do
|
@@ -205,4 +207,21 @@ describe InfluxDB::Config do
|
|
205
207
|
expect(conf).not_to be_async
|
206
208
|
end
|
207
209
|
end
|
210
|
+
|
211
|
+
context "given explicit proxy information" do
|
212
|
+
let(:args) do
|
213
|
+
[{
|
214
|
+
host: "host",
|
215
|
+
port: "port",
|
216
|
+
username: "username",
|
217
|
+
password: "password",
|
218
|
+
time_precision: "m",
|
219
|
+
proxy_addr: "my.proxy.addr",
|
220
|
+
proxy_port: 8080
|
221
|
+
}]
|
222
|
+
end
|
223
|
+
|
224
|
+
specify { expect(conf.proxy_addr).to eq("my.proxy.addr") }
|
225
|
+
specify { expect(conf.proxy_port).to eq(8080) }
|
226
|
+
end
|
208
227
|
end
|
@@ -40,6 +40,14 @@ describe InfluxDB::PointValue do
|
|
40
40
|
expected = series.join(",") + " " + fields.join(",")
|
41
41
|
expect(point.dump).to eq(expected)
|
42
42
|
end
|
43
|
+
|
44
|
+
context 'with empty values' do
|
45
|
+
let(:empty_values_data) { { series: 'test_series', values: {} } }
|
46
|
+
|
47
|
+
it 'should raise an exception' do
|
48
|
+
expect { InfluxDB::PointValue.new(empty_values_data) }.to raise_error(InfluxDB::LineProtocolError)
|
49
|
+
end
|
50
|
+
end
|
43
51
|
end
|
44
52
|
|
45
53
|
describe 'dump' do
|
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.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Todd Persen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -167,8 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
167
|
- !ruby/object:Gem::Version
|
168
168
|
version: '0'
|
169
169
|
requirements: []
|
170
|
-
|
171
|
-
rubygems_version: 2.6.13
|
170
|
+
rubygems_version: 3.0.3
|
172
171
|
signing_key:
|
173
172
|
specification_version: 4
|
174
173
|
summary: Ruby library for InfluxDB.
|