fluentd 0.14.14 → 0.14.15

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 55d7fb0ec7d40340b7c151ecd199d111ce6900d8
4
- data.tar.gz: 69a6ca966e185eb804a882e18ddd4888eba7f468
3
+ metadata.gz: 3f2a4f15bf32737020c69883079694ad81648cff
4
+ data.tar.gz: 142851ddfb0483e49bc1b71aed6e7e98db295c34
5
5
  SHA512:
6
- metadata.gz: 953c3799e0101162f11710cf798a2cae19257430ae4a6086b8029dd95c6d8b1ee003bcf9d47a15b18a81c46b591d02b08f2be053d0a403d5d249fc9d2dc37100
7
- data.tar.gz: e9d9297f25744020754a78ad9fc552a994eeec9798948e007a1bb290b99438645a7b954ab7389043b4a0cf011aa068385b6f6e7c0a53b46d204ad037b875bc90
6
+ metadata.gz: ad5bcad4d26b4cfaa59b7b59c5100cfe0a651206dbadfb0b519369f8b095951bf68f45c8df67dd6954bdb8fc64a714cd4911063f9c5eebb9d963ebd7dd71af4f
7
+ data.tar.gz: c38a2498db6ea742f50103beca1e9c4f8e19fd1f811e84152a2d7679d0225edb65f1cb7e75975f414ec0ea5343a4ca2f2342f233b55bcd4969bfcf481260ec26
data/ChangeLog CHANGED
@@ -1,5 +1,33 @@
1
1
  # v0.14
2
2
 
3
+ ## Release v0.14.15 - 2017/04/23
4
+
5
+ ### New features / Enhancements
6
+
7
+ * Add <worker N> directive
8
+ https://github.com/fluent/fluentd/pull/1507
9
+ * in_tail: Do not warn that directories are unreadable in the in_tail plugin
10
+ https://github.com/fluent/fluentd/pull/1540
11
+ * output: Add formatted_to_msgpack_binary? to Output plugin API
12
+ https://github.com/fluent/fluentd/pull/1547
13
+ * windows: Allow the Windows Service name Fluentd runs as to be configurable
14
+ https://github.com/fluent/fluentd/pull/1548
15
+
16
+ ### Bug fixes
17
+
18
+ * in_http: Fix X-Forwarded-For header handling. Accpet multiple headers
19
+ https://github.com/fluent/fluentd/pull/1535
20
+ * Fix backward compatibility with Fluent::DetachProcess and Fluent::DetachMultiProcess
21
+ https://github.com/fluent/fluentd/pull/1522
22
+ * fix typo
23
+ https://github.com/fluent/fluentd/pull/1521
24
+ https://github.com/fluent/fluentd/pull/1523
25
+ https://github.com/fluent/fluentd/pull/1544
26
+ * test: Fix out_file test with timezone
27
+ https://github.com/fluent/fluentd/pull/1546
28
+ * windows: Quote the file path to the Ruby bin directory when starting fluentd as a windows service
29
+ https://github.com/fluent/fluentd/pull/1536
30
+
3
31
  ## Release v0.14.14 - 2017/03/23
4
32
 
5
33
  ### New features / Enhancements
@@ -0,0 +1,36 @@
1
+ <system>
2
+ workers 4
3
+ root_dir /path/fluentd/root
4
+ </system>
5
+
6
+ <source> # top-level sections works on all workers in parallel
7
+ @type forward
8
+ port 24224
9
+ </source>
10
+
11
+ <match all> # this sections also works on all workers in parallel
12
+ @type stdout
13
+ <inject>
14
+ worker_id_key worker_id
15
+ </inject>
16
+ </match>
17
+
18
+ <worker 0> # this section works only on first worker process
19
+ <source>
20
+ @type tail
21
+ format none
22
+ path /var/log/fluentd_test.log
23
+ pos_file /var/log/fluentd_test.pos
24
+ tag tail
25
+ rotate_wait 5
26
+ read_from_head true
27
+ refresh_interval 60
28
+ </source>
29
+
30
+ <match tail>
31
+ @type stdout
32
+ <inject>
33
+ worker_id_key worker_id
34
+ </inject>
35
+ </match>
36
+ </worker>
data/lib/fluent/agent.rb CHANGED
@@ -62,6 +62,7 @@ module Fluent
62
62
 
