influxdb 0.3.17 → 0.4.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 +4 -4
- data/.rubocop.yml +9 -1
- data/.travis.yml +10 -13
- data/CHANGELOG.md +9 -11
- data/Gemfile +0 -5
- data/README.md +67 -23
- data/Rakefile +10 -9
- data/influxdb.gemspec +5 -6
- data/lib/influxdb/client.rb +7 -11
- data/lib/influxdb/client/http.rb +1 -2
- data/lib/influxdb/config.rb +136 -68
- data/lib/influxdb/errors.rb +6 -17
- data/lib/influxdb/logging.rb +28 -6
- data/lib/influxdb/point_value.rb +7 -5
- data/lib/influxdb/query/builder.rb +1 -2
- data/lib/influxdb/query/cluster.rb +1 -1
- data/lib/influxdb/query/continuous_query.rb +6 -6
- data/lib/influxdb/query/core.rb +21 -19
- data/lib/influxdb/version.rb +1 -1
- data/lib/influxdb/writer/async.rb +7 -6
- data/lib/influxdb/writer/udp.rb +16 -7
- data/spec/influxdb/cases/query_cluster_spec.rb +1 -1
- data/spec/influxdb/cases/query_continuous_query_spec.rb +2 -2
- data/spec/influxdb/cases/query_core_spec.rb +1 -1
- data/spec/influxdb/cases/query_retention_policy_spec.rb +1 -1
- data/spec/influxdb/cases/query_series_spec.rb +1 -1
- data/spec/influxdb/cases/query_user_spec.rb +1 -1
- data/spec/influxdb/cases/query_with_params_spec.rb +1 -1
- data/spec/influxdb/cases/querying_issue_7000_spec.rb +6 -6
- data/spec/influxdb/cases/querying_spec.rb +25 -25
- data/spec/influxdb/cases/show_field_keys_spec.rb +7 -7
- data/spec/influxdb/client_spec.rb +3 -1
- data/spec/influxdb/config_spec.rb +81 -0
- data/spec/influxdb/logging_spec.rb +14 -3
- data/spec/influxdb/point_value_spec.rb +3 -16
- data/spec/spec_helper.rb +5 -3
- metadata +10 -38
data/lib/influxdb/errors.rb
CHANGED
@@ -2,23 +2,12 @@ require "net/http"
|
|
2
2
|
require "zlib"
|
3
3
|
|
4
4
|
module InfluxDB # :nodoc:
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
class ConnectionError < Error
|
12
|
-
end
|
13
|
-
|
14
|
-
class SeriesNotFound < Error
|
15
|
-
end
|
16
|
-
|
17
|
-
class JSONParserError < Error
|
18
|
-
end
|
19
|
-
|
20
|
-
class QueryError < Error
|
21
|
-
end
|
5
|
+
Error = Class.new StandardError
|
6
|
+
AuthenticationError = Class.new Error
|
7
|
+
ConnectionError = Class.new Error
|
8
|
+
SeriesNotFound = Class.new Error
|
9
|
+
JSONParserError = Class.new Error
|
10
|
+
QueryError = Class.new Error
|
22
11
|
|
23
12
|
# When executing queries via HTTP, some errors can more or less safely
|
24
13
|
# be ignored and we can retry the query again. This following
|
data/lib/influxdb/logging.rb
CHANGED
@@ -6,18 +6,40 @@ module InfluxDB
|
|
6
6
|
|
7
7
|
class << self
|
8
8
|
attr_writer :logger
|
9
|
-
|
9
|
+
attr_writer :log_level
|
10
|
+
|
11
|
+
def logger
|
12
|
+
return false if @logger == false
|
13
|
+
@logger ||= ::Logger.new(STDERR).tap { |logger| logger.level = Logger::INFO }
|
14
|
+
end
|
10
15
|
|
11
|
-
|
12
|
-
|
13
|
-
|
16
|
+
def log_level
|
17
|
+
@log_level || Logger::INFO
|
18
|
+
end
|
19
|
+
|
20
|
+
def log?(level)
|
21
|
+
case level
|
22
|
+
when :debug then log_level <= Logger::DEBUG
|
23
|
+
when :info then log_level <= Logger::INFO
|
24
|
+
when :warn then log_level <= Logger::WARN
|
25
|
+
when :error then log_level <= Logger::ERROR
|
26
|
+
when :fatal then log_level <= Logger::FATAL
|
27
|
+
else true
|
28
|
+
end
|
29
|
+
end
|
14
30
|
end
|
15
31
|
|
16
32
|
private
|
17
33
|
|
18
|
-
def log(level, message)
|
34
|
+
def log(level, message = nil, &block)
|
19
35
|
return unless InfluxDB::Logging.logger
|
20
|
-
InfluxDB::Logging.
|
36
|
+
return unless InfluxDB::Logging.log?(level)
|
37
|
+
|
38
|
+
if block_given?
|
39
|
+
InfluxDB::Logging.logger.send(level.to_sym, PREFIX, &block)
|
40
|
+
else
|
41
|
+
InfluxDB::Logging.logger.send(level.to_sym, PREFIX) { message }
|
42
|
+
end
|
21
43
|
end
|
22
44
|
end
|
23
45
|
end
|
data/lib/influxdb/point_value.rb
CHANGED
@@ -25,11 +25,13 @@ module InfluxDB
|
|
25
25
|
tag_key: ['='.freeze, ' '.freeze, ','.freeze],
|
26
26
|
tag_value: ['='.freeze, ' '.freeze, ','.freeze],
|
27
27
|
field_key: ['='.freeze, ' '.freeze, ','.freeze, '"'.freeze],
|
28
|
-
field_value: [
|
28
|
+
field_value: ['"'.freeze],
|
29
29
|
}.freeze
|
30
30
|
|
31
|
+
private_constant :ESCAPES
|
32
|
+
|
31
33
|
def escape(s, type)
|
32
|
-
# rubocop:disable
|
34
|
+
# rubocop:disable Layout/AlignParameters
|
33
35
|
s = s.encode "UTF-8".freeze, "UTF-8".freeze,
|
34
36
|
invalid: :replace,
|
35
37
|
undef: :replace,
|
@@ -47,12 +49,12 @@ module InfluxDB
|
|
47
49
|
key = escape(k.to_s, :field_key)
|
48
50
|
val = escape_value(v)
|
49
51
|
"#{key}=#{val}"
|
50
|
-
end.join(",")
|
52
|
+
end.join(",".freeze)
|
51
53
|
end
|
52
54
|
|
53
55
|
def escape_value(value)
|
54
56
|
if value.is_a?(String)
|
55
|
-
'"' + escape(value, :field_value) + '"'
|
57
|
+
'"'.freeze + escape(value, :field_value) + '"'.freeze
|
56
58
|
elsif value.is_a?(Integer)
|
57
59
|
"#{value}i"
|
58
60
|
else
|
@@ -67,7 +69,7 @@ module InfluxDB
|
|
67
69
|
key = escape(k.to_s, :tag_key)
|
68
70
|
val = escape(v.to_s, :tag_value)
|
69
71
|
|
70
|
-
"#{key}=#{val}" unless key == "" || val == ""
|
72
|
+
"#{key}=#{val}" unless key == "".freeze || val == "".freeze
|
71
73
|
end.compact
|
72
74
|
|
73
75
|
tags.join(",") unless tags.empty?
|
@@ -10,7 +10,6 @@ module InfluxDB
|
|
10
10
|
end
|
11
11
|
|
12
12
|
query % params
|
13
|
-
|
14
13
|
rescue KeyError => e
|
15
14
|
raise ArgumentError, e.message
|
16
15
|
end
|
@@ -18,7 +17,7 @@ module InfluxDB
|
|
18
17
|
def quote(param)
|
19
18
|
case param
|
20
19
|
when String, Symbol
|
21
|
-
"'" + param.to_s.gsub(/['"\\\x0]/, '\\\\\0') + "'"
|
20
|
+
"'".freeze + param.to_s.gsub(/['"\\\x0]/, '\\\\\0') + "'".freeze
|
22
21
|
when Integer, Float, TrueClass, FalseClass
|
23
22
|
param.to_s
|
24
23
|
else
|
@@ -10,16 +10,16 @@ module InfluxDB
|
|
10
10
|
.map { |v| { 'name' => v.first, 'query' => v.last } }
|
11
11
|
end
|
12
12
|
|
13
|
-
def create_continuous_query(name, database, query,
|
13
|
+
def create_continuous_query(name, database, query, resample_every: nil, resample_for: nil)
|
14
14
|
clause = ["CREATE CONTINUOUS QUERY", name, "ON", database]
|
15
15
|
|
16
|
-
if
|
17
|
-
clause << "RESAMPLE"
|
18
|
-
clause << "EVERY #{
|
19
|
-
clause << "FOR #{
|
16
|
+
if resample_every || resample_for
|
17
|
+
clause << "RESAMPLE".freeze
|
18
|
+
clause << "EVERY #{resample_every}" if resample_every
|
19
|
+
clause << "FOR #{resample_for}" if resample_for
|
20
20
|
end
|
21
21
|
|
22
|
-
clause = clause.join(" ") << " BEGIN\n" << query << "\nEND"
|
22
|
+
clause = clause.join(" ".freeze) << " BEGIN\n".freeze << query << "\nEND".freeze
|
23
23
|
execute(clause)
|
24
24
|
end
|
25
25
|
|
data/lib/influxdb/query/core.rb
CHANGED
@@ -18,14 +18,17 @@ module InfluxDB
|
|
18
18
|
end
|
19
19
|
|
20
20
|
# rubocop:disable Metrics/MethodLength
|
21
|
-
def query(
|
22
|
-
query
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
21
|
+
def query(
|
22
|
+
query,
|
23
|
+
params: nil,
|
24
|
+
denormalize: config.denormalize,
|
25
|
+
chunk_size: config.chunk_size,
|
26
|
+
**opts
|
27
|
+
)
|
28
|
+
query = builder.build(query, params)
|
29
|
+
|
30
|
+
url = full_url("/query".freeze, query_params(query, opts))
|
31
|
+
series = fetch_series(get(url, parse: true, json_streaming: !chunk_size.nil?))
|
29
32
|
|
30
33
|
if block_given?
|
31
34
|
series.each do |s|
|
@@ -80,13 +83,13 @@ module InfluxDB
|
|
80
83
|
|
81
84
|
private
|
82
85
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
86
|
+
def query_params(
|
87
|
+
query,
|
88
|
+
precision: config.time_precision,
|
89
|
+
epoch: config.epoch,
|
90
|
+
chunk_size: config.chunk_size,
|
91
|
+
database: config.database
|
92
|
+
)
|
90
93
|
params = { q: query, db: database }
|
91
94
|
params[:precision] = precision if precision
|
92
95
|
params[:epoch] = epoch if epoch
|
@@ -98,7 +101,6 @@ module InfluxDB
|
|
98
101
|
|
99
102
|
params
|
100
103
|
end
|
101
|
-
# rubocop:enable Metrics/MethodLength
|
102
104
|
|
103
105
|
def denormalized_series_list(series)
|
104
106
|
series.map do |s|
|
@@ -122,9 +124,9 @@ module InfluxDB
|
|
122
124
|
end.join("\n".freeze)
|
123
125
|
end
|
124
126
|
|
125
|
-
def execute(query,
|
127
|
+
def execute(query, db: nil, **options)
|
126
128
|
params = { q: query }
|
127
|
-
params[:db] =
|
129
|
+
params[:db] = db if db
|
128
130
|
url = full_url("/query".freeze, params)
|
129
131
|
get(url, options)
|
130
132
|
end
|
@@ -136,7 +138,7 @@ module InfluxDB
|
|
136
138
|
end
|
137
139
|
|
138
140
|
def raw_values(series)
|
139
|
-
series.select { |k, _| %w
|
141
|
+
series.select { |k, _| %w[columns values].include?(k) }
|
140
142
|
end
|
141
143
|
|
142
144
|
def full_url(path, params = {})
|
data/lib/influxdb/version.rb
CHANGED
@@ -77,7 +77,7 @@ module InfluxDB
|
|
77
77
|
def spawn_threads!
|
78
78
|
@threads = []
|
79
79
|
num_worker_threads.times do |thread_num|
|
80
|
-
log
|
80
|
+
log(:debug) { "Spawning background worker thread #{thread_num}." }
|
81
81
|
|
82
82
|
@threads << Thread.new do
|
83
83
|
Thread.current[:influxdb] = object_id
|
@@ -87,14 +87,15 @@ module InfluxDB
|
|
87
87
|
sleep rand(sleep_interval)
|
88
88
|
end
|
89
89
|
|
90
|
-
log
|
90
|
+
log(:debug) { "Exit background worker thread #{thread_num}." }
|
91
91
|
end
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
95
|
def check_background_queue(thread_num = 0)
|
96
|
-
log
|
97
|
-
|
96
|
+
log(:debug) do
|
97
|
+
"Checking background queue on thread #{thread_num} (#{current_thread_count} active)"
|
98
|
+
end
|
98
99
|
|
99
100
|
loop do
|
100
101
|
data = []
|
@@ -107,7 +108,7 @@ module InfluxDB
|
|
107
108
|
return if data.empty?
|
108
109
|
|
109
110
|
begin
|
110
|
-
log
|
111
|
+
log(:debug) { "Found data in the queue! (#{data.length} points)" }
|
111
112
|
client.write(data.join("\n"), nil)
|
112
113
|
rescue => e
|
113
114
|
log :error, "Cannot write data: #{e.inspect}"
|
@@ -118,7 +119,7 @@ module InfluxDB
|
|
118
119
|
end
|
119
120
|
|
120
121
|
def stop!
|
121
|
-
log
|
122
|
+
log(:debug) { "Thread exiting, flushing queue." }
|
122
123
|
check_background_queue until queue.empty?
|
123
124
|
end
|
124
125
|
end
|
data/lib/influxdb/writer/udp.rb
CHANGED
@@ -4,17 +4,26 @@ module InfluxDB
|
|
4
4
|
class UDP
|
5
5
|
attr_accessor :socket
|
6
6
|
attr_reader :host, :port
|
7
|
-
|
7
|
+
|
8
|
+
def initialize(client, host: "localhost".freeze, port: 4444)
|
8
9
|
@client = client
|
9
|
-
|
10
|
-
@
|
11
|
-
@port = config.fetch(:port, 4444)
|
12
|
-
self.socket = UDPSocket.new
|
13
|
-
socket.connect(host, port)
|
10
|
+
@host = host
|
11
|
+
@port = port
|
14
12
|
end
|
15
13
|
|
16
14
|
def write(payload, _precision = nil, _retention_policy = nil, _database = nil)
|
17
|
-
|
15
|
+
with_socket { |sock| sock.send(payload, 0) }
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def with_socket
|
21
|
+
unless socket
|
22
|
+
self.socket = UDPSocket.new
|
23
|
+
socket.connect(host, port)
|
24
|
+
end
|
25
|
+
|
26
|
+
yield socket
|
18
27
|
end
|
19
28
|
end
|
20
29
|
end
|
@@ -52,7 +52,7 @@ describe InfluxDB::Client do
|
|
52
52
|
describe "#list_cluster_admins" do
|
53
53
|
let(:response) do
|
54
54
|
{ "results" => [{ "statement_id" => 0,
|
55
|
-
"series" => [{ "columns" => %w
|
55
|
+
"series" => [{ "columns" => %w[user admin], "values" => [["dbadmin", true], ["foobar", false]] }] }] }
|
56
56
|
end
|
57
57
|
let(:expected_result) { ["dbadmin"] }
|
58
58
|
|
@@ -22,9 +22,9 @@ describe InfluxDB::Client do
|
|
22
22
|
let(:database) { "testdb" }
|
23
23
|
let(:response) do
|
24
24
|
{ "results" => [{ "statement_id" => 0,
|
25
|
-
"series" => [{ "name" => "otherdb", "columns" => %w
|
25
|
+
"series" => [{ "name" => "otherdb", "columns" => %w[name query],
|
26
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"]] },
|
27
|
-
{ "name" => "testdb", "columns" => %w
|
27
|
+
{ "name" => "testdb", "columns" => %w[name query],
|
28
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"]] }] }] }
|
29
29
|
end
|
30
30
|
|
@@ -27,7 +27,7 @@ describe InfluxDB::Client do
|
|
27
27
|
|
28
28
|
describe "#list_retention_policies" do
|
29
29
|
let(:query) { "SHOW RETENTION POLICIES ON \"database\"" }
|
30
|
-
let(:response) { { "results" => [{ "statement_id" => 0, "series" => [{ "columns" => %w
|
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
|
@@ -19,7 +19,7 @@ describe InfluxDB::Client do
|
|
19
19
|
|
20
20
|
describe "GET #list_series" do
|
21
21
|
let(:response) { { "results" => [{ "series" => [{ "columns" => "key", "values" => [["series1,name=default,duration=0"], ["series2,name=another,duration=1"]] }] }] } }
|
22
|
-
let(:data) { %w
|
22
|
+
let(:data) { %w[series1 series2] }
|
23
23
|
let(:query) { "SHOW SERIES" }
|
24
24
|
|
25
25
|
before do
|
@@ -99,7 +99,7 @@ describe InfluxDB::Client do
|
|
99
99
|
|
100
100
|
describe "#list_users" do
|
101
101
|
let(:query) { "SHOW USERS" }
|
102
|
-
let(:response) { { "results" => [{ "statement_id" => 0, "series" => [{ "columns" => %w
|
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
|
@@ -33,11 +33,11 @@ describe InfluxDB::Client do
|
|
33
33
|
|
34
34
|
let(:response_line_1) do
|
35
35
|
{ "results" => [{ "statement_id" => 0,
|
36
|
-
"series" => [{ "name" => "cpu", "tags" => { "region" => "pl" }, "columns" => %w
|
36
|
+
"series" => [{ "name" => "cpu", "tags" => { "region" => "pl" }, "columns" => %w[time temp value], "values" => [["2015-07-07T15:13:04Z", 34, 0.343443]] }] }] }
|
37
37
|
end
|
38
38
|
let(:response_line_2) do
|
39
39
|
{ "results" => [{ "statement_id" => 0,
|
40
|
-
"series" => [{ "name" => "cpu", "tags" => { "region" => "us" }, "columns" => %w
|
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]] }] }] }
|
41
41
|
end
|
42
42
|
let(:response) do
|
43
43
|
JSON.generate(response_line_1) + "\n" + JSON.generate(response_line_2)
|
@@ -62,19 +62,19 @@ describe InfluxDB::Client do
|
|
62
62
|
|
63
63
|
let(:response_line_1) do
|
64
64
|
{ "results" => [{ "statement_id" => 0,
|
65
|
-
"series" => [{ "name" => "access_times.service_1", "tags" => { "code" => "200", "result" => "failure", "status" => "OK" }, "columns" => %w
|
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]] }] }] }
|
66
66
|
end
|
67
67
|
let(:response_line_2) do
|
68
68
|
{ "results" => [{ "statement_id" => 0,
|
69
|
-
"series" => [{ "name" => "access_times.service_1", "tags" => { "code" => "500", "result" => "failure", "status" => "Internal Server Error" }, "columns" => %w
|
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]] }] }] }
|
70
70
|
end
|
71
71
|
let(:response_line_3) do
|
72
72
|
{ "results" => [{ "statement_id" => 0,
|
73
|
-
"series" => [{ "name" => "access_times.service_2", "tags" => { "code" => "200", "result" => "failure", "status" => "OK" }, "columns" => %w
|
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]] }] }] }
|
74
74
|
end
|
75
75
|
let(:response_line_4) do
|
76
76
|
{ "results" => [{ "statement_id" => 0,
|
77
|
-
"series" => [{ "name" => "access_times.service_2", "tags" => { "code" => "500", "result" => "failure", "status" => "Internal Server Error" }, "columns" => %w
|
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]] }] }] }
|
78
78
|
end
|
79
79
|
let(:response) do
|
80
80
|
JSON.generate(response_line_1) + "\n" + JSON.generate(response_line_2) + "\n" + JSON.generate(response_line_3) + "\n" + JSON.generate(response_line_4)
|
@@ -28,7 +28,7 @@ describe InfluxDB::Client do
|
|
28
28
|
let(:response) do
|
29
29
|
{ "results" => [{ "statement_id" => 0,
|
30
30
|
"series" => [{ "name" => "cpu", "tags" => { "region" => "us" },
|
31
|
-
"columns" => %w
|
31
|
+
"columns" => %w[time temp value],
|
32
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
|
@@ -46,8 +46,8 @@ 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" => [{ "name" => "cpu", "tags" => { "region" => "pl" }, "columns" => %w
|
50
|
-
{ "name" => "cpu", "tags" => { "region" => "us" }, "columns" => %w
|
49
|
+
"series" => [{ "name" => "cpu", "tags" => { "region" => "pl" }, "columns" => %w[time temp value], "values" => [["2015-07-07T15:13:04Z", 34, 0.343443]] },
|
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]] }] }] }
|
51
51
|
end
|
52
52
|
let(:expected_result) do
|
53
53
|
[{ "name" => "cpu", "tags" => { "region" => "pl" },
|
@@ -66,10 +66,10 @@ describe InfluxDB::Client do
|
|
66
66
|
context "with multiple series with different tags" do
|
67
67
|
let(:response) do
|
68
68
|
{ "results" => [{ "statement_id" => 0,
|
69
|
-
"series" => [{ "name" => "access_times.service_1", "tags" => { "code" => "200", "result" => "failure", "status" => "OK" }, "columns" => %w
|
70
|
-
{ "name" => "access_times.service_1", "tags" => { "code" => "500", "result" => "failure", "status" => "Internal Server Error" }, "columns" => %w
|
71
|
-
{ "name" => "access_times.service_2", "tags" => { "code" => "200", "result" => "failure", "status" => "OK" }, "columns" => %w
|
72
|
-
{ "name" => "access_times.service_2", "tags" => { "code" => "500", "result" => "failure", "status" => "Internal Server Error" }, "columns" => %w
|
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]] },
|
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]] },
|
71
|
+
{ "name" => "access_times.service_2", "tags" => { "code" => "200", "result" => "failure", "status" => "OK" }, "columns" => %w[time value], "values" => [["2015-07-08T07:15:22Z", 943]] },
|
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]] }] }] }
|
73
73
|
end
|
74
74
|
let(:expected_result) do
|
75
75
|
[{ "name" => "access_times.service_1", "tags" => { "code" => "200", "result" => "failure", "status" => "OK" }, "values" => [{ "time" => "2015-07-08T07:15:22Z", "value" => 327 }] },
|
@@ -87,8 +87,8 @@ describe InfluxDB::Client do
|
|
87
87
|
context "with multiple series for explicit value only" do
|
88
88
|
let(:response) do
|
89
89
|
{ "results" => [{ "statement_id" => 0,
|
90
|
-
"series" => [{ "name" => "access_times.service_1", "columns" => %w
|
91
|
-
{ "name" => "access_times.service_2", "columns" => %w
|
90
|
+
"series" => [{ "name" => "access_times.service_1", "columns" => %w[time value], "values" => [["2015-07-08T06:15:22Z", 873], ["2015-07-08T07:15:22Z", 327]] },
|
91
|
+
{ "name" => "access_times.service_2", "columns" => %w[time value], "values" => [["2015-07-08T06:15:22Z", 606], ["2015-07-08T07:15:22Z", 943]] }] }] }
|
92
92
|
end
|
93
93
|
let(:expected_result) do
|
94
94
|
[{ "name" => "access_times.service_1", "tags" => nil, "values" => [{ "time" => "2015-07-08T06:15:22Z", "value" => 873 }, { "time" => "2015-07-08T07:15:22Z", "value" => 327 }] },
|
@@ -104,8 +104,8 @@ describe InfluxDB::Client do
|
|
104
104
|
context "with a block" do
|
105
105
|
let(:response) do
|
106
106
|
{ "results" => [{ "statement_id" => 0,
|
107
|
-
"series" => [{ "name" => "cpu", "tags" => { "region" => "pl" }, "columns" => %w
|
108
|
-
{ "name" => "cpu", "tags" => { "region" => "us" }, "columns" => %w
|
107
|
+
"series" => [{ "name" => "cpu", "tags" => { "region" => "pl" }, "columns" => %w[time temp value], "values" => [["2015-07-07T15:13:04Z", 34, 0.343443]] },
|
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]] }] }] }
|
109
109
|
end
|
110
110
|
|
111
111
|
let(:expected_result) do
|
@@ -132,8 +132,8 @@ describe InfluxDB::Client do
|
|
132
132
|
|
133
133
|
let(:response) do
|
134
134
|
{ "results" => [{ "statement_id" => 0,
|
135
|
-
"series" => [{ "name" => "cpu", "tags" => { "region" => "pl" }, "columns" => %w
|
136
|
-
{ "name" => "cpu", "tags" => { "region" => "us" }, "columns" => %w
|
135
|
+
"series" => [{ "name" => "cpu", "tags" => { "region" => "pl" }, "columns" => %w[time temp value], "values" => [[1_438_580_576, 34, 0.343443]] },
|
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]] }] }] }
|
137
137
|
end
|
138
138
|
let(:expected_result) do
|
139
139
|
[{ "name" => "cpu", "tags" => { "region" => "pl" },
|
@@ -155,7 +155,7 @@ describe InfluxDB::Client do
|
|
155
155
|
|
156
156
|
let(:response) do
|
157
157
|
{ "results" => [{ "statement_id" => 0,
|
158
|
-
"series" => [{ "name" => "cpu", "tags" => { "region" => "pl" }, "columns" => %w
|
158
|
+
"series" => [{ "name" => "cpu", "tags" => { "region" => "pl" }, "columns" => %w[time temp value], "values" => [[1_438_580_576, 34, 0.343443]] }] }] }
|
159
159
|
end
|
160
160
|
let(:expected_result) do
|
161
161
|
[{ "name" => "cpu", "tags" => { "region" => "pl" }, "values" => [{ "time" => 1_438_580_576, "temp" => 34, "value" => 0.343443 }] }]
|
@@ -171,7 +171,7 @@ describe InfluxDB::Client do
|
|
171
171
|
let(:extra_params) { { db: 'overriden_db' } }
|
172
172
|
let(:response) do
|
173
173
|
{ "results" => [{ "series" => [{ "name" => "cpu", "tags" => { "region" => "us" },
|
174
|
-
"columns" => %w
|
174
|
+
"columns" => %w[time temp value],
|
175
175
|
"values" => [["2015-07-07T14:58:37Z", 92, 0.3445], ["2015-07-07T14:59:09Z", 68, 0.8787]] }] }] }
|
176
176
|
end
|
177
177
|
let(:expected_result) do
|
@@ -192,11 +192,11 @@ describe InfluxDB::Client do
|
|
192
192
|
let(:response) do
|
193
193
|
{ "results" => [{ "statement_id" => 0,
|
194
194
|
"series" => [{ "name" => "cpu", "tags" => { "region" => "us" },
|
195
|
-
"columns" => %w
|
195
|
+
"columns" => %w[time temp value],
|
196
196
|
"values" => [["2015-07-07T14:58:37Z", 92, 0.3445], ["2015-07-07T14:59:09Z", 68, 0.8787]] }] },
|
197
197
|
{ "statement_id" => 1,
|
198
198
|
"series" => [{ "name" => "memory", "tags" => { "region" => "us" },
|
199
|
-
"columns" => %w
|
199
|
+
"columns" => %w[time free total],
|
200
200
|
"values" => [["2015-07-07T14:58:37Z", 96_468_992, 134_217_728], ["2015-07-07T14:59:09Z", 71_303_168, 134_217_728]] }] }] }
|
201
201
|
end
|
202
202
|
let(:expected_result) do
|
@@ -217,11 +217,11 @@ describe InfluxDB::Client do
|
|
217
217
|
context "with series with different tags" do
|
218
218
|
let(:response) do
|
219
219
|
{ "results" => [{ "statement_id" => 0,
|
220
|
-
"series" => [{ "name" => "cpu", "tags" => { "region" => "pl" }, "columns" => %w
|
221
|
-
{ "name" => "cpu", "tags" => { "region" => "us" }, "columns" => %w
|
220
|
+
"series" => [{ "name" => "cpu", "tags" => { "region" => "pl" }, "columns" => %w[time temp value], "values" => [["2015-07-07T15:13:04Z", 34, 0.343443]] },
|
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]] }] },
|
222
222
|
{ "statement_id" => 1,
|
223
|
-
"series" => [{ "name" => "memory", "tags" => { "region" => "pl" }, "columns" => %w
|
224
|
-
{ "name" => "memory", "tags" => { "region" => "us" }, "columns" => %w
|
223
|
+
"series" => [{ "name" => "memory", "tags" => { "region" => "pl" }, "columns" => %w[time free total], "values" => [["2015-07-07T15:13:04Z", 35_651_584, 134_217_728]] },
|
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]] }] }] }
|
225
225
|
end
|
226
226
|
let(:expected_result) do
|
227
227
|
[{ "name" => "cpu", "tags" => { "region" => "pl" },
|
@@ -245,11 +245,11 @@ describe InfluxDB::Client do
|
|
245
245
|
context "with a block" do
|
246
246
|
let(:response) do
|
247
247
|
{ "results" => [{ "statement_id" => 0,
|
248
|
-
"series" => [{ "name" => "cpu", "tags" => { "region" => "pl" }, "columns" => %w
|
249
|
-
{ "name" => "cpu", "tags" => { "region" => "us" }, "columns" => %w
|
248
|
+
"series" => [{ "name" => "cpu", "tags" => { "region" => "pl" }, "columns" => %w[time temp value], "values" => [["2015-07-07T15:13:04Z", 34, 0.343443]] },
|
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]] }] },
|
250
250
|
{ "statement_id" => 1,
|
251
|
-
"series" => [{ "name" => "memory", "tags" => { "region" => "pl" }, "columns" => %w
|
252
|
-
{ "name" => "memory", "tags" => { "region" => "us" }, "columns" => %w
|
251
|
+
"series" => [{ "name" => "memory", "tags" => { "region" => "pl" }, "columns" => %w[time free total], "values" => [["2015-07-07T15:13:04Z", 35_651_584, 134_217_728]] },
|
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]] }] }] }
|
253
253
|
end
|
254
254
|
|
255
255
|
let(:expected_result) do
|