logstash-output-influxdb 3.0.0 → 3.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dc53920ba345ebe5e4e289819a5dfac55406720d
4
- data.tar.gz: deb992fd046dbe441ba216971b96037169f45ef8
3
+ metadata.gz: 98758c0e7ae9f464d3f3bedbd7e806852068de37
4
+ data.tar.gz: 3cd70751da808e61018de4bd7bf939bbd610f01c
5
5
  SHA512:
6
- metadata.gz: 96f4b4d2aff815c0df8cfba3f73030ff7fcf2402c16ec4123b5f844964b2cfa4049c0f34bc42d4ca60c81bd3b1278ac1e9c12cbf6b19ff6f4f256f97f2812606
7
- data.tar.gz: ca510bc40ac465550485e9fbb128e9adfdaf86b2e78abba05844ef5745634f753bd7398bfbc2287c2fe3cb0b319cc02d882c9cb97eb8c8b4d0b8e7769473e972
6
+ metadata.gz: 8c4b6d62bdd19c0599d48d60b9bc449cf735e28928e334ac33173d849c1cfeb1c119b377cd4d0e36b8b25324747053a6928d3e044d76c65c7995f949dc997cad
7
+ data.tar.gz: 9b8dda87b34515887acb82ae0c9ffe59d6428d8b55036a35fb49ee6f618a8f01c65618fffbcd60b3794d99a2025977e63e74d5f561bc446cec4b121697a5cf3a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # 3.1.2
2
+ - Depend on logstash-core-plugin-api instead of logstash-core, removing the need to mass update plugins on major releases of logstash
3
+ # 3.1.1
4
+ - New dependency requirements for logstash-core for the 5.0 release
5
+ ## 3.1.0
6
+ - New option to enable SSL/TLS encrypted communication to InfluxDB
7
+ - DB parameter now supports sprintf formatting
8
+
9
+ ## 3.0.0
10
+ - Update to work with influxdb 0.9
11
+ - breaking change, renaming 'series' to 'measurement'
12
+ - breaking change for values of time_precision
13
+ - Special characters now properly escaped in tag key/value, field key, measurement
14
+
1
15
  ## 2.0.0
2
16
  - Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
3
17
  instead of using Thread.raise on the plugins' threads. Ref: https://github.com/elastic/logstash/pull/3895
data/CONTRIBUTORS CHANGED
@@ -6,6 +6,7 @@ Contributors:
6
6
  * Kurt Hurtado (kurtado)
7
7
  * Pier-Hugues Pellerin (ph)
8
8
  * Richard Pijnenburg (electrical)
9
+ * Michael Laws (mikelaws)
9
10
 
10
11
  Note: If you've sent us patches, bug reports, or otherwise contributed to
11
12
  Logstash, and you aren't on the list above and want to be, please let us know
data/README.md CHANGED
@@ -1,3 +1,7 @@
1
+ # Note
2
+ **This plugin needs maintainers -- please comment on this issue https://github.com/logstash-plugins/logstash-output-influxdb/issues/34 if you would like to help!**
3
+
4
+
1
5
  # Logstash Plugin
2
6
 
