fluent-plugin-influxdb 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +6 -0
- data/fluent-plugin-influxdb.gemspec +1 -1
- data/lib/fluent/plugin/out_influxdb.rb +21 -9
- data/test/plugin/test_out_influxdb.rb +44 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17b05b4d4062e69351985214664cd8802f693884
|
4
|
+
data.tar.gz: 7c48f1472a0f615416011887c55aefdc2d8a4b90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c40c346d389f84f42504510270a31d18ec8395535ca2335172a7796367f31f4906bd12580fe36f4ae5aa5b59dd98ab33e7f1bdb0f787d4c5787794d493d46d8
|
7
|
+
data.tar.gz: 7bfa200fbf29e479259e39466929494fe36cf7e33e56cda96190c814d7996da676226eaa31685d64497603c0873f62b1d8f5033436114365399d630629e359d4
|
data/History.md
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "fluent-plugin-influxdb"
|
6
|
-
s.version = '0.2.
|
6
|
+
s.version = '0.2.5'
|
7
7
|
s.authors = ["Masahiro Nakagawa", "FangLi"]
|
8
8
|
s.email = ["repeatedly@gmail.com", "surivlee@gmail.com"]
|
9
9
|
s.description = %q{InfluxDB output plugin for Fluentd}
|
@@ -47,18 +47,27 @@ DESC
|
|
47
47
|
|
48
48
|
def configure(conf)
|
49
49
|
super
|
50
|
-
@influxdb = InfluxDB::Client.new @dbname, host: @host,
|
51
|
-
port: @port,
|
52
|
-
username: @user,
|
53
|
-
password: @password,
|
54
|
-
async: false,
|
55
|
-
time_precision: @time_precision,
|
56
|
-
use_ssl: @use_ssl,
|
57
|
-
verify_ssl: @verify_ssl
|
58
50
|
end
|
59
51
|
|
60
52
|
def start
|
61
53
|
super
|
54
|
+
|
55
|
+
$log.info "Connecting to database: #{@dbname}, host: #{@host}, port: #{@port}, username: #{@user}, password = #{@password}, use_ssl = #{@use_ssl}, verify_ssl = #{@verify_ssl}"
|
56
|
+
|
57
|
+
# ||= for testing.
|
58
|
+
@influxdb ||= InfluxDB::Client.new @dbname, host: @host,
|
59
|
+
port: @port,
|
60
|
+
username: @user,
|
61
|
+
password: @password,
|
62
|
+
async: false,
|
63
|
+
time_precision: @time_precision,
|
64
|
+
use_ssl: @use_ssl,
|
65
|
+
verify_ssl: @verify_ssl
|
66
|
+
|
67
|
+
existing_databases = @influxdb.list_databases.map { |x| x['name'] }
|
68
|
+
unless existing_databases.include? @dbname
|
69
|
+
raise Fluent::ConfigError, 'Database ' + @dbname + ' doesn\'t exist. Create it first, please. Existing databases: ' + existing_databases.join(',')
|
70
|
+
end
|
62
71
|
end
|
63
72
|
|
64
73
|
FORMATTED_RESULT_FOR_INVALID_RECORD = ''.freeze
|
@@ -88,7 +97,10 @@ DESC
|
|
88
97
|
tags = {}
|
89
98
|
record.each_pair do |k, v|
|
90
99
|
if @tag_keys.include?(k)
|
91
|
-
|
100
|
+
# If the tag value is not nil, empty, or a space, add the tag
|
101
|
+
if v.to_s.strip != ''
|
102
|
+
tags[k] = v
|
103
|
+
end
|
92
104
|
else
|
93
105
|
values[k] = v
|
94
106
|
end
|
@@ -8,6 +8,10 @@ class InfluxdbOutputTest < Test::Unit::TestCase
|
|
8
8
|
@points = []
|
9
9
|
end
|
10
10
|
|
11
|
+
def list_databases
|
12
|
+
[{'name' => 'test'}]
|
13
|
+
end
|
14
|
+
|
11
15
|
def write_points(points)
|
12
16
|
@points += points
|
13
17
|
end
|
@@ -35,9 +39,9 @@ class InfluxdbOutputTest < Test::Unit::TestCase
|
|
35
39
|
def create_driver(conf=CONFIG, tag='test')
|
36
40
|
Fluent::Test::BufferedOutputTestDriver.new(Fluent::InfluxdbOutput, tag) do
|
37
41
|
attr_reader :influxdb
|
38
|
-
def
|
39
|
-
super
|
42
|
+
def start
|
40
43
|
@influxdb = DummyInfluxDBClient.new()
|
44
|
+
super
|
41
45
|
end
|
42
46
|
end.configure(conf)
|
43
47
|
end
|
@@ -92,6 +96,44 @@ class InfluxdbOutputTest < Test::Unit::TestCase
|
|
92
96
|
|
93
97
|
end
|
94
98
|
|
99
|
+
def test_empty_tag_keys
|
100
|
+
config_with_tags = %Q(
|
101
|
+
#{CONFIG}
|
102
|
+
|
103
|
+
tag_keys ["b"]
|
104
|
+
)
|
105
|
+
|
106
|
+
driver = create_driver(config_with_tags, 'input.influxdb')
|
107
|
+
|
108
|
+
time = Time.parse("2011-01-02 13:14:15 UTC").to_i
|
109
|
+
driver.emit({'a' => 1, 'b' => ''}, time)
|
110
|
+
driver.emit({'a' => 2, 'b' => 1}, time)
|
111
|
+
driver.emit({'a' => 3, 'b' => ' '}, time)
|
112
|
+
|
113
|
+
data = driver.run
|
114
|
+
|
115
|
+
assert_equal([
|
116
|
+
{
|
117
|
+
:timestamp => time,
|
118
|
+
:series => 'input.influxdb',
|
119
|
+
:values => {'a' => 1},
|
120
|
+
:tags => {},
|
121
|
+
},
|
122
|
+
{
|
123
|
+
:timestamp => time,
|
124
|
+
:series => 'input.influxdb',
|
125
|
+
:values => {'a' => 2},
|
126
|
+
:tags => {'b' => 1},
|
127
|
+
},
|
128
|
+
{
|
129
|
+
:timestamp => time,
|
130
|
+
:series => 'input.influxdb',
|
131
|
+
:values => {'a' => 3},
|
132
|
+
:tags => {},
|
133
|
+
}
|
134
|
+
], driver.instance.influxdb.points)
|
135
|
+
end
|
136
|
+
|
95
137
|
def test_seq
|
96
138
|
config = %[
|
97
139
|
type influxdb
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-influxdb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masahiro Nakagawa
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-04-
|
12
|
+
date: 2016-04-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fluentd
|