fluent-plugin-influxdb 0.3.0 → 0.3.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f0e1211e313f744ceecfb57ec8a21f22715569b2
4
- data.tar.gz: be8470752389e6369cc5860695d127691fc55939
3
+ metadata.gz: 659fc90e62fb688b58a1846586ac472afeea1930
4
+ data.tar.gz: 90a268553b8597b8fa4a2501e06820870bdf4e4c
5
5
  SHA512:
6
- metadata.gz: 0241c72b998cf7df9e9ad341ef9385d74d511ede88598056c5edfa90f17f90d0c68dab2b77fc3f35ec6696a1bee99fa83a7dfb8239a773eba9b39bf2d7689760
7
- data.tar.gz: 96511394b68b23bd8daad5e2bc3489bd7757bb1118739012b5d84b6256f7f86af65e419774d82d57e17bf1f3afb91803ce8bdda26fba41952aa46877811d3417
6
+ metadata.gz: df2e35733cc5a28310a4e77458cee98328b9ab10cebd7efcf34b61883a49f6b6336daa68b2729008a3c6588b3f34356754cfe1f3b6bb563fc9d3f57200917293
7
+ data.tar.gz: 3977a6a8914bd8078d3c29d97daad7f7329d587600349008fd02ac81515df33611ad5d2bb9493cb4917a9062d612d7caf027a3736eb381310373169db4a04e1d
data/History.md CHANGED
@@ -1,6 +1,11 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ 0.3.1 (Jan, 07, 2017)
5
+ =====
6
+
7
+ - Add auto_tags parameter
8
+
4
9
  0.3.0 (Dec, 15, 2016)
5
10
  =====
6
11
 
data/README.md CHANGED
@@ -51,6 +51,8 @@ Just like other regular output plugins, Use type `influxdb` in your fluentd conf
51
51
 
52
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)
53
53
 
54
+ `auto_tags`: Enable/Disable auto-tagging behaviour which makes strings tags.
55
+
54
56
  `tag_keys`: The names of the keys to use as influxDB tags.
55
57
 
56
58
  `sequence_tag`: The name of the tag whose value is incremented for the consecutive simultaneous events and reset to zero for a new event with the different timestamp
@@ -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.3.0'
6
+ s.version = '0.3.1'
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}
@@ -36,6 +36,8 @@ DESC
36
36
  :desc => "Use SSL when connecting to influxDB."
37
37
  config_param :verify_ssl, :bool, :default => true,
38
38
  :desc => "Enable/Disable SSL Certs verification when connecting to influxDB via SSL."
39
+ config_param :auto_tags, :bool, :default => false,
40
+ :desc => "Enable/Disable auto-tagging behaviour which makes strings tags."
39
41
  config_param :tag_keys, :array, :default => [],
40
42
  :desc => "The names of the keys to use as influxDB tags."
41
43
  config_param :sequence_tag, :string, :default => nil,
@@ -106,14 +108,14 @@ DESC
106
108
  points = []
107
109
  chunk.msgpack_each do |tag, time, record|
108
110
  timestamp = record.delete(@time_key) || time
109
- if tag_keys.empty?
111
+ if tag_keys.empty? && !@auto_tags
110
112
  values = record
111
113
  tags = {}
112
114
  else
113
115
  values = {}
114
116
  tags = {}
115
117
  record.each_pair do |k, v|
116
- if @tag_keys.include?(k)
118
+ if (@auto_tags && v.is_a?(String)) || @tag_keys.include?(k)
117
119
  # If the tag value is not nil, empty, or a space, add the tag
118
120
  if v.to_s.strip != ''
119
121
  tags[k] = v
data/test/helper.rb CHANGED
@@ -24,7 +24,10 @@ unless ENV.has_key?('VERBOSE')
24
24
  $log = nulllogger
25
25
  end
26
26
 
27
+ require 'fluent/test/helpers'
27
28
  require 'fluent/plugin/out_influxdb'
28
29
 
30
+ include Fluent::Test::Helpers
31
+
29
32
  class Test::Unit::TestCase
30
33
  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 = Fluent::EventTime.from_time(Time.parse('2011-01-02 13:14:15 UTC'))
65
+ time = event_time('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 = Fluent::EventTime.from_time(Time.parse('2011-01-02 13:14:15 UTC'))
79
+ time = event_time('2011-01-02 13:14:15 UTC')
80
80
  driver.emit({'a' => 1}, time)
81
81
  driver.emit({'a' => 2}, time)
82
82
 
@@ -113,7 +113,7 @@ class InfluxdbOutputTest < Test::Unit::TestCase
113
113
 
114
114
  driver = create_driver(config_with_tags, 'input.influxdb')
115
115
 
116
- time = Fluent::EventTime.from_time(Time.parse('2011-01-02 13:14:15 UTC'))
116
+ time = event_time('2011-01-02 13:14:15 UTC')
117
117
  driver.emit({'a' => 1, 'b' => ''}, time)
118
118
  driver.emit({'a' => 2, 'b' => 1}, time)
119
119
  driver.emit({'a' => 3, 'b' => ' '}, time)
@@ -147,6 +147,53 @@ class InfluxdbOutputTest < Test::Unit::TestCase
147
147
  ]
148
148
  ], driver.instance.influxdb.points)
149
149
  end