3
7
  [![Build
@@ -86,4 +90,4 @@ Programming is not a required skill. Whatever you've seen about open source and
86
90
 
87
91
  It is more important to the community that you are able to contribute.
88
92
 
89
- For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
93
+ For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
@@ -19,7 +19,7 @@ class LogStash::Outputs::InfluxDB < LogStash::Outputs::Base
19
19
 
20
20
  config_name "influxdb"
21
21
 
22
- # The database to write
22
+ # The database to write - supports sprintf formatting
23
23
  config :db, :validate => :string, :default => "statistics"
24
24
 
25
25
  # The retention policy to use
@@ -37,6 +37,9 @@ class LogStash::Outputs::InfluxDB < LogStash::Outputs::Base
37
37
  # The password for the user who access to the named database
38
38
  config :password, :validate => :password, :default => nil
39
39
 
40
+ # Enable SSL/TLS secured communication to InfluxDB
41
+ config :ssl, :validate => :boolean, :default => false
42
+
40
43
  # Measurement name - supports sprintf formatting
41
44
  config :measurement, :validate => :string, :default => "logstash"
42
45
 
@@ -113,10 +116,7 @@ class LogStash::Outputs::InfluxDB < LogStash::Outputs::Base
113
116
 
114
117
  @client = Manticore::Client.new
115
118
  @queue = []
116
-
117
- @query_params = "db=#{@db}&rp=#{@retention_policy}&precision=#{@time_precision}&u=#{@user}&p=#{@password.value}"
118
- @base_url = "http://#{@host}:#{@port}/write"
119
- @url = "#{@base_url}?#{@query_params}"
119
+ @protocol = @ssl ? "https" : "http"
120
120
 
121
121
  buffer_initialize(
122
122
  :max_items => @flush_size,
@@ -162,18 +162,23 @@ class LogStash::Outputs::InfluxDB < LogStash::Outputs::Base
162
162
  }
163
163
  event_hash["tags"] = tags unless tags.empty?
164
164
 
165
- buffer_receive(event_hash)
165
+ buffer_receive(event_hash, event.sprintf(@db))
166
166
  end # def receive
167
167
 
168
168
 
169
- def flush(events, teardown = false)
170
- @logger.debug? and @logger.debug("Flushing #{events.size} events to #{@url} - Teardown? #{teardown}")
171
- post(events_to_request_body(events))
169
+ def flush(events, database, teardown = false)
170
+ @logger.debug? and @logger.debug("Flushing #{events.size} events to #{database} - Teardown? #{teardown}")
171
+ post(events_to_request_body(events), database)
172
172
  end # def flush
173
173
 
174
174
 
175
- def post(body)
175
+ def post(body, database, proto = @protocol)
176
176
  begin
177
+ @query_params = "db=#{database}&rp=#{@retention_policy}&precision=#{@time_precision}&u=#{@user}&p=#{@password.value}"
178
+ @base_url = "#{proto}://#{@host}:#{@port}/write"
179
+ @url = "#{@base_url}?#{@query_params}"
180
+
181
+ @logger.debug? and @logger.debug("POSTing to #{@url}")
177
182
  @logger.debug? and @logger.debug("Post body: #{body}")
178
183
  response = @client.post!(@url, :body => body)
179
184
 
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-output-influxdb'
4
- s.version = '3.0.0'
4
+ s.version = '3.1.2'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "This output lets you output Metrics to InfluxDB"
7
7
  s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.metadata = { "logstash_plugin" => "true", "logstash_group" => "output" }
21
21
 
22
22
  # Gem dependencies
23
- s.add_runtime_dependency "logstash-core", ">= 2.0.0.beta2", "< 3.0.0"
23
+ s.add_runtime_dependency "logstash-core-plugin-api", "~> 1.0"
24
24
 
25
25
  s.add_runtime_dependency 'stud'
26
26
  s.add_runtime_dependency 'manticore'
@@ -26,7 +26,8 @@ describe LogStash::Outputs::InfluxDB do
26
26
 
27
27
  before do
28
28
  subject.register
29
- allow(subject).to receive(:post).with(result)
29
+ # Added db name parameter to post - M.Laws
30
+ allow(subject).to receive(:post).with(result, "statistics")
30
31
 
31
32
  2.times do
32
33
  subject.receive(LogStash::Event.new("foo" => "1", "bar" => "2", "time" => "3", "type" => "generator"))
@@ -39,7 +40,7 @@ describe LogStash::Outputs::InfluxDB do
39
40
  let(:result) { "logstash foo=\"1\",bar=\"2\" 3\nlogstash foo=\"1\",bar=\"2\" 3" }
40
41
 
41
42
  it "should receive 2 events, flush and call post with 2 items json array" do
42
- expect(subject).to have_received(:post).with(result)
43
+ expect(subject).to have_received(:post).with(result, "statistics")
43
44
  end
44
45
 
45
46
  end
@@ -354,4 +355,154 @@ describe LogStash::Outputs::InfluxDB do
354
355
  pipeline.run
355
356
  end
356
357
  end
358
+
359
+ # Test issue #32 - Add support for HTTPS via configuration
360
+ # --------------------------------------------------------
361
+ # A simple test to verify that setting the ssl configuration option works
362
+ # similar to other Logstash output plugins (specifically the Elasticsearch
363
+ # output plugin).
364
+ context "setting the ssl configuration option to true" do
365
+ let(:config) do <<-CONFIG
366
+ input {
367
+ generator {
368
+ message => "foo=1 bar=2 baz=3 time=4"
369
+ count => 1
370
+ type => "generator"
371
+ }
372
+ }
373
+
374
+ filter {
375
+ kv { }
376
+ }
377
+
378
+ output {
379
+ influxdb {
380
+ host => "localhost"
381
+ ssl => true
382
+ measurement => "barfoo"
383
+ allow_time_override => true
384
+ use_event_fields_for_data_points => true
385
+ exclude_fields => [ "@version", "@timestamp", "sequence",
386
+ "message", "type", "host" ]
387
+ }
388
+ }
389
+ CONFIG
390
+ end
391
+
392
+ let(:expected_url) { 'https://localhost:8086/write?db=statistics&rp=default&precision=ms&u=&p=' }
393
+ let(:expected_body) { 'barfoo foo="1",bar="2",baz="3" 4' }
394
+
395
+ it "should POST to an https URL" do
396
+ expect_any_instance_of(Manticore::Client).to receive(:post!).with(expected_url, body: expected_body)
397
+ pipeline.run
398
+ end
399
+ end
400
+
401
+ # Test issue #31 - Run "db" parameter through event.sprintf() to support...
402
+ # -------------------------------------------------------------------------
403
+ # This test is intended to verify writes to multiple measurements in A SINGLE
404
+ # DATABASE continue to work *after* implementing #31. Also verifies that
405
+ # sprintf formatting is supported in the measurement name.
406
+ context "receiving 3 points between 2 measurements in 1 database" do
407
+ let(:config) do <<-CONFIG
408
+ input {
409
+ generator {
410
+ lines => [
411
+ "foo=1 bar=2 baz=m1 time=1",
412
+ "foo=3 bar=4 baz=m2 time=2",
413
+ "foo=5 bar=6 baz=m2 time=3"
414
+ ]
415
+ count => 1
416
+ type => "generator"
417
+ }
418
+ }
419
+
420
+ filter {
421
+ kv { }
422
+ }
423
+
424
+ output {
425
+ influxdb {
426
+ host => "localhost"
427
+ db => "barfoo"
428
+ measurement => "%{baz}"
429
+ allow_time_override => true
430
+ use_event_fields_for_data_points => true
431
+ exclude_fields => [ "@version", "@timestamp", "sequence",
432
+ "message", "type", "host" ]
433
+ }
434
+ }
435
+ CONFIG
436
+ end
437
+
438
+ let(:expected_url) { 'http://localhost:8086/write?db=barfoo&rp=default&precision=ms&u=&p=' }
439
+ let(:expected_body) { "m1 foo=\"1\",bar=\"2\",baz=\"m1\" 1\nm2 foo=\"3\",bar=\"4\",baz=\"m2\" 2\nm2 foo=\"5\",bar=\"6\",baz=\"m2\" 3" }
440
+
441
+ it "should result in a single POST (one per database)" do
442
+ expect_any_instance_of(Manticore::Client).to receive(:post!).once
443
+ pipeline.run
444
+ end
445
+
446
+ it "should POST in bulk format" do
447
+ expect_any_instance_of(Manticore::Client).to receive(:post!).with(expected_url, body: expected_body)
448
+ pipeline.run
449
+ end
450
+ end
451
+
452
+ # Test issue #31 - Run "db" parameter through event.sprintf() to support...
453
+ # -------------------------------------------------------------------------
454
+ # This test is intended to verify writes to multiple measurements in MULTIPLE
455
+ # DATABASES result in separate bulk POSTs (one for each database in the
456
+ # buffer), and the correct measurements being written to the correct db.
457
+ # Also verifies that sprintf formatting is correctly supported in the
458
+ # database name.
459
+ context "receiving 4 points between 2 measurements in 2 databases" do
460
+ let(:config) do <<-CONFIG
461
+ input {
462
+ generator {
463
+ lines => [
464
+ "foo=1 bar=db1 baz=m1 time=1",
465
+ "foo=2 bar=db1 baz=m2 time=2",
466
+ "foo=3 bar=db2 baz=m1 time=3",
467
+ "foo=4 bar=db2 baz=m2 time=4"
468
+ ]
469
+ count => 1
470
+ type => "generator"
471
+ }
472
+ }
473
+
474
+ filter {
475
+ kv { }
476
+ }
477
+
478
+ output {
479
+ influxdb {
480
+ host => "localhost"
481
+ db => "%{bar}"
482
+ measurement => "%{baz}"
483
+ allow_time_override => true
484
+ use_event_fields_for_data_points => true
485
+ exclude_fields => [ "@version", "@timestamp", "sequence",
486
+ "message", "type", "host" ]
487
+ }
488
+ }
489
+ CONFIG
490
+ end
491
+
492
+ let(:expected_url_db1) { 'http://localhost:8086/write?db=db1&rp=default&precision=ms&u=&p=' }
493
+ let(:expected_url_db2) { 'http://localhost:8086/write?db=db2&rp=default&precision=ms&u=&p=' }
494
+ let(:expected_body_db1) { "m1 foo=\"1\",bar=\"db1\",baz=\"m1\" 1\nm2 foo=\"2\",bar=\"db1\",baz=\"m2\" 2" }
495
+ let(:expected_body_db2) { "m1 foo=\"3\",bar=\"db2\",baz=\"m1\" 3\nm2 foo=\"4\",bar=\"db2\",baz=\"m2\" 4" }
496
+
497
+ it "should result in two POSTs (one per database)" do
498
+ expect_any_instance_of(Manticore::Client).to receive(:post!).twice
499
+ pipeline.run
500
+ end
501
+
502
+ it "should post in bulk format" do
503
+ expect_any_instance_of(Manticore::Client).to receive(:post!).with(expected_url_db1, body: expected_body_db1)
504
+ expect_any_instance_of(Manticore::Client).to receive(:post!).with(expected_url_db2, body: expected_body_db2)
505
+ pipeline.run
506
+ end
507
+ end
357
508
  end
metadata CHANGED
@@ -1,39 +1,33 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-influxdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-28 00:00:00.000000000 Z
11
+ date: 2016-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
- - - '>='
16
+ - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: 2.0.0.beta2
19
- - - <
20
- - !ruby/object:Gem::Version
21
- version: 3.0.0
22
- name: logstash-core
18
+ version: '1.0'
19
+ name: logstash-core-plugin-api
23
20
  prerelease: false
24
21
  type: :runtime
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - '>='
28
- - !ruby/object:Gem::Version
29
- version: 2.0.0.beta2
30
- - - <
24
+ - - "~>"
31
25
  - !ruby/object:Gem::Version
32
- version: 3.0.0
26
+ version: '1.0'
33
27
  - !ruby/object:Gem::Dependency
34
28
  requirement: !ruby/object:Gem::Requirement
35
29
  requirements:
36
- - - '>='
30
+ - - ">="
37
31
  - !ruby/object:Gem::Version
38
32
  version: '0'
39
33
  name: stud
@@ -41,13 +35,13 @@ dependencies:
41
35
  type: :runtime
42
36
  version_requirements: !ruby/object:Gem::Requirement
43
37
  requirements:
44
- - - '>='
38
+ - - ">="
45
39
  - !ruby/object:Gem::Version
46
40
  version: '0'
47
41
  - !ruby/object:Gem::Dependency
48
42
  requirement: !ruby/object:Gem::Requirement
49
43
  requirements:
50
- - - '>='
44
+ - - ">="
51
45
  - !ruby/object:Gem::Version
52
46
  version: '0'
53
47
  name: manticore
@@ -55,13 +49,13 @@ dependencies:
55
49
  type: :runtime
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
51
  requirements:
58
- - - '>='
52
+ - - ">="
59
53
  - !ruby/object:Gem::Version
60
54
  version: '0'
61
55
  - !ruby/object:Gem::Dependency
62
56
  requirement: !ruby/object:Gem::Requirement
63
57
  requirements:
64
- - - '>='
58
+ - - ">="
65
59
  - !ruby/object:Gem::Version
66
60
  version: '0'
67
61
  name: logstash-devutils
@@ -69,13 +63,13 @@ dependencies:
69
63
  type: :development
70
64
  version_requirements: !ruby/object:Gem::Requirement
71
65
  requirements:
72
- - - '>='
66
+ - - ">="
73
67
  - !ruby/object:Gem::Version
74
68
  version: '0'
75
69
  - !ruby/object:Gem::Dependency
76
70
  requirement: !ruby/object:Gem::Requirement
77
71
  requirements:
78
- - - '>='
72
+ - - ">="
79
73
  - !ruby/object:Gem::Version
80
74
  version: '0'
81
75
  name: logstash-input-generator
@@ -83,13 +77,13 @@ dependencies:
83
77
  type: :development
84
78
  version_requirements: !ruby/object:Gem::Requirement
85
79
  requirements:
86
- - - '>='
80
+ - - ">="
87
81
  - !ruby/object:Gem::Version
88
82
  version: '0'
89
83
  - !ruby/object:Gem::Dependency
90
84
  requirement: !ruby/object:Gem::Requirement
91
85
  requirements:
92
- - - '>='
86
+ - - ">="
93
87
  - !ruby/object:Gem::Version
94
88
  version: '0'
95
89
  name: logstash-filter-kv
@@ -97,7 +91,7 @@ dependencies:
97
91
  type: :development
98
92
  version_requirements: !ruby/object:Gem::Requirement
99
93
  requirements:
100
- - - '>='
94
+ - - ">="
101
95
  - !ruby/object:Gem::Version
102
96
  version: '0'
103
97
  description: This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program
@@ -127,17 +121,17 @@ require_paths:
127
121
  - lib
128
122
  required_ruby_version: !ruby/object:Gem::Requirement
129
123
  requirements:
130
- - - '>='
124
+ - - ">="
131
125
  - !ruby/object:Gem::Version
132
126
  version: '0'
133
127
  required_rubygems_version: !ruby/object:Gem::Requirement
134
128
  requirements:
135
- - - '>='
129
+ - - ">="
136
130
  - !ruby/object:Gem::Version
137
131
  version: '0'
138
132
  requirements: []
139
133
  rubyforge_project:
140
- rubygems_version: 2.4.5
134
+ rubygems_version: 2.4.8
141
135
  signing_key:
142
136
  specification_version: 4
143
137
  summary: This output lets you output Metrics to InfluxDB