fluent-plugin-influxdb 0.2.8 → 0.3.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/History.md +7 -0
- data/README.md +5 -1
- data/fluent-plugin-influxdb.gemspec +1 -1
- data/lib/fluent/plugin/out_influxdb.rb +36 -3
- data/test/plugin/test_out_influxdb.rb +44 -13
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0e1211e313f744ceecfb57ec8a21f22715569b2
|
4
|
+
data.tar.gz: be8470752389e6369cc5860695d127691fc55939
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0241c72b998cf7df9e9ad341ef9385d74d511ede88598056c5edfa90f17f90d0c68dab2b77fc3f35ec6696a1bee99fa83a7dfb8239a773eba9b39bf2d7689760
|
7
|
+
data.tar.gz: 96511394b68b23bd8daad5e2bc3489bd7757bb1118739012b5d84b6256f7f86af65e419774d82d57e17bf1f3afb91803ce8bdda26fba41952aa46877811d3417
|
data/History.md
CHANGED
data/README.md
CHANGED
@@ -41,11 +41,15 @@ Just like other regular output plugins, Use type `influxdb` in your fluentd conf
|
|
41
41
|
|
42
42
|
`password`: The password of the user, default to "root"
|
43
43
|
|
44
|
+
`retry`: The finite number of retry times. default is infinite
|
45
|
+
|
44
46
|
`use_ssl`: Use SSL when connecting to influxDB. default to false
|
45
47
|
|
46
48
|
`verify_ssl`: Enable/Disable SSL Certs verification when connecting to influxDB via SSL. default to true
|
47
49
|
|
48
|
-
`
|
50
|
+
`time_key`: Use value of this tag if it exists in event instead of event timestamp
|
51
|
+
|
52
|
+
`time_precision`: The time precision of timestamp. default to "s". should specify either hour (h), minutes (m), second (s), millisecond (ms), microsecond (u), or nanosecond (ns)
|
49
53
|
|
50
54
|
`tag_keys`: The names of the keys to use as influxDB tags.
|
51
55
|
|
@@ -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.
|
6
|
+
s.version = '0.3.0'
|
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}
|
@@ -30,7 +30,7 @@ DESC
|
|
30
30
|
:desc => <<-DESC
|
31
31
|
The time precision of timestamp.
|
32
32
|
You should specify either hour (h), minutes (m), second (s),
|
33
|
-
millisecond (ms), microsecond (u), or nanosecond (
|
33
|
+
millisecond (ms), microsecond (u), or nanosecond (ns).
|
34
34
|
DESC
|
35
35
|
config_param :use_ssl, :bool, :default => false,
|
36
36
|
:desc => "Use SSL when connecting to influxDB."
|
@@ -57,6 +57,7 @@ DESC
|
|
57
57
|
|
58
58
|
def configure(conf)
|
59
59
|
super
|
60
|
+
@time_precise = time_precise_lambda()
|
60
61
|
end
|
61
62
|
|
62
63
|
def start
|
@@ -80,7 +81,7 @@ DESC
|
|
80
81
|
unless existing_databases.include? @dbname
|
81
82
|
raise Fluent::ConfigError, 'Database ' + @dbname + ' doesn\'t exist. Create it first, please. Existing databases: ' + existing_databases.join(',')
|
82
83
|
end
|
83
|
-
rescue InfluxDB::AuthenticationError
|
84
|
+
rescue InfluxDB::AuthenticationError, InfluxDB::Error
|
84
85
|
$log.info "skip database presence check because '#{@user}' user doesn't have admin privilege. Check '#{@dbname}' exists on influxdb"
|
85
86
|
end
|
86
87
|
end
|
@@ -92,7 +93,7 @@ DESC
|
|
92
93
|
if record.empty? || record.has_value?(nil)
|
93
94
|
FORMATTED_RESULT_FOR_INVALID_RECORD
|
94
95
|
else
|
95
|
-
[tag, time, record].to_msgpack
|
96
|
+
[tag, precision_time(time), record].to_msgpack
|
96
97
|
end
|
97
98
|
end
|
98
99
|
|
@@ -131,6 +132,12 @@ DESC
|
|
131
132
|
tags[@sequence_tag] = @seq
|
132
133
|
@prev_timestamp = timestamp
|
133
134
|
end
|
135
|
+
|
136
|
+
if values.empty?
|
137
|
+
log.warn "Skip record '#{record}', because InfluxDB requires at least one value in raw"
|
138
|
+
next
|
139
|
+
end
|
140
|
+
|
134
141
|
point = {
|
135
142
|
:timestamp => timestamp,
|
136
143
|
:series => tag,
|
@@ -163,4 +170,30 @@ DESC
|
|
163
170
|
end
|
164
171
|
end
|
165
172
|
end
|
173
|
+
|
174
|
+
def time_precise_lambda()
|
175
|
+
case @time_precision.to_sym
|
176
|
+
when :h then
|
177
|
+
lambda{|nstime| nstime / (10 ** 9) / (60 ** 2) }
|
178
|
+
when :m then
|
179
|
+
lambda{|nstime| nstime / (10 ** 9) / 60 }
|
180
|
+
when :s then
|
181
|
+
lambda{|nstime| nstime / (10 ** 9) }
|
182
|
+
when :ms then
|
183
|
+
lambda{|nstime| nstime / (10 ** 6) }
|
184
|
+
when :u then
|
185
|
+
lambda{|nstime| nstime / (10 ** 3) }
|
186
|
+
when :ns then
|
187
|
+
lambda{|nstime| nstime }
|
188
|
+
else
|
189
|
+
raise Fluent::ConfigError, 'time_precision ' + @time_precision + ' is invalid.' +
|
190
|
+
'should specify either either hour (h), minutes (m), second (s), millisecond (ms), microsecond (u), or nanosecond (ns)'
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
def precision_time(time)
|
195
|
+
# nsec is supported from v0.14
|
196
|
+
nstime = time * (10 ** 9) + (defined?(Fluent::EventTime) ? time.nsec : 0)
|
197
|
+
@time_precise.call(nstime)
|
198
|
+
end
|
166
199
|
end
|
@@ -62,7 +62,7 @@ class InfluxdbOutputTest < Test::Unit::TestCase
|
|
62
62
|
|
63
63
|
def test_format
|
64
64
|
driver = create_driver(CONFIG, 'test')
|
65
|
-
time = Time.parse('2011-01-02 13:14:15 UTC')
|
65
|
+
time = Fluent::EventTime.from_time(Time.parse('2011-01-02 13:14:15 UTC'))
|
66
66
|
|
67
67
|
driver.emit({'a' => 1}, time)
|
68
68
|
driver.emit({'a' => 2}, time)
|
@@ -76,7 +76,7 @@ class InfluxdbOutputTest < Test::Unit::TestCase
|
|
76
76
|
def test_write
|
77
77
|
driver = create_driver(CONFIG, 'input.influxdb')
|
78
78
|
|
79
|
-
time = Time.parse(
|
79
|
+
time = Fluent::EventTime.from_time(Time.parse('2011-01-02 13:14:15 UTC'))
|
80
80
|
driver.emit({'a' => 1}, time)
|
81
81
|
driver.emit({'a' => 2}, time)
|
82
82
|
|
@@ -102,7 +102,6 @@ class InfluxdbOutputTest < Test::Unit::TestCase
|
|
102
102
|
nil
|
103
103
|
]
|
104
104
|
], driver.instance.influxdb.points)
|
105
|
-
|
106
105
|
end
|
107
106
|
|
108
107
|
def test_empty_tag_keys
|
@@ -114,7 +113,7 @@ class InfluxdbOutputTest < Test::Unit::TestCase
|
|
114
113
|
|
115
114
|
driver = create_driver(config_with_tags, 'input.influxdb')
|
116
115
|
|
117
|
-
time = Time.parse(
|
116
|
+
time = Fluent::EventTime.from_time(Time.parse('2011-01-02 13:14:15 UTC'))
|
118
117
|
driver.emit({'a' => 1, 'b' => ''}, time)
|
119
118
|
driver.emit({'a' => 2, 'b' => 1}, time)
|
120
119
|
driver.emit({'a' => 3, 'b' => ' '}, time)
|
@@ -149,6 +148,37 @@ class InfluxdbOutputTest < Test::Unit::TestCase
|
|
149
148
|
], driver.instance.influxdb.points)
|
150
149
|
end
|
151
150
|
|
151
|
+
def test_ignore_empty_values
|
152
|
+
config_with_tags = %Q(
|
153
|
+
#{CONFIG}
|
154
|
+
|
155
|
+
tag_keys ["b"]
|
156
|
+
)
|
157
|
+
|
158
|
+
driver = create_driver(config_with_tags, 'input.influxdb')
|
159
|
+
|
160
|
+
time = Fluent::EventTime.from_time(Time.parse('2011-01-02 13:14:15 UTC'))
|
161
|
+
driver.emit({'b' => '3'}, time)
|
162
|
+
driver.emit({'a' => 2, 'b' => 1}, time)
|
163
|
+
|
164
|
+
data = driver.run
|
165
|
+
|
166
|
+
assert_equal([
|
167
|
+
[
|
168
|
+
[
|
169
|
+
{
|
170
|
+
:timestamp => time,
|
171
|
+
:series => 'input.influxdb',
|
172
|
+
:values => {'a' => 2},
|
173
|
+
:tags => {'b' => 1},
|
174
|
+
}
|
175
|
+
],
|
176
|
+
nil,
|
177
|
+
nil
|
178
|
+
]
|
179
|
+
], driver.instance.influxdb.points)
|
180
|
+
end
|
181
|
+
|
152
182
|
def test_seq
|
153
183
|
config = %[
|
154
184
|
type influxdb
|
@@ -158,17 +188,18 @@ class InfluxdbOutputTest < Test::Unit::TestCase
|
|
158
188
|
user testuser
|
159
189
|
password mypwd
|
160
190
|
use_ssl false
|
161
|
-
time_precision s
|
191
|
+
time_precision s
|
162
192
|
sequence_tag _seq
|
163
193
|
]
|
164
194
|
driver = create_driver(config, 'input.influxdb')
|
165
195
|
|
166
|
-
time = Time.parse(
|
196
|
+
time = Fluent::EventTime.from_time(Time.parse('2011-01-02 13:14:15 UTC'))
|
167
197
|
driver.emit({'a' => 1}, time)
|
168
198
|
driver.emit({'a' => 2}, time)
|
169
199
|
|
170
|
-
|
171
|
-
driver.emit({'a' =>
|
200
|
+
time2 = Fluent::EventTime.from_time(Time.parse('2011-01-02 13:14:16 UTC'))
|
201
|
+
driver.emit({'a' => 1}, time2)
|
202
|
+
driver.emit({'a' => 2}, time2)
|
172
203
|
|
173
204
|
data = driver.run
|
174
205
|
|
@@ -188,13 +219,13 @@ class InfluxdbOutputTest < Test::Unit::TestCase
|
|
188
219
|
:tags => {'_seq' => 1},
|
189
220
|
},
|
190
221
|
{
|
191
|
-
:timestamp =>
|
222
|
+
:timestamp => time2,
|
192
223
|
:series => 'input.influxdb',
|
193
224
|
:values => {'a' => 1},
|
194
225
|
:tags => {'_seq' => 0},
|
195
226
|
},
|
196
227
|
{
|
197
|
-
:timestamp =>
|
228
|
+
:timestamp => time2,
|
198
229
|
:series => 'input.influxdb',
|
199
230
|
:values => {'a' => 2},
|
200
231
|
:tags => {'_seq' => 1},
|
@@ -213,7 +244,7 @@ class InfluxdbOutputTest < Test::Unit::TestCase
|
|
213
244
|
]
|
214
245
|
driver = create_driver(config, 'input.influxdb')
|
215
246
|
|
216
|
-
time = Time.parse(
|
247
|
+
time = Fluent::EventTime.from_time(Time.parse('2011-01-02 13:14:15 UTC'))
|
217
248
|
driver.emit({'a' => 1}, time)
|
218
249
|
driver.emit({'a' => 2}, time)
|
219
250
|
|
@@ -248,7 +279,7 @@ class InfluxdbOutputTest < Test::Unit::TestCase
|
|
248
279
|
]
|
249
280
|
driver = create_driver(config, 'input.influxdb')
|
250
281
|
|
251
|
-
time = Time.parse(
|
282
|
+
time = Fluent::EventTime.from_time(Time.parse('2011-01-02 13:14:15 UTC'))
|
252
283
|
driver.emit({'a' => 1}, time)
|
253
284
|
driver.emit({'a' => 2, 'rp' => 'ephemeral_1d'}, time)
|
254
285
|
driver.emit({'a' => 3, 'rp' => 'ephemeral_1m'}, time)
|
@@ -303,7 +334,7 @@ class InfluxdbOutputTest < Test::Unit::TestCase
|
|
303
334
|
]
|
304
335
|
driver = create_driver(config, 'input.influxdb')
|
305
336
|
|
306
|
-
time = Time.parse(
|
337
|
+
time = Fluent::EventTime.from_time(Time.parse('2011-01-02 13:14:15 UTC'))
|
307
338
|
driver.emit({'a' => 1}, time)
|
308
339
|
driver.emit({'a' => 2, 'rp' => 'ephemeral_1d'}, time)
|
309
340
|
driver.emit({'a' => 3, 'rp' => 'ephemeral_1m'}, time)
|
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.
|
4
|
+
version: 0.3.0
|
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-
|
12
|
+
date: 2016-12-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fluentd
|
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
125
|
version: '0'
|
126
126
|
requirements: []
|
127
127
|
rubyforge_project:
|
128
|
-
rubygems_version: 2.
|
128
|
+
rubygems_version: 2.6.8
|
129
129
|
signing_key:
|
130
130
|
specification_version: 4
|
131
131
|
summary: A buffered output plugin for fluentd and influxDB
|