fluentd 1.5.2-x64-mingw32 → 1.6.0-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of fluentd might be problematic. Click here for more details.

Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE.md +15 -6
  3. data/.github/ISSUE_TEMPLATE/bug_report.md +39 -0
  4. data/.github/ISSUE_TEMPLATE/feature_request.md +23 -0
  5. data/CHANGELOG.md +29 -0
  6. data/CONTRIBUTING.md +1 -1
  7. data/Gemfile +5 -0
  8. data/Rakefile +6 -1
  9. data/appveyor.yml +9 -10
  10. data/lib/fluent/command/fluentd.rb +4 -0
  11. data/lib/fluent/config/literal_parser.rb +2 -2
  12. data/lib/fluent/plugin/base.rb +1 -0
  13. data/lib/fluent/plugin/buffer.rb +22 -0
  14. data/lib/fluent/plugin/in_forward.rb +2 -2
  15. data/lib/fluent/plugin/in_monitor_agent.rb +90 -131
  16. data/lib/fluent/plugin/out_forward.rb +4 -0
  17. data/lib/fluent/plugin/output.rb +31 -1
  18. data/lib/fluent/plugin/parser_none.rb +1 -2
  19. data/lib/fluent/plugin_helper.rb +1 -0
  20. data/lib/fluent/plugin_helper/cert_option.rb +1 -1
  21. data/lib/fluent/plugin_helper/http_server.rb +75 -0
  22. data/lib/fluent/plugin_helper/http_server/app.rb +79 -0
  23. data/lib/fluent/plugin_helper/http_server/compat/server.rb +81 -0
  24. data/lib/fluent/plugin_helper/http_server/compat/webrick_handler.rb +58 -0
  25. data/lib/fluent/plugin_helper/http_server/methods.rb +35 -0
  26. data/lib/fluent/plugin_helper/http_server/request.rb +42 -0
  27. data/lib/fluent/plugin_helper/http_server/router.rb +54 -0
  28. data/lib/fluent/plugin_helper/http_server/server.rb +87 -0
  29. data/lib/fluent/plugin_helper/socket.rb +8 -2
  30. data/lib/fluent/supervisor.rb +5 -2
  31. data/lib/fluent/time.rb +13 -0
  32. data/lib/fluent/version.rb +1 -1
  33. data/test/command/test_fluentd.rb +36 -2
  34. data/test/helper.rb +1 -0
  35. data/test/helpers/fuzzy_assert.rb +89 -0
  36. data/test/plugin/test_buf_file.rb +1 -1
  37. data/test/plugin/test_in_http.rb +2 -5
  38. data/test/plugin/test_in_monitor_agent.rb +118 -17
  39. data/test/plugin/test_in_udp.rb +0 -2
  40. data/test/plugin/test_out_file.rb +15 -12
  41. data/test/plugin/test_out_forward.rb +18 -0
  42. data/test/plugin/test_out_secondary_file.rb +6 -4
  43. data/test/plugin/test_output_as_buffered.rb +4 -0
  44. data/test/plugin/test_output_as_buffered_retries.rb +0 -2
  45. data/test/plugin/test_output_as_buffered_secondary.rb +0 -3
  46. data/test/plugin_helper/data/cert/cert-key.pem +27 -0
  47. data/test/plugin_helper/data/cert/cert-with-no-newline.pem +19 -0
  48. data/test/plugin_helper/data/cert/cert.pem +19 -0
  49. data/test/plugin_helper/http_server/test_app.rb +65 -0
  50. data/test/plugin_helper/http_server/test_route.rb +32 -0
  51. data/test/plugin_helper/test_cert_option.rb +16 -0
  52. data/test/plugin_helper/test_http_server_helper.rb +203 -0
  53. data/test/plugin_helper/test_server.rb +1 -7
  54. data/test/test_event_time.rb +13 -0
  55. data/test/test_log.rb +8 -6
  56. data/test/test_supervisor.rb +3 -0
  57. metadata +28 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 40a735885456e270cdec4a7901890a1bdb95ed57ac11619e4964a4e4a72424b5
