fluent-plugin-out-http-ext 0.1.9 → 0.1.10

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: 26e4d5bcc932112e5fcc01009af8729d208e57a5
4
- data.tar.gz: 28198ae958747c4c9ee0ed790b540c6e6637fc52
3
+ metadata.gz: 1e2e7bd52f08a19386fc47ba7736c841dd2db645
4
+ data.tar.gz: 05a14a9b2f9c0c91fc52992d9e2d74941a996705
5
5
  SHA512:
6
- metadata.gz: e2bc98bcc613703a493a9fd5c48c5cf7167b2e659054d0a342e42264160a29d226e026dff05f32eeadd3c278a92ab9e2dd12ca9ab4cf30d9fc6f93043ba99fac
7
- data.tar.gz: 1117fa75f436984f76aef29f4e8a8b59c7045cc4512e6d61fd9412e89bf7e655c59baf4a8143845f3424771218dfa20eb699453825e362f7d12065e5b8ac5e2a
6
+ metadata.gz: 91470c3d1004f715bf2ced2ef26f615e05a22a35cb2498c14c8a5eb6e657b35da50c2320f2e5852dc01ce064e096fa6eb0ec83eb9d74c2e1ab9740d5f04ff65a
7
+ data.tar.gz: 474352e90ee14e340ae8a8553b91509ecf1aee965f7dcca5cc42c31f9bc291be40674cd7cda594b4f3401554e456a831602c00f970be14298d8610075089aa96
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.10
4
+ * Add custom formatter support
5
+
3
6
  ## 0.1.9
4
7
  * accept array request body
5
8
 
data/README.md CHANGED
@@ -25,6 +25,7 @@ A generic [fluentd][1] output plugin for sending logs to an HTTP endpoint
25
25
  password bobpop # default: '', secret: true
26
26
  use_ssl true # default: false
27
27
  verify_ssl false # default: true
28
+ format <formatter> # default: '', <formatter> is the name of your formatter plugin
28
29
  <headers>
29
30
  HeaderExample1 header1
30
31
  HeaderExample2 header2
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = "fluent-plugin-out-http-ext"
5
- gem.version = "0.1.9"
5
+ gem.version = "0.1.10"
6
6
  gem.authors = ["Toshiya Kawasaki"]
7
7
  gem.email = ["kawasakitoshiya@gmail.com"]
8
8
  gem.summary = %q{A generic Fluentd output plugin to send logs to an HTTP endpoint with SSL and Header option}
@@ -103,6 +103,8 @@ class Fluent::HTTPOutput < Fluent::Output
103
103
  config_param :username, :string, :default => ''
104
104
  config_param :password, :string, :default => '', :secret => true
105
105
 
106
+ config_param :format, :string, :default => ''
107
+
106
108
  def configure(conf)
107
109
  super
108
110
 
@@ -137,6 +139,12 @@ class Fluent::HTTPOutput < Fluent::Output
137
139
  @headers = element.to_hash
138
140
  end
139
141
  end
142
+
143
+ @formatter = nil
144
+ unless @format.empty?
145
+ @formatter = Fluent::Plugin.new_formatter(@format)
146
+ @formatter.configure(conf)
147
+ end
140
148
  end
141
149
 
142
150
  def start
@@ -251,6 +259,9 @@ class Fluent::HTTPOutput < Fluent::Output
251
259
 
252
260
  def emit(tag, es, chain)
253
261
  es.each do |time, record|
262
+ if @formatter
263
+ record = @formatter.format(tag, time, record)
264
+ end
254
265
  handle_record(tag, time, record)
255
266
  end
256
267
  chain.next
@@ -0,0 +1,21 @@
1
+ require 'fluent/formatter'
2
+
3
+ module Fluent
4
+ module TextFormatter
5
+ class TestFormatter < Formatter
6
+ Plugin.register_formatter('test_formatter', self)
7
+
8
+ def configure(conf)
9
+ super
10
+ end
11
+
12
+ def format(tag, time, record)
13
+ output = {
14
+ "wrapped" => true,
15
+ "record" => record
16
+ }
17
+ output
18
+ end
19
+ end
20
+ end
21
+ end
@@ -218,6 +218,12 @@ class HTTPOutputTest < HTTPOutputTestBase
218
218
  ignore_http_status_code 400..599
219
219
  ]
220
220
 
221
+ CONFIG_CUSTOM_FORMATTER = %[
222
+ endpoint_url http://127.0.0.1:#{TEST_LISTEN_PORT}/api/
223
+ serializer json
224
+ format test_formatter
225
+ ]
226
+
221
227
  def create_driver(conf=CONFIG, tag='test.metrics')
222
228
  Fluent::Test::OutputTestDriver.new(Fluent::HTTPOutput, tag).configure(conf)
223
229
  end
@@ -523,4 +529,15 @@ class HTTPOutputTest < HTTPOutputTestBase
523
529
  assert_equal [].to_set, Set.new([])
524
530
  assert_equal [1, 2].to_set, Set.new([1, 2])
525
531
  end
532
+
533
+ def test_custom_formatter
534
+ d = create_driver CONFIG_CUSTOM_FORMATTER
535
+ payload = {"field" => 1}
536
+ d.emit(payload)
537
+ d.run
538
+
539
+ record = @posts[0]
540
+ assert_equal record[:json]["wrapped"], true
541
+ assert_equal record[:json]["record"], payload
542
+ end
526
543
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-out-http-ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toshiya Kawasaki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-19 00:00:00.000000000 Z
11
+ date: 2018-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yajl-ruby
@@ -118,6 +118,7 @@ files:
118
118
  - Rakefile
119
119
  - fluent-plugin-out-http-ext.gemspec
120
120
  - lib/fluent/plugin/out_http_ext.rb
121
+ - lib/fluent/test/formatter_test.rb
121
122
  - lib/fluent/test/http_output_test.rb
122
123
  - test/plugin/test_helper.rb
123
124
  - test/plugin/test_out_http_ext.rb
@@ -141,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
142
  version: '0'
142
143
  requirements: []
143
144
  rubyforge_project:
144
- rubygems_version: 2.5.1
145
+ rubygems_version: 2.5.2
145
146
  signing_key:
146
147
  specification_version: 4
147
148
  summary: A generic Fluentd output plugin to send logs to an HTTP endpoint with SSL