fluentd 0.12.43 → 0.14.0
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.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE.md +6 -0
- data/.gitignore +2 -0
- data/.travis.yml +33 -21
- data/CONTRIBUTING.md +1 -0
- data/ChangeLog +1239 -0
- data/README.md +0 -25
- data/Rakefile +2 -1
- data/Vagrantfile +17 -0
- data/appveyor.yml +35 -0
- data/example/filter_stdout.conf +5 -5
- data/example/in_forward.conf +2 -2
- data/example/in_http.conf +2 -2
- data/example/in_out_forward.conf +17 -0
- data/example/in_syslog.conf +2 -2
- data/example/in_tail.conf +2 -2
- data/example/in_tcp.conf +2 -2
- data/example/in_udp.conf +2 -2
- data/example/out_copy.conf +4 -4
- data/example/out_file.conf +2 -2
- data/example/out_forward.conf +2 -2
- data/example/out_forward_buf_file.conf +23 -0
- data/example/v0_12_filter.conf +8 -8
- data/fluent.conf +29 -0
- data/fluentd.gemspec +18 -11
- data/lib/fluent/agent.rb +60 -58
- data/lib/fluent/command/cat.rb +1 -1
- data/lib/fluent/command/debug.rb +7 -5
- data/lib/fluent/command/fluentd.rb +97 -2
- data/lib/fluent/compat/call_super_mixin.rb +67 -0
- data/lib/fluent/compat/filter.rb +50 -0
- data/lib/fluent/compat/formatter.rb +109 -0
- data/lib/fluent/compat/input.rb +50 -0
- data/lib/fluent/compat/output.rb +617 -0
- data/lib/fluent/compat/output_chain.rb +60 -0
- data/lib/fluent/compat/parser.rb +163 -0
- data/lib/fluent/compat/propagate_default.rb +62 -0
- data/lib/fluent/config.rb +23 -20
- data/lib/fluent/config/configure_proxy.rb +119 -70
- data/lib/fluent/config/dsl.rb +5 -18
- data/lib/fluent/config/element.rb +72 -8
- data/lib/fluent/config/error.rb +0 -3
- data/lib/fluent/config/literal_parser.rb +0 -2
- data/lib/fluent/config/parser.rb +4 -4
- data/lib/fluent/config/section.rb +39 -28
- data/lib/fluent/config/types.rb +2 -13
- data/lib/fluent/config/v1_parser.rb +1 -3
- data/lib/fluent/configurable.rb +48 -16
- data/lib/fluent/daemon.rb +15 -0
- data/lib/fluent/engine.rb +26 -52
- data/lib/fluent/env.rb +6 -4
- data/lib/fluent/event.rb +58 -11
- data/lib/fluent/event_router.rb +5 -5
- data/lib/fluent/filter.rb +2 -50
- data/lib/fluent/formatter.rb +4 -293
- data/lib/fluent/input.rb +2 -32
- data/lib/fluent/label.rb +2 -2
- data/lib/fluent/load.rb +3 -2
- data/lib/fluent/log.rb +107 -38
- data/lib/fluent/match.rb +0 -36
- data/lib/fluent/mixin.rb +117 -7
- data/lib/fluent/msgpack_factory.rb +62 -0
- data/lib/fluent/output.rb +7 -612
- data/lib/fluent/output_chain.rb +23 -0
- data/lib/fluent/parser.rb +4 -800
- data/lib/fluent/plugin.rb +100 -121
- data/lib/fluent/plugin/bare_output.rb +63 -0
- data/lib/fluent/plugin/base.rb +121 -0
- data/lib/fluent/plugin/buf_file.rb +101 -182
- data/lib/fluent/plugin/buf_memory.rb +9 -92
- data/lib/fluent/plugin/buffer.rb +473 -0
- data/lib/fluent/plugin/buffer/chunk.rb +135 -0
- data/lib/fluent/plugin/buffer/file_chunk.rb +339 -0
- data/lib/fluent/plugin/buffer/memory_chunk.rb +100 -0
- data/lib/fluent/plugin/exec_util.rb +80 -75
- data/lib/fluent/plugin/file_util.rb +33 -28
- data/lib/fluent/plugin/file_wrapper.rb +120 -0
- data/lib/fluent/plugin/filter.rb +51 -0
- data/lib/fluent/plugin/filter_grep.rb +13 -40
- data/lib/fluent/plugin/filter_record_transformer.rb +22 -18
- data/lib/fluent/plugin/formatter.rb +93 -0
- data/lib/fluent/plugin/formatter_csv.rb +48 -0
- data/lib/fluent/plugin/formatter_hash.rb +32 -0
- data/lib/fluent/plugin/formatter_json.rb +47 -0
- data/lib/fluent/plugin/formatter_ltsv.rb +42 -0
- data/lib/fluent/plugin/formatter_msgpack.rb +32 -0
- data/lib/fluent/plugin/formatter_out_file.rb +45 -0
- data/lib/fluent/plugin/formatter_single_value.rb +34 -0
- data/lib/fluent/plugin/formatter_stdout.rb +39 -0
- data/lib/fluent/plugin/in_debug_agent.rb +4 -0
- data/lib/fluent/plugin/in_dummy.rb +22 -18
- data/lib/fluent/plugin/in_exec.rb +18 -8
- data/lib/fluent/plugin/in_forward.rb +36 -79
- data/lib/fluent/plugin/in_gc_stat.rb +4 -0
- data/lib/fluent/plugin/in_http.rb +21 -18
- data/lib/fluent/plugin/in_monitor_agent.rb +15 -48
- data/lib/fluent/plugin/in_object_space.rb +6 -1
- data/lib/fluent/plugin/in_stream.rb +7 -3
- data/lib/fluent/plugin/in_syslog.rb +46 -95
- data/lib/fluent/plugin/in_tail.rb +58 -640
- data/lib/fluent/plugin/in_tcp.rb +8 -1
- data/lib/fluent/plugin/in_udp.rb +8 -18
- data/lib/fluent/plugin/input.rb +33 -0
- data/lib/fluent/plugin/multi_output.rb +95 -0
- data/lib/fluent/plugin/out_buffered_null.rb +59 -0
- data/lib/fluent/plugin/out_copy.rb +11 -7
- data/lib/fluent/plugin/out_exec.rb +15 -11
- data/lib/fluent/plugin/out_exec_filter.rb +18 -10
- data/lib/fluent/plugin/out_file.rb +34 -5
- data/lib/fluent/plugin/out_forward.rb +25 -19
- data/lib/fluent/plugin/out_null.rb +0 -14
- data/lib/fluent/plugin/out_roundrobin.rb +11 -7
- data/lib/fluent/plugin/out_stdout.rb +5 -7
- data/lib/fluent/plugin/out_stream.rb +3 -1
- data/lib/fluent/plugin/output.rb +979 -0
- data/lib/fluent/plugin/owned_by_mixin.rb +42 -0
- data/lib/fluent/plugin/parser.rb +244 -0
- data/lib/fluent/plugin/parser_apache.rb +24 -0
- data/lib/fluent/plugin/parser_apache2.rb +84 -0
- data/lib/fluent/plugin/parser_apache_error.rb +21 -0
- data/lib/fluent/plugin/parser_csv.rb +31 -0
- data/lib/fluent/plugin/parser_json.rb +79 -0
- data/lib/fluent/plugin/parser_ltsv.rb +50 -0
- data/lib/fluent/plugin/parser_multiline.rb +102 -0
- data/lib/fluent/plugin/parser_nginx.rb +24 -0
- data/lib/fluent/plugin/parser_none.rb +36 -0
- data/lib/fluent/plugin/parser_syslog.rb +82 -0
- data/lib/fluent/plugin/parser_tsv.rb +37 -0
- data/lib/fluent/plugin/socket_util.rb +119 -117
- data/lib/fluent/plugin/storage.rb +84 -0
- data/lib/fluent/plugin/storage_local.rb +116 -0
- data/lib/fluent/plugin/string_util.rb +16 -13
- data/lib/fluent/plugin_helper.rb +39 -0
- data/lib/fluent/plugin_helper/child_process.rb +298 -0
- data/lib/fluent/plugin_helper/compat_parameters.rb +99 -0
- data/lib/fluent/plugin_helper/event_emitter.rb +80 -0
- data/lib/fluent/plugin_helper/event_loop.rb +118 -0
- data/lib/fluent/plugin_helper/retry_state.rb +177 -0
- data/lib/fluent/plugin_helper/storage.rb +308 -0
- data/lib/fluent/plugin_helper/thread.rb +147 -0
- data/lib/fluent/plugin_helper/timer.rb +85 -0
- data/lib/fluent/plugin_id.rb +63 -0
- data/lib/fluent/process.rb +21 -30
- data/lib/fluent/registry.rb +21 -9
- data/lib/fluent/root_agent.rb +115 -40
- data/lib/fluent/supervisor.rb +330 -320
- data/lib/fluent/system_config.rb +42 -18
- data/lib/fluent/test.rb +6 -1
- data/lib/fluent/test/base.rb +23 -3
- data/lib/fluent/test/driver/base.rb +247 -0
- data/lib/fluent/test/driver/event_feeder.rb +98 -0
- data/lib/fluent/test/driver/filter.rb +35 -0
- data/lib/fluent/test/driver/input.rb +31 -0
- data/lib/fluent/test/driver/output.rb +78 -0
- data/lib/fluent/test/driver/test_event_router.rb +45 -0
- data/lib/fluent/test/filter_test.rb +0 -1
- data/lib/fluent/test/formatter_test.rb +2 -1
- data/lib/fluent/test/input_test.rb +23 -17
- data/lib/fluent/test/output_test.rb +28 -39
- data/lib/fluent/test/parser_test.rb +1 -1
- data/lib/fluent/time.rb +104 -1
- data/lib/fluent/{status.rb → unique_id.rb} +15 -24
- data/lib/fluent/version.rb +1 -1
- data/lib/fluent/winsvc.rb +72 -0
- data/test/compat/test_calls_super.rb +164 -0
- data/test/config/test_config_parser.rb +83 -0
- data/test/config/test_configurable.rb +547 -274
- data/test/config/test_configure_proxy.rb +146 -29
- data/test/config/test_dsl.rb +3 -181
- data/test/config/test_element.rb +274 -0
- data/test/config/test_literal_parser.rb +1 -1
- data/test/config/test_section.rb +79 -7
- data/test/config/test_system_config.rb +21 -0
- data/test/config/test_types.rb +3 -26
- data/test/helper.rb +78 -8
- data/test/plugin/test_bare_output.rb +118 -0
- data/test/plugin/test_base.rb +75 -0
- data/test/plugin/test_buf_file.rb +420 -521
- data/test/plugin/test_buf_memory.rb +32 -194
- data/test/plugin/test_buffer.rb +981 -0
- data/test/plugin/test_buffer_chunk.rb +110 -0
- data/test/plugin/test_buffer_file_chunk.rb +770 -0
- data/test/plugin/test_buffer_memory_chunk.rb +265 -0
- data/test/plugin/test_filter.rb +255 -0
- data/test/plugin/test_filter_grep.rb +2 -73
- data/test/plugin/test_filter_record_transformer.rb +24 -68
- data/test/plugin/test_filter_stdout.rb +6 -6
- data/test/plugin/test_in_debug_agent.rb +2 -0
- data/test/plugin/test_in_dummy.rb +11 -17
- data/test/plugin/test_in_exec.rb +6 -25
- data/test/plugin/test_in_forward.rb +112 -151
- data/test/plugin/test_in_gc_stat.rb +2 -0
- data/test/plugin/test_in_http.rb +106 -157
- data/test/plugin/test_in_object_space.rb +21 -5
- data/test/plugin/test_in_stream.rb +14 -13
- data/test/plugin/test_in_syslog.rb +30 -275
- data/test/plugin/test_in_tail.rb +95 -282
- data/test/plugin/test_in_tcp.rb +14 -0
- data/test/plugin/test_in_udp.rb +21 -67
- data/test/plugin/test_input.rb +122 -0
- data/test/plugin/test_multi_output.rb +180 -0
- data/test/plugin/test_out_buffered_null.rb +79 -0
- data/test/plugin/test_out_copy.rb +15 -2
- data/test/plugin/test_out_exec.rb +75 -25
- data/test/plugin/test_out_exec_filter.rb +74 -8
- data/test/plugin/test_out_file.rb +61 -7
- data/test/plugin/test_out_forward.rb +92 -15
- data/test/plugin/test_out_roundrobin.rb +1 -0
- data/test/plugin/test_out_stdout.rb +22 -13
- data/test/plugin/test_out_stream.rb +18 -0
- data/test/plugin/test_output.rb +515 -0
- data/test/plugin/test_output_as_buffered.rb +1540 -0
- data/test/plugin/test_output_as_buffered_overflow.rb +247 -0
- data/test/plugin/test_output_as_buffered_retries.rb +808 -0
- data/test/plugin/test_output_as_buffered_secondary.rb +776 -0
- data/test/plugin/test_output_as_standard.rb +362 -0
- data/test/plugin/test_owned_by.rb +35 -0
- data/test/plugin/test_storage.rb +167 -0
- data/test/plugin/test_storage_local.rb +8 -0
- data/test/plugin_helper/test_child_process.rb +599 -0
- data/test/plugin_helper/test_compat_parameters.rb +175 -0
- data/test/plugin_helper/test_event_emitter.rb +51 -0
- data/test/plugin_helper/test_event_loop.rb +52 -0
- data/test/plugin_helper/test_retry_state.rb +399 -0
- data/test/plugin_helper/test_storage.rb +411 -0
- data/test/plugin_helper/test_thread.rb +164 -0
- data/test/plugin_helper/test_timer.rb +100 -0
- data/test/scripts/exec_script.rb +0 -6
- data/test/scripts/fluent/plugin/out_test.rb +3 -0
- data/test/test_config.rb +13 -4
- data/test/test_event.rb +24 -13
- data/test/test_event_router.rb +8 -7
- data/test/test_event_time.rb +187 -0
- data/test/test_formatter.rb +13 -51
- data/test/test_input.rb +1 -1
- data/test/test_log.rb +239 -16
- data/test/test_mixin.rb +1 -1
- data/test/test_output.rb +53 -66
- data/test/test_parser.rb +105 -323
- data/test/test_plugin_helper.rb +81 -0
- data/test/test_root_agent.rb +4 -52
- data/test/test_supervisor.rb +272 -0
- data/test/test_unique_id.rb +47 -0
- metadata +181 -55
- data/CHANGELOG.md +0 -710
- data/lib/fluent/buffer.rb +0 -365
- data/lib/fluent/plugin/filter_parser.rb +0 -107
- data/lib/fluent/plugin/in_status.rb +0 -76
- data/lib/fluent/test/helpers.rb +0 -86
- data/test/plugin/data/log/foo/bar2 +0 -0
- data/test/plugin/test_filter_parser.rb +0 -744
- data/test/plugin/test_in_status.rb +0 -38
- data/test/test_buffer.rb +0 -624
@@ -50,6 +50,8 @@ module Fluent
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def start
|
53
|
+
super
|
54
|
+
|
53
55
|
@loop = Coolio::Loop.new
|
54
56
|
@timer = TimerWatcher.new(@emit_interval, true, log, &method(:on_timer))
|
55
57
|
@loop.attach(@timer)
|
@@ -60,6 +62,8 @@ module Fluent
|
|
60
62
|
@loop.watchers.each {|w| w.detach }
|
61
63
|
@loop.stop
|
62
64
|
@thread.join
|
65
|
+
|
66
|
+
super
|
63
67
|
end
|
64
68
|
|
65
69
|
def run
|
@@ -101,12 +101,17 @@ module Fluent
|
|
101
101
|
|
102
102
|
def start
|
103
103
|
log.debug "listening http on #{@bind}:#{@port}"
|
104
|
-
|
104
|
+
|
105
|
+
socket_manager_path = ENV['SERVERENGINE_SOCKETMANAGER_PATH']
|
106
|
+
if Fluent.windows?
|
107
|
+
socket_manager_path = socket_manager_path.to_i
|
108
|
+
end
|
109
|
+
client = ServerEngine::SocketManager::Client.new(socket_manager_path)
|
110
|
+
lsock = client.listen_tcp(@bind, @port)
|
105
111
|
|
106
112
|
detach_multi_process do
|
107
113
|
super
|
108
114
|
@km = KeepaliveManager.new(@keepalive_timeout)
|
109
|
-
#@lsock = Coolio::TCPServer.new(@bind, @port, Handler, @km, method(:on_request), @body_size_limit)
|
110
115
|
@lsock = Coolio::TCPServer.new(lsock, nil, Handler, @km, method(:on_request),
|
111
116
|
@body_size_limit, @format, log,
|
112
117
|
@cors_allow_origins)
|
@@ -125,6 +130,8 @@ module Fluent
|
|
125
130
|
@loop.stop
|
126
131
|
@lsock.close
|
127
132
|
@thread.join
|
133
|
+
|
134
|
+
super
|
128
135
|
end
|
129
136
|
|
130
137
|
def run
|
@@ -143,9 +150,9 @@ module Fluent
|
|
143
150
|
# Skip nil record
|
144
151
|
if record.nil?
|
145
152
|
if @respond_with_empty_img
|
146
|
-
return ["200 OK", {'Content-
|
153
|
+
return ["200 OK", {'Content-Type'=>'image/gif; charset=utf-8'}, EMPTY_GIF_IMAGE]
|
147
154
|
else
|
148
|
-
return ["200 OK", {'Content-
|
155
|
+
return ["200 OK", {'Content-Type'=>'text/plain'}, ""]
|
149
156
|
end
|
150
157
|
end
|
151
158
|
|
@@ -162,13 +169,13 @@ module Fluent
|
|
162
169
|
end
|
163
170
|
end
|
164
171
|
time = if param_time = params['time']
|
165
|
-
param_time = param_time.
|
166
|
-
param_time.zero? ? Engine.now : param_time
|
172
|
+
param_time = param_time.to_f
|
173
|
+
param_time.zero? ? Engine.now : Fluent::EventTime.from_time(Time.at(param_time))
|
167
174
|
else
|
168
175
|
record_time.nil? ? Engine.now : record_time
|
169
176
|
end
|
170
177
|
rescue
|
171
|
-
return ["400 Bad Request", {'Content-
|
178
|
+
return ["400 Bad Request", {'Content-Type'=>'text/plain'}, "400 Bad Request\n#{$!}\n"]
|
172
179
|
end
|
173
180
|
|
174
181
|
# TODO server error
|
@@ -195,13 +202,13 @@ module Fluent
|
|
195
202
|
router.emit(tag, time, record)
|
196
203
|
end
|
197
204
|
rescue
|
198
|
-
return ["500 Internal Server Error", {'Content-
|
205
|
+
return ["500 Internal Server Error", {'Content-Type'=>'text/plain'}, "500 Internal Server Error\n#{$!}\n"]
|
199
206
|
end
|
200
207
|
|
201
208
|
if @respond_with_empty_img
|
202
|
-
return ["200 OK", {'Content-
|
209
|
+
return ["200 OK", {'Content-Type'=>'image/gif; charset=utf-8'}, EMPTY_GIF_IMAGE]
|
203
210
|
else
|
204
|
-
return ["200 OK", {'Content-
|
211
|
+
return ["200 OK", {'Content-Type'=>'text/plain'}, ""]
|
205
212
|
end
|
206
213
|
end
|
207
214
|
|
@@ -232,6 +239,8 @@ module Fluent
|
|
232
239
|
end
|
233
240
|
|
234
241
|
class Handler < Coolio::Socket
|
242
|
+
attr_reader :content_type
|
243
|
+
|
235
244
|
def initialize(io, km, callback, body_size_limit, format, log, cors_allow_origins)
|
236
245
|
super(io)
|
237
246
|
@km = km
|
@@ -300,10 +309,6 @@ module Fluent
|
|
300
309
|
end
|
301
310
|
when /Origin/i
|
302
311
|
@origin = v
|
303
|
-
when /X-Forwarded-For/i
|
304
|
-
# For multiple X-Forwarded-For headers. Use first header value.
|
305
|
-
v = v.first if v.is_a?(Array)
|
306
|
-
@remote_addr = v.split(",").first
|
307
312
|
end
|
308
313
|
}
|
309
314
|
if expect
|
@@ -357,8 +362,6 @@ module Fluent
|
|
357
362
|
params.update WEBrick::HTTPUtils.parse_form_data(@body, boundary)
|
358
363
|
elsif @content_type =~ /^application\/json/
|
359
364
|
params['json'] = @body
|
360
|
-
elsif @content_type =~ /^application\/msgpack/
|
361
|
-
params['msgpack'] = @body
|
362
365
|
end
|
363
366
|
path_info = uri.path
|
364
367
|
|
@@ -391,8 +394,8 @@ module Fluent
|
|
391
394
|
end
|
392
395
|
|
393
396
|
def send_response(code, header, body)
|
394
|
-
header['Content-
|
395
|
-
header['Content-
|
397
|
+
header['Content-Length'] ||= body.bytesize
|
398
|
+
header['Content-Type'] ||= 'text/plain'
|
396
399
|
|
397
400
|
data = %[HTTP/1.1 #{code}\r\n]
|
398
401
|
header.each_pair {|k,v|
|
@@ -32,9 +32,6 @@ module Fluent
|
|
32
32
|
config_param :port, :integer, default: 24220
|
33
33
|
config_param :tag, :string, default: nil
|
34
34
|
config_param :emit_interval, :time, default: 60
|
35
|
-
config_param :emit_config, :bool, default: false
|
36
|
-
config_param :include_config, :bool, default: true
|
37
|
-
config_param :include_retry, :bool, default: true
|
38
35
|
|
39
36
|
class MonitorServlet < WEBrick::HTTPServlet::AbstractServlet
|
40
37
|
def initialize(server, agent)
|
@@ -78,24 +75,12 @@ module Fluent
|
|
78
75
|
|
79
76
|
# if ?debug=1 is set, set :with_debug_info for get_monitor_info
|
80
77
|
# and :pretty_json for render_json_error
|
81
|
-
opts = {
|
78
|
+
opts = {}
|
82
79
|
if s = qs['debug'] and s[0]
|
83
80
|
opts[:with_debug_info] = true
|
84
81
|
opts[:pretty_json] = true
|
85
82
|
end
|
86
83
|
|
87
|
-
if ivars = (qs['with_ivars'] || []).first
|
88
|
-
opts[:ivars] = ivars.split(',')
|
89
|
-
end
|
90
|
-
|
91
|
-
if with_config = get_search_parameter(qs, 'with_config'.freeze)
|
92
|
-
opts[:with_config] = Fluent::Config.bool_value(with_config)
|
93
|
-
end
|
94
|
-
|
95
|
-
if with_retry = get_search_parameter(qs, 'with_retry'.freeze)
|
96
|
-
opts[:with_retry] = Fluent::Config.bool_value(with_retry)
|
97
|
-
end
|
98
|
-
|
99
84
|
if tag = get_search_parameter(qs, 'tag'.freeze)
|
100
85
|
# ?tag= to search an output plugin by match pattern
|
101
86
|
if obj = @agent.plugin_info_by_tag(tag, opts)
|
@@ -250,6 +235,8 @@ module Fluent
|
|
250
235
|
end
|
251
236
|
|
252
237
|
def start
|
238
|
+
super
|
239
|
+
|
253
240
|
log.debug "listening monitoring http server on http://#{@bind}:#{@port}/api/plugins"
|
254
241
|
@srv = WEBrick::HTTPServer.new({
|
255
242
|
BindAddress: @bind,
|
@@ -268,7 +255,7 @@ module Fluent
|
|
268
255
|
log.debug "tag parameter is specified. Emit plugins info to '#{@tag}'"
|
269
256
|
|
270
257
|
@loop = Coolio::Loop.new
|
271
|
-
opts = {with_config:
|
258
|
+
opts = {with_config: false}
|
272
259
|
timer = TimerWatcher.new(@emit_interval, log) {
|
273
260
|
es = MultiEventStream.new
|
274
261
|
now = Engine.now
|
@@ -305,12 +292,14 @@ module Fluent
|
|
305
292
|
@thread_for_emit.join
|
306
293
|
@thread_for_emit = nil
|
307
294
|
end
|
295
|
+
|
296
|
+
super
|
308
297
|
end
|
309
298
|
|
310
299
|
MONITOR_INFO = {
|
311
|
-
'output_plugin' => 'is_a?(::Fluent::Output)',
|
312
|
-
'buffer_queue_length' => '@buffer.
|
313
|
-
'buffer_total_queued_size' => '@buffer.
|
300
|
+
'output_plugin' => 'is_a?(::Fluent::Plugin::Output)',
|
301
|
+
'buffer_queue_length' => '@buffer.queue.size',
|
302
|
+
'buffer_total_queued_size' => '@buffer.stage_size + @buffer.queue_size',
|
314
303
|
'retry_count' => '@num_errors',
|
315
304
|
}
|
316
305
|
|
@@ -379,7 +368,7 @@ module Fluent
|
|
379
368
|
# multiple plugins could have the same type
|
380
369
|
def plugins_info_by_type(type, opts={})
|
381
370
|
array = all_plugins.select {|pe|
|
382
|
-
(pe.config['@type'] == type
|
371
|
+
(pe.config['@type'] == type) rescue nil
|
383
372
|
}
|
384
373
|
array.map {|pe|
|
385
374
|
get_monitor_info(pe, opts)
|
@@ -394,7 +383,6 @@ module Fluent
|
|
394
383
|
|
395
384
|
# TODO: use %i() after drop ruby v1.9.3 support.
|
396
385
|
IGNORE_ATTRIBUTES = %W(@config_root_section @config @masked_config).map(&:to_sym)
|
397
|
-
EMPTY_RESULT = {}
|
398
386
|
|
399
387
|
# get monitor info from the plugin `pe` and return a hash object
|
400
388
|
def get_monitor_info(pe, opts={})
|
@@ -403,8 +391,8 @@ module Fluent
|
|
403
391
|
# Common plugin information
|
404
392
|
obj['plugin_id'] = pe.plugin_id
|
405
393
|
obj['plugin_category'] = plugin_category(pe)
|
406
|
-
obj['type'] = pe.config['@type']
|
407
|
-
obj['config'] = pe.config if opts[:with_config]
|
394
|
+
obj['type'] = pe.config['@type']
|
395
|
+
obj['config'] = pe.config if !opts.has_key?(:with_config) || opts[:with_config]
|
408
396
|
|
409
397
|
# run MONITOR_INFO in plugins' instance context and store the info to obj
|
410
398
|
MONITOR_INFO.each_pair {|key,code|
|
@@ -414,13 +402,6 @@ module Fluent
|
|
414
402
|
end
|
415
403
|
}
|
416
404
|
|
417
|
-
if opts[:with_retry]
|
418
|
-
num_errors = pe.instance_variable_get(:@num_errors)
|
419
|
-
if num_errors
|
420
|
-
obj['retry'] = num_errors.zero? ? EMPTY_RESULT : get_retry_info(pe, num_errors)
|
421
|
-
end
|
422
|
-
end
|
423
|
-
|
424
405
|
# include all instance variables if :with_debug_info is set
|
425
406
|
if opts[:with_debug_info]
|
426
407
|
iv = {}
|
@@ -432,32 +413,18 @@ module Fluent
|
|
432
413
|
}
|
433
414
|
end
|
434
415
|
obj['instance_variables'] = iv
|
435
|
-
elsif ivars = opts[:ivars]
|
436
|
-
iv = {}
|
437
|
-
ivars.each {|name|
|
438
|
-
iname = "@#{name}"
|
439
|
-
iv[name] = pe.instance_variable_get(iname) if pe.instance_variable_defined?(iname)
|
440
|
-
}
|
441
|
-
obj['instance_variables'] = iv
|
442
416
|
end
|
443
417
|
|
444
418
|
obj
|
445
419
|
end
|
446
420
|
|
447
|
-
def get_retry_info(pe, num_errors)
|
448
|
-
retry_variables = {}
|
449
|
-
retry_variables['steps'] = num_errors
|
450
|
-
retry_variables['next_time'] = Time.at(pe.instance_variable_get('@next_retry_time'.freeze))
|
451
|
-
retry_variables
|
452
|
-
end
|
453
|
-
|
454
421
|
def plugin_category(pe)
|
455
422
|
case pe
|
456
|
-
when Fluent::Input
|
423
|
+
when Fluent::Plugin::Input
|
457
424
|
'input'.freeze
|
458
|
-
when Fluent::Output
|
425
|
+
when Fluent::Plugin::Output, Fluent::Plugin::BareOutput
|
459
426
|
'output'.freeze
|
460
|
-
when Fluent::Filter
|
427
|
+
when Fluent::Plugin::Filter
|
461
428
|
'filter'.freeze
|
462
429
|
else
|
463
430
|
'unknown'.freeze
|
@@ -52,6 +52,8 @@ module Fluent
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def start
|
55
|
+
super
|
56
|
+
|
55
57
|
@loop = Coolio::Loop.new
|
56
58
|
@timer = TimerWatcher.new(@emit_interval, true, log, &method(:on_timer))
|
57
59
|
@loop.attach(@timer)
|
@@ -62,6 +64,8 @@ module Fluent
|
|
62
64
|
@loop.watchers.each {|w| w.detach }
|
63
65
|
@loop.stop
|
64
66
|
@thread.join
|
67
|
+
|
68
|
+
super
|
65
69
|
end
|
66
70
|
|
67
71
|
def run
|
@@ -115,7 +119,8 @@ module Fluent
|
|
115
119
|
|
116
120
|
router.emit(@tag, now, record)
|
117
121
|
rescue => e
|
118
|
-
log.error "object space failed to emit", error: e
|
122
|
+
log.error "object space failed to emit", error: e, tag: @tag, record: Yajl.dump(record)
|
123
|
+
log.error_backtrace
|
119
124
|
end
|
120
125
|
end
|
121
126
|
end
|
@@ -35,6 +35,8 @@ module Fluent
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def start
|
38
|
+
super
|
39
|
+
|
38
40
|
@loop = Coolio::Loop.new
|
39
41
|
@lsock = listen
|
40
42
|
@loop.attach(@lsock)
|
@@ -46,6 +48,8 @@ module Fluent
|
|
46
48
|
@loop.stop
|
47
49
|
@lsock.close
|
48
50
|
@thread.join
|
51
|
+
|
52
|
+
super
|
49
53
|
end
|
50
54
|
|
51
55
|
#def listen
|
@@ -96,8 +100,8 @@ module Fluent
|
|
96
100
|
entries.each {|e|
|
97
101
|
record = e[1]
|
98
102
|
next if record.nil?
|
99
|
-
time = e[0]
|
100
|
-
time = (now ||= Engine.now) if time == 0
|
103
|
+
time = e[0]
|
104
|
+
time = (now ||= Engine.now) if time.to_i == 0
|
101
105
|
es.add(time, record)
|
102
106
|
}
|
103
107
|
router.emit_stream(tag, es)
|
@@ -108,7 +112,7 @@ module Fluent
|
|
108
112
|
return if record.nil?
|
109
113
|
|
110
114
|
time = msg[1]
|
111
|
-
time = Engine.now if time == 0
|
115
|
+
time = Engine.now if time.to_i == 0
|
112
116
|
router.emit(tag, time, record)
|
113
117
|
end
|
114
118
|
end
|
@@ -88,72 +88,36 @@ module Fluent
|
|
88
88
|
end
|
89
89
|
end
|
90
90
|
desc 'If true, add source host to event record.'
|
91
|
-
config_param :include_source_host, :bool, default: false
|
91
|
+
config_param :include_source_host, :bool, default: false
|
92
92
|
desc 'Specify key of source host when include_source_host is true.'
|
93
|
-
config_param :source_host_key, :string, default: 'source_host'.freeze
|
94
|
-
desc "The field name of the client's hostname."
|
95
|
-
config_param :source_hostname_key, :string, default: nil
|
96
|
-
desc "The field name of the client's source address."
|
97
|
-
config_param :source_address_key, :string, default: nil
|
98
|
-
desc 'Try to resolve hostname from IP addresses or not.'
|
99
|
-
config_param :resolve_hostname, :bool, default: nil
|
100
|
-
desc 'The field name of the priority.'
|
101
|
-
config_param :priority_key, :string, default: nil
|
102
|
-
desc 'The field name of the facility.'
|
103
|
-
config_param :facility_key, :string, default: nil
|
104
|
-
desc "The max bytes of message"
|
105
|
-
config_param :message_length_limit, :size, default: 2048
|
93
|
+
config_param :source_host_key, :string, default: 'source_host'.freeze
|
106
94
|
config_param :blocking_timeout, :time, default: 0.5
|
107
95
|
|
108
|
-
desc 'If true, accept syslog message without PRI part'
|
109
|
-
config_param :allow_without_priority, :bool, default: false
|
110
|
-
# 13 is the default value of rsyslog and syslog-ng
|
111
|
-
desc 'The default PRI value (0 - 191 are available)'
|
112
|
-
config_param :default_priority, :integer, default: 13
|
113
|
-
|
114
96
|
def configure(conf)
|
115
97
|
super
|
116
98
|
|
117
|
-
|
118
|
-
raise ConfigError, "default_priority must be 0 ~ 191"
|
119
|
-
end
|
120
|
-
|
121
|
-
if @allow_without_priority && conf['message_format'] == 'auto'
|
122
|
-
raise ConfigError, "message_format auto isn't allowed when allow_without_priority is true"
|
123
|
-
end
|
99
|
+
@use_default = false
|
124
100
|
|
125
|
-
conf['with_priority'] = !@allow_without_priority
|
126
101
|
if conf.has_key?('format')
|
127
102
|
@parser = Plugin.new_parser(conf['format'])
|
128
103
|
@parser.configure(conf)
|
129
104
|
else
|
105
|
+
conf['with_priority'] = true
|
130
106
|
@parser = TextParser::SyslogParser.new
|
131
107
|
@parser.configure(conf)
|
132
108
|
@use_default = true
|
133
109
|
end
|
134
|
-
|
135
|
-
if @source_hostname_key.nil? && @include_source_host
|
136
|
-
@source_hostname_key = @source_host_key
|
137
|
-
end
|
138
|
-
if @source_hostname_key
|
139
|
-
if @resolve_hostname.nil?
|
140
|
-
@resolve_hostname = true
|
141
|
-
elsif !@resolve_hostname # user specifies "false" in configure
|
142
|
-
raise Fluent::ConfigError, "resolve_hostname must be true with source_hostname_key"
|
143
|
-
end
|
144
|
-
end
|
145
110
|
end
|
146
111
|
|
147
112
|
def start
|
148
|
-
|
149
|
-
|
113
|
+
super
|
114
|
+
|
115
|
+
callback = if @use_default
|
116
|
+
method(:receive_data)
|
150
117
|
else
|
151
|
-
|
152
|
-
method(:receive_data_default)
|
153
|
-
else
|
154
|
-
method(:receive_data_with_format)
|
155
|
-
end
|
118
|
+
method(:receive_data_parser)
|
156
119
|
end
|
120
|
+
|
157
121
|
@loop = Coolio::Loop.new
|
158
122
|
@handler = listen(callback)
|
159
123
|
@loop.attach(@handler)
|
@@ -166,6 +130,8 @@ module Fluent
|
|
166
130
|
@loop.stop
|
167
131
|
@handler.close
|
168
132
|
@thread.join
|
133
|
+
|
134
|
+
super
|
169
135
|
end
|
170
136
|
|
171
137
|
def run
|
@@ -177,16 +143,7 @@ module Fluent
|
|
177
143
|
|
178
144
|
private
|
179
145
|
|
180
|
-
|
181
|
-
def receive_data_default(data, addr)
|
182
|
-
parse_text(data, addr)
|
183
|
-
rescue => e
|
184
|
-
log.error data.dump, error: e.to_s
|
185
|
-
log.error_backtrace
|
186
|
-
end
|
187
|
-
|
188
|
-
## PRI part parser + custom parser without PRI part
|
189
|
-
def receive_data_with_format(data, addr)
|
146
|
+
def receive_data_parser(data, addr)
|
190
147
|
m = SYSLOG_REGEXP.match(data)
|
191
148
|
unless m
|
192
149
|
log.warn "invalid syslog message: #{data.dump}"
|
@@ -195,70 +152,64 @@ module Fluent
|
|
195
152
|
pri = m[1].to_i
|
196
153
|
text = m[2]
|
197
154
|
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
## PRI part parser + SyslogParser without PRI part | custom parser without PRI part
|
205
|
-
def receive_data_allow_without_priority(data, addr)
|
206
|
-
m = SYSLOG_REGEXP.match(data)
|
207
|
-
if m
|
208
|
-
pri = m[1].to_i
|
209
|
-
text = m[2]
|
210
|
-
else
|
211
|
-
pri = @default_priority
|
212
|
-
text = data
|
213
|
-
end
|
155
|
+
@parser.parse(text) { |time, record|
|
156
|
+
unless time && record
|
157
|
+
log.warn "pattern not match: #{text.inspect}"
|
158
|
+
return
|
159
|
+
end
|
214
160
|
|
215
|
-
|
161
|
+
record[@source_host_key] = addr[2] if @include_source_host
|
162
|
+
emit(pri, time, record)
|
163
|
+
}
|
216
164
|
rescue => e
|
217
165
|
log.error data.dump, error: e.to_s
|
218
166
|
log.error_backtrace
|
219
167
|
end
|
220
168
|
|
221
|
-
def
|
222
|
-
@parser.parse(
|
169
|
+
def receive_data(data, addr)
|
170
|
+
@parser.parse(data) { |time, record|
|
223
171
|
unless time && record
|
224
|
-
log.warn "
|
172
|
+
log.warn "invalid syslog message", data: data
|
225
173
|
return
|
226
174
|
end
|
227
175
|
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
facility = FACILITY_MAP[pri >> 3]
|
232
|
-
priority = PRIORITY_MAP[pri & 0b111]
|
233
|
-
|
234
|
-
record[@priority_key] = priority if @priority_key
|
235
|
-
record[@facility_key] = facility if @facility_key
|
236
|
-
record[@source_hostname_key] = addr[2] if @source_hostname_key
|
237
|
-
record[@source_address_key] = addr[3] if @source_address_key
|
238
|
-
|
239
|
-
tag = "#{@tag}.#{facility}.#{priority}"
|
240
|
-
emit(tag, time, record)
|
176
|
+
pri = record.delete('pri')
|
177
|
+
record[@source_host_key] = addr[2] if @include_source_host
|
178
|
+
emit(pri, time, record)
|
241
179
|
}
|
180
|
+
rescue => e
|
181
|
+
log.error data.dump, error: e.to_s
|
182
|
+
log.error_backtrace
|
242
183
|
end
|
243
184
|
|
244
185
|
private
|
245
186
|
|
246
187
|
def listen(callback)
|
247
188
|
log.info "listening syslog socket on #{@bind}:#{@port} with #{@protocol_type}"
|
189
|
+
socket_manager_path = ENV['SERVERENGINE_SOCKETMANAGER_PATH']
|
190
|
+
if Fluent.windows?
|
191
|
+
socket_manager_path = socket_manager_path.to_i
|
192
|
+
end
|
193
|
+
client = ServerEngine::SocketManager::Client.new(socket_manager_path)
|
248
194
|
if @protocol_type == :udp
|
249
|
-
@usock =
|
250
|
-
|
251
|
-
SocketUtil::UdpHandler.new(@usock, log, @message_length_limit, callback, @resolve_hostname)
|
195
|
+
@usock = client.listen_udp(@bind, @port)
|
196
|
+
SocketUtil::UdpHandler.new(@usock, log, 2048, callback)
|
252
197
|
else
|
253
198
|
# syslog family add "\n" to each message and this seems only way to split messages in tcp stream
|
254
|
-
|
199
|
+
lsock = client.listen_tcp(@bind, @port)
|
200
|
+
Coolio::TCPServer.new(lsock, nil, SocketUtil::TcpHandler, log, "\n", callback)
|
255
201
|
end
|
256
202
|
end
|
257
203
|
|
258
|
-
def emit(
|
204
|
+
def emit(pri, time, record)
|
205
|
+
facility = FACILITY_MAP[pri >> 3]
|
206
|
+
priority = PRIORITY_MAP[pri & 0b111]
|
207
|
+
|
208
|
+
tag = "#{@tag}.#{facility}.#{priority}"
|
209
|
+
|
259
210
|
router.emit(tag, time, record)
|
260
211
|
rescue => e
|
261
|
-
log.error "syslog failed to emit", error: e
|
212
|
+
log.error "syslog failed to emit", error: e, tag: tag, record: Yajl.dump(record)
|
262
213
|
end
|
263
214
|
end
|
264
215
|
end
|