150
+
151
+ def test_auto_tagging
152
+ config_with_tags = %Q(
153
+ #{CONFIG}
154
+
155
+ auto_tags true
156
+ )
157
+
158
+ driver = create_driver(config_with_tags, 'input.influxdb')
159
+
160
+ time = event_time("2011-01-02 13:14:15 UTC")
161
+ driver.emit({'a' => 1, 'b' => '1'}, time)
162
+ driver.emit({'a' => 2, 'b' => 1}, time)
163
+ driver.emit({'a' => 3, 'b' => ' '}, time)
164
+
165
+
166
+ data = driver.run
167
+
168
+ assert_equal([
169
+ [
170
+ [
171
+ {
172
+ :timestamp => time,
173
+ :series => 'input.influxdb',
174
+
175
+ :values => {'a' => 1},
176
+ :tags => {'b' => '1'},
177
+ },
178
+ {
179
+ :timestamp => time,
180
+ :series => 'input.influxdb',
181
+ :values => {'a' => 2, 'b' => 1},
182
+ :tags => {},
183
+ },
184
+ {
185
+ :timestamp => time,
186
+ :series => 'input.influxdb',
187
+ :values => {'a' => 3},
188
+ :tags => {},
189
+ },
190
+
191
+ ],
192
+ nil,
193
+ nil
194
+ ]
195
+ ], driver.instance.influxdb.points)
196
+ end
150
197
 
151
198
  def test_ignore_empty_values
152
199
  config_with_tags = %Q(
@@ -157,7 +204,7 @@ class InfluxdbOutputTest < Test::Unit::TestCase
157
204
 
158
205
  driver = create_driver(config_with_tags, 'input.influxdb')
159
206
 
160
- time = Fluent::EventTime.from_time(Time.parse('2011-01-02 13:14:15 UTC'))
207
+ time = event_time('2011-01-02 13:14:15 UTC')
161
208
  driver.emit({'b' => '3'}, time)
162
209
  driver.emit({'a' => 2, 'b' => 1}, time)
163
210
 
@@ -169,6 +216,7 @@ class InfluxdbOutputTest < Test::Unit::TestCase
169
216
  {
170
217
  :timestamp => time,
171
218
  :series => 'input.influxdb',
219
+
172
220
  :values => {'a' => 2},
173
221
  :tags => {'b' => 1},
174
222
  }
@@ -177,7 +225,7 @@ class InfluxdbOutputTest < Test::Unit::TestCase
177
225
  nil
178
226
  ]
179
227
  ], driver.instance.influxdb.points)
180
- end
228
+ end
181
229
 
182
230
  def test_seq
183
231
  config = %[
@@ -193,11 +241,11 @@ class InfluxdbOutputTest < Test::Unit::TestCase
193
241
  ]
194
242
  driver = create_driver(config, 'input.influxdb')
195
243
 
196
- time = Fluent::EventTime.from_time(Time.parse('2011-01-02 13:14:15 UTC'))
244
+ time = event_time('2011-01-02 13:14:15 UTC')
197
245
  driver.emit({'a' => 1}, time)
198
246
  driver.emit({'a' => 2}, time)
199
247
 
200
- time2 = Fluent::EventTime.from_time(Time.parse('2011-01-02 13:14:16 UTC'))
248
+ time2 = event_time('2011-01-02 13:14:16 UTC')
201
249
  driver.emit({'a' => 1}, time2)
202
250
  driver.emit({'a' => 2}, time2)
203
251
 
@@ -244,7 +292,7 @@ class InfluxdbOutputTest < Test::Unit::TestCase
244
292
  ]
245
293
  driver = create_driver(config, 'input.influxdb')
246
294
 
247
- time = Fluent::EventTime.from_time(Time.parse('2011-01-02 13:14:15 UTC'))
295
+ time = event_time('2011-01-02 13:14:15 UTC')
248
296
  driver.emit({'a' => 1}, time)
249
297
  driver.emit({'a' => 2}, time)
250
298
 
@@ -279,7 +327,7 @@ class InfluxdbOutputTest < Test::Unit::TestCase
279
327
  ]
280
328
  driver = create_driver(config, 'input.influxdb')
281
329
 
282
- time = Fluent::EventTime.from_time(Time.parse('2011-01-02 13:14:15 UTC'))
330
+ time = event_time('2011-01-02 13:14:15 UTC')
283
331
  driver.emit({'a' => 1}, time)
284
332
  driver.emit({'a' => 2, 'rp' => 'ephemeral_1d'}, time)
285
333
  driver.emit({'a' => 3, 'rp' => 'ephemeral_1m'}, time)
@@ -334,7 +382,7 @@ class InfluxdbOutputTest < Test::Unit::TestCase
334
382
  ]
335
383
  driver = create_driver(config, 'input.influxdb')
336
384
 
337
- time = Fluent::EventTime.from_time(Time.parse('2011-01-02 13:14:15 UTC'))
385
+ time = event_time('2011-01-02 13:14:15 UTC')
338
386
  driver.emit({'a' => 1}, time)
339
387
  driver.emit({'a' => 2, 'rp' => 'ephemeral_1d'}, time)
340
388
  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.3.0
4
+ version: 0.3.1
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-16 00:00:00.000000000 Z
12
+ date: 2017-01-07 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.6.8
128
+ rubygems_version: 2.5.1
129
129
  signing_key:
130
130
  specification_version: 4
131
131
  summary: A buffered output plugin for fluentd and influxDB