63
63
  # initialize <match> and <filter> elements
64
64
  conf.elements('filter', 'match').each { |e|
65
+ next if e.for_another_worker?
65
66
  pattern = e.arg.empty? ? '**' : e.arg
66
67
  type = e['@type']
67
68
  raise ConfigError, "Missing '@type' parameter on <#{e.name}> directive" unless type
@@ -121,7 +122,8 @@ module Fluent
121
122
  end
122
123
 
123
124
  def add_match(type, pattern, conf)
124
- log.info :worker0, "adding match#{@context.nil? ? '' : " in #{@context}"}", pattern: pattern, type: type
125
+ log_type = conf.for_this_worker? ? :default : :worker0
126
+ log.info log_type, "adding match#{@context.nil? ? '' : " in #{@context}"}", pattern: pattern, type: type
125
127
 
126
128
  output = Plugin.new_output(type)
127
129
  output.context_router = @event_router
@@ -142,7 +144,8 @@ module Fluent
142
144
  end
143
145
 
144
146
  def add_filter(type, pattern, conf)
145
- log.info :worker0, "adding filter#{@context.nil? ? '' : " in #{@context}"}", pattern: pattern, type: type
147
+ log_type = conf.for_this_worker? ? :default : :worker0
148
+ log.info log_type, "adding filter#{@context.nil? ? '' : " in #{@context}"}", pattern: pattern, type: type
146
149
 
147
150
  filter = Plugin.new_filter(type)
148
151
  filter.context_router = @event_router
@@ -158,6 +158,12 @@ op.on('-G', '--gem-path GEM_INSTALL_PATH', "Gemfile install path (default: $(dir
158
158
  if Fluent.windows?
159
159
  require 'windows/library'
160
160
  include Windows::Library
161
+
162
+ opts.merge!(
163
+ :winsvc_name => 'fluentdwinsvc',
164
+ :winsvc_display_name => 'Fluentd Windows Service',
165
+ :winsvc_desc => 'Fluentd is an event collector system.',
166
+ )
161
167
 
162
168
  op.on('-x', '--signame INTSIGNAME', "an object name which is used for Windows Service signal (Windows only)") {|s|
163
169
  opts[:signame] = s
@@ -174,6 +180,18 @@ if Fluent.windows?
174
180
  op.on('--reg-winsvc-fluentdopt OPTION', "specify fluentd option paramters for Windows Service. (Windows only)") {|s|
175
181
  opts[:fluentdopt] = s
176
182
  }
183
+
184
+ op.on('--winsvc-name NAME', "The Windows Service name to run as (Windows only)") {|s|
185
+ opts[:winsvc_name] = s
186
+ }
187
+
188
+ op.on('--winsvc-display-name DISPLAY_NAME', "The Windows Service display name (Windows only)") {|s|
189
+ opts[:winsvc_display_name] = s
190
+ }
191
+
192
+ op.on('--winsvc-desc DESC', "The Windows Service description (Windows only)") {|s|
193
+ opts[:winsvc_desc] = s
194
+ }
177
195
  end
178
196
 
179
197
 
@@ -229,9 +247,6 @@ end
229
247
  early_exit = false
230
248
  start_service = false
231
249
  if winsvcinstmode = opts[:regwinsvc]
232
- FLUENTD_WINSVC_NAME="fluentdwinsvc"
233
- FLUENTD_WINSVC_DISPLAYNAME="Fluentd Windows Service"
234
- FLUENTD_WINSVC_DESC="Fluentd is an event collector system."
235
250
  require 'fileutils'
236
251
  require "win32/service"
237
252
  require "win32/registry"
@@ -249,27 +264,28 @@ if winsvcinstmode = opts[:regwinsvc]
249
264
  start_service = true
250
265
  end
251
266
 
267
+
252
268
  Service.create(
253
- service_name: FLUENTD_WINSVC_NAME,
269
+ service_name: opts[:winsvc_name],
254
270
  host: nil,
255
271
  service_type: Service::WIN32_OWN_PROCESS,
256
- description: FLUENTD_WINSVC_DESC,
272
+ description: opts[:winsvc_desc],
257
273
  start_type: start_type,
258
274
  error_control: Service::ERROR_NORMAL,
259
- binary_path_name: ruby_path+" -C "+binary_path+" winsvc.rb",
275
+ binary_path_name: "\"#{ruby_path}\" -C \"#{binary_path}\" winsvc.rb --service-name #{opts[:winsvc_name]}",
260
276
  load_order_group: "",
261
277
  dependencies: [""],
262
- display_name: FLUENTD_WINSVC_DISPLAYNAME
278
+ display_name: opts[:winsvc_display_name]
263
279
  )
264
280
  when 'u'
265
- if Service.status(FLUENTD_WINSVC_NAME).current_state != 'stopped'
281
+ if Service.status(opts[:winsvc_name]).current_state != 'stopped'
266
282
  begin
267
- Service.stop(FLUENTD_WINSVC_NAME)
283
+ Service.stop(opts[:winsvc_name])
268
284
  rescue => ex
269
285
  puts "Warning: Failed to stop service: ", ex
270
286
  end
271
287
  end
272
- Service.delete(FLUENTD_WINSVC_NAME)
288
+ Service.delete(opts[:winsvc_name])
273
289
  else
274
290
  # none
275
291
  end
@@ -277,14 +293,14 @@ if winsvcinstmode = opts[:regwinsvc]
277
293
  end
278
294
 
279
295
  if fluentdopt = opts[:fluentdopt]
280
- Win32::Registry::HKEY_LOCAL_MACHINE.open("SYSTEM\\CurrentControlSet\\Services\\fluentdwinsvc", Win32::Registry::KEY_ALL_ACCESS) do |reg|
296
+ Win32::Registry::HKEY_LOCAL_MACHINE.open("SYSTEM\\CurrentControlSet\\Services\\#{opts[:winsvc_name]}", Win32::Registry::KEY_ALL_ACCESS) do |reg|
281
297
  reg['fluentdopt', Win32::Registry::REG_SZ] = fluentdopt
282
298
  end
283
299
  early_exit = true
284
300
  end
285
301
 
286
302
  if start_service
287
- Service.start(FLUENTD_WINSVC_NAME)
303
+ Service.start(opts[:winsvc_name])
288
304
  end
289
305
 
290
306
  exit 0 if early_exit
@@ -227,7 +227,7 @@ BANNER
227
227
  \tY - yes, overwrite
228
228
  \tn - no, do not overwrite
229
229
  \ta - all, overwrite this and all others
230
- \tq - quite, abort
230
+ \tq - quit, abort
231
231
  \th - help, show this help
232
232
  HELP
233
233
  end
@@ -17,9 +17,17 @@
17
17
  module Fluent
18
18
  module Compat
19
19
  module DetachProcessMixin
20
+ def detach_process
21
+ log.warn "#{__method__} is not supported in this version. ignored."
22
+ yield
23
+ end
20
24
  end
21
25
 
22
26
  module DetachMultiProcessMixin
27
+ def detach_multi_process
28
+ log.warn "#{__method__} is not supported in this version. ignored."
29
+ yield
30
+ end
23
31
  end
24
32
  end
25
33
  end
@@ -44,16 +44,6 @@ module Fluent
44
44
  def shutdown
45
45
  super
46
46
  end
47
-
48
- def detach_process(&block)
49
- log.warn "detach_process is not supported in this version. ignored."
50
- block.call
51
- end
52
-
53
- def detach_multi_process(&block)
54
- log.warn "detach_process is not supported in this version. ignored."
55
- block.call
56
- end
57
47
  end
58
48
  end
59
49
  end
@@ -190,16 +190,6 @@ module Fluent
190
190
  end
191
191
  end
192
192
  end
193
-
194
- def detach_process(&block)
195
- log.warn "detach_process is not supported in this version. ignored."
196
- block.call
197
- end
198
-
199
- def detach_multi_process(&block)
200
- log.warn "detach_process is not supported in this version. ignored."
201
- block.call
202
- end
203
193
  end
204
194
 
205
195
  class MultiOutput < Fluent::Plugin::BareOutput
@@ -35,10 +35,13 @@ module Fluent
35
35
 
36
36
  # it's global logger, not plugin logger: deprecated message should be global warning, not plugin level.
37
37
  @logger = defined?($log) ? $log : nil
38
+
39
+ @target_worker_id = nil
38
40
  end
39
41
 
40
42
  attr_accessor :name, :arg, :unused, :v1_config, :corresponding_proxies, :unused_in
41
43
  attr_writer :elements
44
+ attr_reader :target_worker_id
42
45
 
43
46
  RESERVED_PARAMETERS_COMPAT = {
44
47
  '@type' => 'type',
@@ -213,6 +216,25 @@ module Fluent
213
216
  v.each_char { |c| result << LiteralParser.unescape_char(c) }
214
217
  result
215
218
  end
219
+
220
+ def set_target_worker_id(worker_id)
221
+ @target_worker_id = worker_id
222
+ @elements.each { |e|
223
+ e.set_target_worker_id(worker_id)
224
+ }
225
+ end
226
+
227
+ def for_every_workers?
228
+ @target_worker_id == nil
229
+ end
230
+
231
+ def for_this_worker?
232
+ @target_worker_id == Fluent::Engine.worker_id
233
+ end
234
+
235
+ def for_another_worker?
236
+ @target_worker_id != nil && @target_worker_id != Fluent::Engine.worker_id
237
+ end
216
238
  end
217
239
  end
218
240
  end
data/lib/fluent/engine.rb CHANGED
@@ -31,6 +31,7 @@ module Fluent
31
31
  @root_agent = nil
32
32
  @default_loop = nil
33
33
  @engine_stopped = false
34
+ @_worker_id = nil
34
35
 
35
36
  @log_event_router = nil
36
37
  @log_emit_thread = nil
@@ -97,12 +98,21 @@ module Fluent
97
98
  else
98
99
  "section <#{e.name}> is not used in <#{parent_name}>"
99
100
  end
100
- $log.warn :worker0, message
101
+ if e.for_every_workers?
102
+ $log.warn :worker0, message
103
+ elsif e.for_this_worker?
104
+ $log.warn message
105
+ end
101
106
  next
102
107
  end
103
108
  unless e.name == 'system'
104
109
  unless @without_source && e.name == 'source'
105
- $log.warn :worker0, "parameter '#{key}' in #{e.to_s.strip} is not used."
110
+ message = "parameter '#{key}' in #{e.to_s.strip} is not used."
111
+ if e.for_every_workers?
112
+ $log.warn :worker0, message
113
+ elsif e.for_this_worker?
114
+ $log.warn message
115
+ end
106
116
  end
107
117
  end
108
118
  }
@@ -128,7 +138,7 @@ module Fluent
128
138
 
129
139
  unmatched_tags = Fluent::Log.event_tags.select{|t| !@log_event_router.match?(t) }
130
140
  unless unmatched_tags.empty?
131
- $log.warn :worker0, "match for some tags of log events are not defined (to be ignored)", tags: unmatched_tags
141
+ $log.warn "match for some tags of log events are not defined (to be ignored)", tags: unmatched_tags
132
142
  end
133
143
  rescue ArgumentError # ArgumentError "#{label_name} label not found"
134
144
  # use default event router if <label @FLUENT_LOG> is missing in configuration
@@ -139,7 +149,7 @@ module Fluent
139
149
 
140
150
  unmatched_tags = Fluent::Log.event_tags.select{|t| !@log_event_router.match?(t) }
141
151
  unless unmatched_tags.empty?
142
- $log.warn :worker0, "match for some tags of log events are not defined (to be ignored)", tags: unmatched_tags
152
+ $log.warn "match for some tags of log events are not defined (to be ignored)", tags: unmatched_tags
143
153
  end
144
154
  end
145
155
  end
@@ -200,10 +210,6 @@ module Fluent
200
210
  end
201
211
 
202
212
  def run
203
- # if ENV doesn't have SERVERENGINE_WORKER_ID, it is a worker under --no-supervisor or in tests
204
- # so it's (almost) a single worker, worker_id=0
205
- worker_id = (ENV['SERVERENGINE_WORKER_ID'] || 0).to_i
206
-
207
213
  begin
208
214
  $log.info "starting fluentd worker", pid: Process.pid, ppid: Process.ppid, worker: worker_id
209
215
  start
@@ -251,8 +257,15 @@ module Fluent
251
257
  @log_event_queue.push([tag, time, record])
252
258
  end
253
259
 
254
- private
260
+ def worker_id
261
+ return @_worker_id if @_worker_id
262
+ # if ENV doesn't have SERVERENGINE_WORKER_ID, it is a worker under --no-supervisor or in tests
263
+ # so it's (almost) a single worker, worker_id=0
264
+ @_worker_id = (ENV['SERVERENGINE_WORKER_ID'] || 0).to_i
265
+ @_worker_id
266
+ end
255
267
 
268
+ private
256
269
  def start
257
270
  @root_agent.start
258
271
  end
@@ -51,6 +51,9 @@ module Fluent
51
51
  end
52
52
 
53
53
  def configure(conf)
54
+ if conf.respond_to?(:for_this_worker?) && conf.for_this_worker?
55
+ system_config_override(workers: 1)
56
+ end
54
57
  super
55
58
  @_state ||= State.new(false, false, false, false, false, false, false, false, false)
56
59
  @_state.configure = true
@@ -79,13 +79,13 @@ module Fluent
79
79
  return nil if implmented_methods.include?(:filter_stream)
80
80
  case
81
81
  when [:filter, :filter_with_time].all? { |e| implmented_methods.include?(e) }
82
- raise "BUG: Filter plugins MUST be implemented either `filter` or `filter_with_time`"
82
+ raise "BUG: Filter plugins MUST implement either `filter` or `filter_with_time`"
83
83
  when implmented_methods.include?(:filter)
84
84
  false
85
85
  when implmented_methods.include?(:filter_with_time)
86
86
  true
87
87
  else
88
- raise NotImplementedError, "BUG: Filter plugins MUST be implmented either `filter` or `filter_with_time`"
88
+ raise NotImplementedError, "BUG: Filter plugins MUST implement either `filter` or `filter_with_time`"
89
89
  end
90
90
  end
91
91
  end
@@ -319,6 +319,8 @@ module Fluent::Plugin
319
319
  when /Origin/i
320
320
  @origin = v
321
321
  when /X-Forwarded-For/i
322
+ # For multiple X-Forwarded-For headers. Use first header value.
323
+ v = v.first if v.is_a?(Array)
322
324
  @remote_addr = v.split(",").first
323
325
  end
324
326
  }
@@ -189,14 +189,17 @@ module Fluent::Plugin
189
189
  path = date.strftime(path)
190
190
  if path.include?('*')
191
191
  paths += Dir.glob(path).select { |p|
192
- if File.readable?(p) && !File.directory?(p)
192
+ is_file = !File.directory?(p)
193
+ if File.readable?(p) && is_file
193
194
  if @limit_recently_modified && File.mtime(p) < (date - @limit_recently_modified)
194
195
  false
195
196
  else
196
197
  true
197
198
  end
198
199
  else
199
- log.warn "#{p} unreadable. It is excluded and would be examined next time."
200
+ if is_file
201
+ log.warn "#{p} unreadable. It is excluded and would be examined next time."
202
+ end
200
203
  false
201
204
  end
202
205
  }