4
- data.tar.gz: 2812b16f48d05abcac4a73db463fdfeb5e54d134b27a616e4970a6a926d10ea3
3
+ metadata.gz: 3ce5c94466c4b0778160d6f54544308a0575fd7d9dd049bf9f1a57cc29c8c9a2
4
+ data.tar.gz: c0c4552b5e7b14454820365e18fe025bde61dce833058ec6e352cad436632ffe
5
5
  SHA512:
6
- metadata.gz: 2c2f29227b18b048568afafe50256389578e67996b9a042c6b7ff5a929b365a0da32e227cca7e9f0b52c74d0f9fcec2cd1d489676a4d1f7a60f206cc777c913f
7
- data.tar.gz: da62ccfb11b42ec7e312343c64d697aa79bcc05d2289b35ff3fb0b8769712076caf2373c627428c98fa8300515e580c29b99985183d8bedf3dd66ce59a492183
6
+ metadata.gz: 3b159865d0e829fc2711918fa71c1bb017cb900c6b793c96af2c0177b7e3b313aa210bb5cf1e25a0db38473dbd966d6fa8fd59ca1616e6e67c281e3d19d6d7b4
7
+ data.tar.gz: 9e0a43aee3b37f0343df2a1c398223d2df0785afecac64c0a7254004b39b2765a31ea306b036dc8fff2ee44ea8d7e597a43d468d18a93c52f2a316a8d137bd3a
@@ -1,8 +1,17 @@
1
1
  Check [CONTRIBUTING guideline](https://github.com/fluent/fluentd/blob/master/CONTRIBUTING.md) first and here is the list to help us investigate the problem.
2
2
 
3
- - fluentd or td-agent version.
4
- - Environment information:
5
- - Operating system: `cat /etc/os-release`
6
- - Kernel version: `uname -r`
7
- - Your configuration
8
- - Your problem explanation. If you have an error logs, write it together.
3
+ **Got a question or problem?**
4
+
5
+ RESOURCES of [Official site](https://www.fluentd.org/) and [Fluentd documentation](https://docs.fluentd.org/) may help you.
6
+
7
+ If you have further questions about Fluentd and plugins, please direct these to [Mailing List](https://groups.google.com/forum/#!forum/fluentd).
8
+ Don't use Github issue for asking questions. Here are examples:
9
+
10
+ - I installed xxx plugin but it doesn't work. Why?
11
+ - Fluentd starts but logs are not sent to xxx. Am I wrong?
12
+ - I want to do xxx. How to realize it with plugins?
13
+
14
+ We may close such questions to keep clear repository for developers and users.
15
+ Github issue is mainly for submitting a bug report or feature request. See below.
16
+
17
+ If you can't judge your case is a bug or not, use mailing list or slack first.
@@ -0,0 +1,39 @@
1
+ ---
2
+ name: Bug Report
3
+ about: Create a report to help us improve. If you have questions about Fluentd and plugins, please direct these to https://groups.google.com/forum/#!forum/fluentd
4
+ labels: 'bug'
5
+
6
+ ---
7
+
8
+ Check [CONTRIBUTING guideline](https://github.com/fluent/fluentd/blob/master/CONTRIBUTING.md) first and here is the list to help us investigate the problem.
9
+
10
+ **Describe the bug**
11
+ <!-- A clear and concise description of what the bug is. -->
12
+
13
+ **To Reproduce**
14
+ <!-- Steps to reproduce the behavior: -->
15
+
16
+ **Expected behavior**
17
+ <!-- A clear and concise description of what you expected to happen. -->
18
+
19
+ **Your Environment**
20
+
21
+ - Fluentd or td-agent version: `fluentd --version` or `td-agent --version`
22
+ - Operating system: `cat /etc/os-release`
23
+ - Kernel version: `uname -r`
24
+
25
+ **Your Configuration**
26
+
27
+ ```
28
+ <!-- Write your configuration here -->
29
+ ```
30
+
31
+ **Your Error Log**
32
+
33
+ ```
34
+ <!-- Write your **ALL** error log here -->
35
+ ```
36
+
37
+ **Additional context**
38
+
39
+ <!-- Add any other context about the problem here. -->
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+
5
+ ---
6
+
7
+ Check [CONTRIBUTING guideline](https://github.com/fluent/fluentd/blob/master/CONTRIBUTING.md) first and here is the list to help us investigate the problem.
8
+
9
+ **Is your feature request related to a problem? Please describe.**
10
+
11
+ <!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->
12
+
13
+ **Describe the solution you'd like**
14
+
15
+ <!-- A clear and concise description of what you want to happen. -->
16
+
17
+ **Describe alternatives you've considered**
18
+
19
+ <!-- A clear and concise description of any alternative solutions or features you've considered. -->
20
+
21
+ **Additional context**
22
+
23
+ <!-- Add any other context or screenshots about the feature request here. -->
@@ -1,3 +1,32 @@
1
+ # v1.6
2
+
3
+ ## Release v1.6.0 - 2019/07/01
4
+
5
+ ### New feature
6
+
7
+ * plugin: Add http_server helper and in_monitor_agent use it
8
+ https://github.com/fluent/fluentd/pull/2447
9
+
10
+ ### Enhancement
11
+
12
+ * in_monitor_agent: Add more metrics for buffer/output
13
+ https://github.com/fluent/fluentd/pull/2450
14
+ * time/plugin: Add `EventTime#to_time` method for fast conversion
15
+ https://github.com/fluent/fluentd/pull/2469
16
+ * socket helper/out_forward: Add connect_timeout parameter
17
+ https://github.com/fluent/fluentd/pull/2467
18
+ * command: Add `--conf-encoding` option
19
+ https://github.com/fluent/fluentd/pull/2453
20
+ * parser_none: Small performance optimization
21
+ https://github.com/fluent/fluentd/pull/2455
22
+
23
+ ### Bug fixes
24
+
25
+ * cert: Fix cert match pattern
26
+ https://github.com/fluent/fluentd/pull/2466
27
+ * output: Fix forget to increment rollback count
28
+ https://github.com/fluent/fluentd/pull/2462
29
+
1
30
  # v1.5
2
31
 
3
32
  ## Release v1.5.2 - 2019/06/13
@@ -24,7 +24,7 @@ If you find a bug of Fluentd or a mistake in the documentation, you can help us
24
24
  submitting an issue to Fluentd. Even better you can submit a Pull Request with a fix.
25
25
 
26
26
  * **Fluentd**: Use [fluentd](https://github.com/fluent/fluentd) repository. Fill issue template.
27
- * **Documentation**: Use [fluentd-docs](https://github.com/fluent/fluentd-docs) repository.
27
+ * **Documentation**: Use [fluentd-docs](https://github.com/fluent/fluentd-docs-gitbook) repository.
28
28
 
29
29
  If you find a bug of 3rd party plugins, please submit an issue to each plugin repository.
30
30
  And use [omnibus-td-agent](https://github.com/treasure-data/omnibus-td-agent) repository for td-agent related issues.
data/Gemfile CHANGED
@@ -2,6 +2,11 @@ source 'https://rubygems.org/'
2
2
 
3
3
  gemspec
4
4
 
5
+ # https://github.com/socketry/async-io/blob/v1.23.1/async-io.gemspec#L21
6
+ if Gem::Version.create(RUBY_VERSION) >= Gem::Version.create('2.3.0')
7
+ gem 'async-http', '~> 0.42'
8
+ end
9
+
5
10
  local_gemfile = File.join(File.dirname(__FILE__), "Gemfile.local")
6
11
  if File.exist?(local_gemfile)
7
12
  puts "Loading Gemfile.local ..." if $DEBUG # `ruby -d` or `bundle -v`
data/Rakefile CHANGED
@@ -34,7 +34,12 @@ Rake::TestTask.new(:base_test) do |t|
34
34
  t.test_files = if ENV["WIN_RAPID"]
35
35
  ["test/test_event.rb", "test/test_supervisor.rb", "test/plugin_helper/test_event_loop.rb"]
36
36
  else
37
- Dir["test/**/test_*.rb"].sort
37
+ tests = Dir["test/**/test_*.rb"].sort
38
+ if Process.uid.zero?
39
+ puts "test_file_util.rb for non-root user env. Disable this test on root environment"
40
+ tests.delete("test/plugin/test_file_util.rb")
41
+ end
42
+ tests
38
43
  end
39
44
  t.verbose = true
40
45
  t.warning = true
@@ -5,10 +5,11 @@ version: '{build}'
5
5
 
6
6
  install:
7
7
  - SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
8
- - "%devkit%\\devkitvars.bat"
8
+ - IF %ridk%==0 "%devkit%\\devkitvars.bat"
9
9
  - ruby --version
10
10
  - gem --version
11
- - bundle install
11
+ - IF %ridk%==1 ridk.cmd exec bundle install
12
+ - IF %ridk%==0 bundle install
12
13
  build: off
13
14
  test_script:
14
15
  - bundle exec rake test
@@ -17,22 +18,20 @@ test_script:
17
18
  branches:
18
19
  only:
19
20
  - master
20
- - v0.10
21
- - v0.12
22
- - v0.14
23
21
 
24
22
  # https://www.appveyor.com/docs/installed-software/#ruby
25
23
  environment:
26
24
  matrix:
27
25
  - ruby_version: "23-x64"
28
26
  devkit: C:\Ruby23-x64\DevKit
27
+ ridk: 0
29
28
  - ruby_version: "23"
30
29
  devkit: C:\Ruby23\DevKit
31
- - ruby_version: "22-x64"
32
- devkit: C:\Ruby23-x64\DevKit
33
- - ruby_version: "22"
34
- devkit: C:\Ruby23\DevKit
35
- WIN_RAPID: true
30
+ ridk: 0
31
+ - ruby_version: "24-x64"
32
+ ridk: 1
33
+ - ruby_version: "24"
34
+ ridk: 1
36
35
  matrix:
37
36
  allow_failures:
38
37
  - ruby_version: "21"
@@ -155,6 +155,10 @@ op.on('-G', '--gem-path GEM_INSTALL_PATH', "Gemfile install path (default: $(dir
155
155
  opts[:gem_install_path] = s
156
156
  }
157
157
 
158
+ op.on('--conf-encoding ENCODING', "specify configuration file encoding") { |s|
159
+ opts[:conf_encoding] = s
160
+ }
161
+
158
162
  if Fluent.windows?
159
163
  require 'windows/library'
160
164
  include Windows::Library
@@ -215,7 +215,7 @@ EOM
215
215
  parsed = nil
216
216
  begin
217
217
  parsed = JSON.parse(buffer + line_buffer.rstrip.sub(/,$/, '') + (is_array ? "]" : "}"))
218
- rescue JSON::ParserError => e
218
+ rescue JSON::ParserError
219
219
  # This '#' is in json string literals
220
220
  end
221
221
 
@@ -243,7 +243,7 @@ EOM
243
243
  line_buffer << char
244
244
  begin
245
245
  result = JSON.parse(buffer + line_buffer)
246
- rescue JSON::ParserError => e
246
+ rescue JSON::ParserError
247
247
  # Incomplete json string yet
248
248
  end
249
249
  end
@@ -29,6 +29,7 @@ module Fluent
29
29
  attr_accessor :under_plugin_development
30
30
 
31
31
  def initialize
32
+ @log = nil
32
33
  super
33
34
  @_state = State.new(false, false, false, false, false, false, false, false, false)
34
35
  @_context_router = nil
@@ -740,6 +740,28 @@ module Fluent
740
740
  enqueue_chunk(metadata) if enqueue_chunk_before_retry
741
741
  retry
742
742
  end
743
+
744
+ def statistics
745
+ buffer_space = 1.0 - ((@stage_size + @queue_size * 1.0) / @total_limit_size).round
746
+ stats = {
747
+ 'stage_length' => @stage.size,
748
+ 'stage_byte_size' => @stage_size,
749
+ 'queue_length' => @queue.size,
750
+ 'queue_byte_size' => @queue_size,
751
+ 'available_buffer_space_ratios' => buffer_space * 100,
752
+ 'total_queued_size' => @stage_size + @queue_size,
753
+ }
754
+
755
+ if (m = timekeys.min)
756
+ stats['oldest_timekey'] = m
757
+ end
758
+
759
+ if (m = timekeys.max)
760
+ stats['newest_timekey'] = m
761
+ end
762
+
763
+ { 'buffer' => stats }
764
+ end
743
765
  end
744
766
  end
745
767
  end
@@ -135,13 +135,13 @@ module Fluent::Plugin
135
135
  if client.host
136
136
  begin
137
137
  source = IPSocket.getaddress(client.host)
138
- rescue SocketError => e
138
+ rescue SocketError
139
139
  raise Fluent::ConfigError, "host '#{client.host}' cannot be resolved"
140
140
  end
141
141
  end
142
142
  source_addr = begin
143
143
  IPAddr.new(source || client.network)
144
- rescue ArgumentError => e
144
+ rescue ArgumentError
145
145
  raise Fluent::ConfigError, "network '#{client.network}' address format is invalid"
146
146
  end
147
147
  @nodes.push({
@@ -28,7 +28,7 @@ module Fluent::Plugin
28
28
  class MonitorAgentInput < Input
29
29
  Fluent::Plugin.register_input('monitor_agent', self)
30
30
 
31
- helpers :timer, :thread
31
+ helpers :timer, :thread, :http_server
32
32
 
33
33
  desc 'The address to bind to.'
34
34
  config_param :bind, :string, default: '0.0.0.0'
@@ -43,35 +43,83 @@ module Fluent::Plugin
43
43
  desc 'Determine whether to include the retry information.'
44
44
  config_param :include_retry, :bool, default: true
45
45
 
46
- class MonitorServlet < WEBrick::HTTPServlet::AbstractServlet
47
- def initialize(server, agent)
46
+ class APIHandler
47
+ def initialize(agent)
48
48
  @agent = agent
49
49
  end
50
50
 
51
- def do_GET(req, res)
52
- begin
53
- code, header, body = process(req)
54
- rescue
55
- code, header, body = render_json_error(500, {
56
- 'message '=> 'Internal Server Error',
57
- 'error' => "#{$!}",
58
- 'backgrace'=> $!.backtrace,
59
- })
60
- end
51
+ def plugins_ltsv(req)
52
+ list = build_object(build_option(req))
61
53
 
62
- # set response code, header and body
63
- res.status = code
64
- header.each_pair {|k,v|
65
- res[k] = v
66
- }
67
- res.body = body
54
+ render_ltsv(list)
55
+ end
56
+
57
+ def plugins_json(req)
58
+ opts = build_option(req)
59
+ obj = build_object(opts)
60
+
61
+ render_json({ 'plugins' => obj }, pretty_json: opts[:pretty_json])
62
+ end
63
+
64
+ def config_ltsv(_req)
65
+ obj = {
66
+ 'pid' => Process.pid,
67
+ 'ppid' => Process.ppid
68
+ }.merge(@agent.fluentd_opts)
69
+
70
+ render_ltsv([obj])
71
+ end
72
+
73
+ def config_json(req)
74
+ obj = {
75
+ 'pid' => Process.pid,
76
+ 'ppid' => Process.ppid
77
+ }.merge(@agent.fluentd_opts)
78
+ opts = build_option(req)
79
+
80
+ render_json(obj, pretty_json: opts[:pretty_json])
81
+ end
82
+
83
+ private
84
+
85
+ def render_error_json(code:, msg:, pretty_json: nil, **additional_params)
86
+ resp = additional_params.merge('message' => msg)
87
+ render_json(resp, code: code, pretty_json: pretty_json)
68
88
  end
69
89
 
70
- def build_object(req, opts)
71
- unless req.path_info == ""
72
- return render_json_error(404, "Not found")
90
+ def render_json(obj, code: 200, pretty_json: nil)
91
+ body =
92
+ if pretty_json
93
+ JSON.pretty_generate(obj)
94
+ else
95
+ obj.to_json
96
+ end
97
+
98
+ [code, { 'Content-Type' => 'application/json' }, body]
99
+ end
100
+
101
+ def render_ltsv(obj, code: 200)
102
+ normalized = JSON.parse(obj.to_json)
103
+ text = ''
104
+ normalized.each do |hash|
105
+ row = []
106
+ hash.each do |k, v|
107
+ if v.is_a?(Array)
108
+ row << "#{k}:#{v.join(',')}"
109
+ elsif v.is_a?(Hash)
110
+ next
111
+ else
112
+ row << "#{k}:#{v}"
113
+ end
114
+ end
115
+
116
+ text << row.join("\t") << "\n"
73
117
  end
74
118
 
119
+ [code, { 'Content-Type' => 'text/plain' }, text]
120
+ end
121
+
122
+ def build_object(opts)
75
123
  qs = opts[:query]
76
124
  if tag = qs['tag'.freeze].first
77
125
  # ?tag= to search an output plugin by match pattern
@@ -98,30 +146,11 @@ module Fluent::Plugin
98
146
  list
99
147
  end
100
148
 
101
- def render_json(obj, opts={})
102
- render_json_error(200, obj, opts)
103
- end
104
-
105
- def render_json_error(code, obj, opts={})
106
- if opts[:pretty_json]
107
- js = JSON.pretty_generate(obj)
108
- else
109
- js = obj.to_json
110
- end
111
- [code, {'Content-Type'=>'application/json'}, js]
112
- end
113
-
114
- private
115
-
116
149
  def build_option(req)
117
150
  qs = Hash.new { |_, _| [] }
118
151
  # parse ?=query string
119
152
  if req.query_string
120
- begin
121
- qs.merge!(CGI.parse(req.query_string))
122
- rescue
123
- return render_json_error(400, "Invalid query string")
124
- end
153
+ qs.merge!(CGI.parse(req.query_string))
125
154
  end
126
155
 
127
156
  # if ?debug=1 is set, set :with_debug_info for get_monitor_info
@@ -152,74 +181,6 @@ module Fluent::Plugin
152
181
  end
153
182
  end
154
183
 
155
- class LTSVMonitorServlet < MonitorServlet
156
- def process(req)
157
- opts = build_option(req)
158
- list = build_object(req, opts)
159
- return unless list
160
-
161
- normalized = JSON.parse(list.to_json)
162
-
163
- text = ''
164
-
165
- normalized.map {|hash|
166
- row = []
167
- hash.each_pair {|k,v|
168
- unless v.is_a?(Hash) || v.is_a?(Array)
169
- row << "#{k}:#{v}"
170
- end
171
- }
172
- text << row.join("\t") << "\n"
173
- }
174
-
175
- [200, {'Content-Type'=>'text/plain'}, text]
176
- end
177
- end
178
-
179
- class JSONMonitorServlet < MonitorServlet
180
- def process(req)
181
- opts = build_option(req)
182
- list = build_object(req, opts)
183
- return unless list
184
-
185
- render_json({
186
- 'plugins' => list
187
- }, opts)
188
- end
189
- end
190
-
191
- class ConfigMonitorServlet < MonitorServlet
192
- def build_object(req, _opt)
193
- {
194
- 'pid' => Process.pid,
195
- 'ppid' => Process.ppid
196
- }.merge(@agent.fluentd_opts)
197
- end
198
- end
199
-
200
- class LTSVConfigMonitorServlet < ConfigMonitorServlet
201
- def process(req)
202
- opts = build_option(req)
203
- result = build_object(req, opts)
204
-
205
- row = []
206
- JSON.parse(result.to_json).each_pair { |k, v|
207
- row << "#{k}:#{v}"
208
- }
209
- text = row.join("\t")
210
-
211
- [200, {'Content-Type'=>'text/plain'}, text]
212
- end
213
- end
214
-
215
- class JSONConfigMonitorServlet < ConfigMonitorServlet
216
- def process(req)
217
- opts = build_option(req)
218
- result = build_object(req, opts)
219
- render_json(result, opts)
220
- end
221
- end
222
-
223
184
  def initialize
224
185
  super
225
186
 
@@ -235,23 +196,25 @@ module Fluent::Plugin
235
196
  true
236
197
  end
237
198
 
199
+ class NotFoundJson
200
+ BODY = { 'message' => 'Not found' }.to_json
201
+ def self.call(_req)
202
+ [404, { 'Content-Type' => 'application/json' }, BODY]
203
+ end
204
+ end
205
+
238
206
  def start
239
207
  super
240
208
 
241
209
  log.debug "listening monitoring http server on http://#{@bind}:#{@port}/api/plugins for worker#{fluentd_worker_id}"
242
- @srv = WEBrick::HTTPServer.new({
243
- BindAddress: @bind,
244
- Port: @port,
245
- Logger: WEBrick::Log.new(STDERR, WEBrick::Log::FATAL),
246
- AccessLog: [],
247
- })
248
- @srv.mount('/api/plugins', LTSVMonitorServlet, self)
249
- @srv.mount('/api/plugins.json', JSONMonitorServlet, self)
250
- @srv.mount('/api/config', LTSVConfigMonitorServlet, self)
251
- @srv.mount('/api/config.json', JSONConfigMonitorServlet, self)
252
- thread_create :in_monitor_agent_servlet do
253
- @srv.start
210
+ api_handler = APIHandler.new(self)
211
+ create_http_server(addr: @bind, port: @port, logger: log, default_app: NotFoundJson) do |serv|
212
+ serv.get('/api/plugins') { |req| api_handler.plugins_ltsv(req) }
213
+ serv.get('/api/plugins.json') { |req| api_handler.plugins_json(req) }
214
+ serv.get('/api/config') { |req| api_handler.config_ltsv(req) }
215
+ serv.get('/api/config.json') { |req| api_handler.config_json(req) }
254
216
  end
217
+
255
218
  if @tag
256
219
  log.debug "tag parameter is specified. Emit plugins info to '#{@tag}'"
257
220
 
@@ -267,15 +230,7 @@ module Fluent::Plugin
267
230
  end
268
231
  end
269
232
 
270
- def shutdown
271
- if @srv
272
- @srv.shutdown
273
- @srv = nil
274
- end
275
-
276
- super
277
- end
278
-
233
+ # They are deprecated but remain for compatibility
279
234
  MONITOR_INFO = {
280
235
  'output_plugin' => ->(){ is_a?(::Fluent::Plugin::Output) },
281
236
  'buffer_queue_length' => ->(){ throw(:skip) unless instance_variable_defined?(:@buffer) && !@buffer.nil? && @buffer.is_a?(::Fluent::Plugin::Buffer); @buffer.queue.size },
@@ -377,6 +332,10 @@ module Fluent::Plugin
377
332
  end
378
333
  }
379
334
 
335
+ if pe.respond_to?(:statistics)
336
+ obj.merge!(pe.statistics['output'] || {})
337
+ end
338
+
380
339
  obj['retry'] = get_retry_info(pe.retry) if opts[:with_retry] and pe.instance_variable_defined?(:@retry)
381
340
 
382
341
  # include all instance variables if :with_debug_info is set