fluentd 0.14.1 → 0.14.2
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/ChangeLog +110 -1
- data/Rakefile +5 -1
- data/appveyor.yml +7 -1
- data/example/in_forward.conf +4 -0
- data/lib/fluent/compat/exec_util.rb +129 -0
- data/lib/fluent/compat/file_util.rb +54 -0
- data/lib/fluent/compat/filter.rb +21 -3
- data/lib/fluent/compat/formatter.rb +4 -2
- data/lib/fluent/compat/formatter_utils.rb +85 -0
- data/lib/fluent/compat/handle_tag_and_time_mixin.rb +60 -0
- data/lib/fluent/compat/input.rb +1 -3
- data/lib/fluent/compat/output.rb +95 -39
- data/lib/fluent/compat/parser.rb +17 -0
- data/lib/fluent/compat/parser_utils.rb +40 -0
- data/lib/fluent/compat/socket_util.rb +165 -0
- data/lib/fluent/compat/string_util.rb +34 -0
- data/lib/fluent/{test/driver/owner.rb → compat/structured_format_mixin.rb} +5 -11
- data/lib/fluent/config/element.rb +2 -2
- data/lib/fluent/configurable.rb +2 -1
- data/lib/fluent/event.rb +61 -7
- data/lib/fluent/event_router.rb +1 -1
- data/lib/fluent/plugin.rb +7 -7
- data/lib/fluent/plugin/buf_file.rb +5 -2
- data/lib/fluent/plugin/buffer.rb +194 -64
- data/lib/fluent/plugin/buffer/chunk.rb +28 -3
- data/lib/fluent/plugin/buffer/file_chunk.rb +5 -21
- data/lib/fluent/plugin/buffer/memory_chunk.rb +1 -11
- data/lib/fluent/plugin/exec_util.rb +2 -112
- data/lib/fluent/plugin/file_util.rb +3 -38
- data/lib/fluent/plugin/file_wrapper.rb +1 -1
- data/lib/fluent/plugin/filter_grep.rb +3 -7
- data/lib/fluent/plugin/filter_record_transformer.rb +5 -5
- data/lib/fluent/plugin/filter_stdout.rb +18 -11
- data/lib/fluent/plugin/formatter.rb +0 -48
- data/lib/fluent/plugin/formatter_csv.rb +7 -8
- data/lib/fluent/plugin/formatter_hash.rb +1 -4
- data/lib/fluent/plugin/formatter_json.rb +1 -4
- data/lib/fluent/plugin/formatter_ltsv.rb +5 -6
- data/lib/fluent/plugin/formatter_msgpack.rb +1 -4
- data/lib/fluent/plugin/formatter_out_file.rb +36 -3
- data/lib/fluent/plugin/formatter_stdout.rb +36 -1
- data/lib/fluent/plugin/in_dummy.rb +9 -2
- data/lib/fluent/plugin/in_exec.rb +20 -57
- data/lib/fluent/plugin/in_forward.rb +4 -3
- data/lib/fluent/plugin/in_object_space.rb +8 -44
- data/lib/fluent/plugin/in_syslog.rb +13 -24
- data/lib/fluent/plugin/in_tail.rb +3 -0
- data/lib/fluent/plugin/out_buffered_stdout.rb +14 -4
- data/lib/fluent/plugin/out_exec.rb +7 -5
- data/lib/fluent/plugin/out_exec_filter.rb +10 -10
- data/lib/fluent/plugin/out_file.rb +1 -3
- data/lib/fluent/plugin/out_forward.rb +38 -57
- data/lib/fluent/plugin/out_stdout.rb +14 -5
- data/lib/fluent/plugin/out_stream.rb +3 -0
- data/lib/fluent/plugin/output.rb +31 -14
- data/lib/fluent/plugin/parser.rb +0 -69
- data/lib/fluent/plugin/parser_apache.rb +10 -6
- data/lib/fluent/plugin/parser_apache_error.rb +8 -3
- data/lib/fluent/plugin/parser_csv.rb +3 -1
- data/lib/fluent/plugin/parser_json.rb +1 -1
- data/lib/fluent/plugin/parser_multiline.rb +5 -3
- data/lib/fluent/plugin/parser_nginx.rb +10 -6
- data/lib/fluent/plugin/parser_regexp.rb +73 -0
- data/lib/fluent/plugin/socket_util.rb +2 -148
- data/lib/fluent/plugin/storage_local.rb +1 -1
- data/lib/fluent/plugin/string_util.rb +3 -18
- data/lib/fluent/plugin_helper.rb +1 -0
- data/lib/fluent/plugin_helper/compat_parameters.rb +166 -41
- data/lib/fluent/plugin_helper/formatter.rb +30 -19
- data/lib/fluent/plugin_helper/inject.rb +25 -12
- data/lib/fluent/plugin_helper/parser.rb +22 -13
- data/lib/fluent/plugin_helper/storage.rb +22 -13
- data/lib/fluent/registry.rb +19 -6
- data/lib/fluent/supervisor.rb +27 -1
- data/lib/fluent/test/driver/base.rb +16 -92
- data/lib/fluent/test/driver/base_owned.rb +17 -53
- data/lib/fluent/test/driver/base_owner.rb +125 -0
- data/lib/fluent/test/driver/filter.rb +24 -2
- data/lib/fluent/test/driver/input.rb +2 -2
- data/lib/fluent/test/driver/multi_output.rb +2 -2
- data/lib/fluent/test/driver/output.rb +3 -5
- data/lib/fluent/test/helpers.rb +25 -0
- data/lib/fluent/test/input_test.rb +4 -4
- data/lib/fluent/test/output_test.rb +3 -3
- data/lib/fluent/version.rb +1 -1
- data/test/config/test_element.rb +135 -6
- data/test/plugin/test_buf_file.rb +71 -3
- data/test/plugin/test_buffer.rb +305 -86
- data/test/plugin/test_buffer_chunk.rb +60 -2
- data/test/plugin/test_buffer_file_chunk.rb +4 -3
- data/test/plugin/test_filter_grep.rb +25 -21
- data/test/plugin/test_filter_record_transformer.rb +75 -67
- data/test/plugin/test_filter_stdout.rb +171 -74
- data/test/plugin/test_formatter_csv.rb +94 -0
- data/test/plugin/test_formatter_json.rb +30 -0
- data/test/plugin/test_formatter_ltsv.rb +52 -0
- data/test/plugin/test_formatter_msgpack.rb +28 -0
- data/test/plugin/test_formatter_out_file.rb +95 -0
- data/test/plugin/test_formatter_single_value.rb +38 -0
- data/test/plugin/test_in_dummy.rb +95 -0
- data/test/plugin/test_in_exec.rb +27 -31
- data/test/plugin/test_in_forward.rb +24 -0
- data/test/plugin/test_in_gc_stat.rb +5 -5
- data/test/plugin/test_in_object_space.rb +4 -4
- data/test/plugin/test_in_syslog.rb +60 -35
- data/test/plugin/test_out_buffered_stdout.rb +17 -3
- data/test/plugin/test_out_forward.rb +93 -5
- data/test/plugin/test_out_stdout.rb +14 -3
- data/test/plugin/test_output_as_buffered_retries.rb +20 -0
- data/test/plugin/test_output_as_buffered_secondary.rb +16 -0
- data/test/plugin/test_output_as_standard.rb +22 -22
- data/test/plugin/test_parser_apache.rb +13 -9
- data/test/plugin/test_parser_apache_error.rb +11 -6
- data/test/plugin/test_parser_csv.rb +35 -25
- data/test/plugin/test_parser_nginx.rb +11 -5
- data/test/plugin/test_parser_regexp.rb +235 -68
- data/test/plugin/test_parser_tsv.rb +54 -58
- data/test/plugin_helper/test_compat_parameters.rb +111 -46
- data/test/plugin_helper/test_formatter.rb +40 -0
- data/test/plugin_helper/test_inject.rb +101 -2
- data/test/plugin_helper/test_parser.rb +40 -0
- data/test/plugin_helper/test_storage.rb +43 -0
- data/test/test_event.rb +93 -0
- data/test/test_event_router.rb +13 -4
- data/test/test_event_time.rb +0 -3
- data/test/test_formatter.rb +7 -164
- data/test/test_plugin_classes.rb +28 -1
- metadata +24 -3
@@ -14,6 +14,7 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
16
|
|
17
|
+
require 'fluent/config/types'
|
17
18
|
require 'fluent/config/element'
|
18
19
|
|
19
20
|
module Fluent
|
@@ -24,7 +25,7 @@ module Fluent
|
|
24
25
|
# This helper is mainly to convert plugins from v0.12 API
|
25
26
|
# to v0.14 API safely, without breaking user deployment.
|
26
27
|
|
27
|
-
|
28
|
+
BUFFER_PARAMS = {
|
28
29
|
"buffer_type" => "@type",
|
29
30
|
"buffer_path" => "path",
|
30
31
|
"num_threads" => "flush_thread_count",
|
@@ -40,59 +41,183 @@ module Fluent
|
|
40
41
|
"flush_at_shutdown" => "flush_at_shutdown",
|
41
42
|
}
|
42
43
|
|
43
|
-
|
44
|
+
BUFFER_TIME_SLICED_PARAMS = {
|
44
45
|
"time_slice_format" => nil,
|
45
46
|
"time_slice_wait" => "timekey_wait",
|
46
47
|
}
|
47
48
|
|
48
|
-
|
49
|
-
|
50
|
-
|
49
|
+
PARSER_PARAMS = {
|
50
|
+
"format" => "@type",
|
51
|
+
"time_key" => "time_key",
|
52
|
+
"time_format" => "time_format",
|
53
|
+
"delimiter" => "delimiter",
|
54
|
+
"json_parser" => "json_parser", # JSONParser
|
55
|
+
"label_delimiter" => "label_delimiter", # LabeledTSVParser
|
56
|
+
"format_firstline" => "format_firstline", # MultilineParser
|
57
|
+
"message_key" => "message_key", # NoneParser
|
58
|
+
"with_priority" => "with_priority", # SyslogParser
|
59
|
+
}
|
60
|
+
|
61
|
+
INJECT_PARAMS = {
|
62
|
+
"include_time_key" => nil,
|
63
|
+
"time_key" => "time_key",
|
64
|
+
"time_format" => "time_format",
|
65
|
+
"timezone" => "timezone",
|
66
|
+
"include_tag_key" => nil,
|
67
|
+
"tag_key" => "tag_key",
|
68
|
+
"localtime" => nil,
|
69
|
+
"utc" => nil,
|
70
|
+
}
|
71
|
+
|
72
|
+
FORMATTER_PARAMS = {
|
73
|
+
"format" => "@type",
|
74
|
+
"delimiter" => "delimiter",
|
75
|
+
"force_quotes" => "force_quotes", # CsvFormatter
|
76
|
+
"fields" => "fields", # CsvFormatter
|
77
|
+
"json_parser" => "json_parser", # JSONFormatter
|
78
|
+
"label_delimiter" => "label_delimiter", # LabeledTSVFormatter
|
79
|
+
"output_time" => "output_time", # OutFileFormatter
|
80
|
+
"output_tag" => "output_tag", # OutFileFormatter
|
81
|
+
"message_key" => "message_key", # SingleValueFormatter
|
82
|
+
"add_newline" => "add_newline", # SingleValueFormatter
|
83
|
+
"output_type" => "output_type", # StdoutFormatter
|
84
|
+
}
|
85
|
+
|
86
|
+
def compat_parameters_convert(conf, *types, **kwargs)
|
87
|
+
types.each do |type|
|
88
|
+
case type
|
89
|
+
when :buffer
|
90
|
+
compat_parameters_buffer(conf, **kwargs)
|
91
|
+
when :inject
|
92
|
+
compat_parameters_inject(conf)
|
93
|
+
when :parser
|
94
|
+
compat_parameters_parser(conf)
|
95
|
+
when :formatter
|
96
|
+
compat_parameters_formatter(conf)
|
97
|
+
else
|
98
|
+
raise "BUG: unknown compat_parameters type: #{type}"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
conf
|
51
103
|
end
|
52
104
|
|
53
|
-
def
|
54
|
-
if
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
end
|
105
|
+
def compat_parameters_buffer(conf, default_chunk_key: '')
|
106
|
+
# return immediately if <buffer> section exists, or any buffer-related parameters don't exist
|
107
|
+
return unless conf.elements('buffer').empty?
|
108
|
+
return if (BUFFER_PARAMS.keys + BUFFER_TIME_SLICED_PARAMS.keys).all?{|k| !conf.has_key?(k) }
|
109
|
+
|
110
|
+
# TODO: warn obsolete parameters if these are deprecated
|
111
|
+
buffer_params = BUFFER_PARAMS.merge(BUFFER_TIME_SLICED_PARAMS)
|
112
|
+
attr = compat_parameters_copy_to_subsection_attributes(conf, buffer_params) do |compat_key, value|
|
113
|
+
if compat_key == 'buffer_queue_full_action' && value == 'exception'
|
114
|
+
'throw_exception'
|
115
|
+
else
|
116
|
+
value
|
66
117
|
end
|
67
|
-
|
68
|
-
|
69
|
-
|
118
|
+
end
|
119
|
+
|
120
|
+
chunk_key = default_chunk_key
|
121
|
+
|
122
|
+
if conf.has_key?('time_slice_format')
|
123
|
+
chunk_key = 'time'
|
124
|
+
attr['timekey'] = case conf['time_slice_format']
|
125
|
+
when /\%S/ then 1
|
126
|
+
when /\%M/ then 60
|
127
|
+
when /\%H/ then 3600
|
128
|
+
when /\%d/ then 86400
|
129
|
+
else
|
130
|
+
raise Fluent::ConfigError, "time_slice_format only with %Y or %m is too long"
|
131
|
+
end
|
132
|
+
else
|
133
|
+
if chunk_key == 'time'
|
134
|
+
attr['timekey'] = 86400 # TimeSliceOutput.time_slice_format default value is '%Y%m%d'
|
70
135
|
end
|
136
|
+
end
|
71
137
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
138
|
+
e = Fluent::Config::Element.new('buffer', chunk_key, attr, [])
|
139
|
+
conf.elements << e
|
140
|
+
|
141
|
+
conf
|
142
|
+
end
|
143
|
+
|
144
|
+
def compat_parameters_inject(conf)
|
145
|
+
return unless conf.elements('inject').empty?
|
146
|
+
return if INJECT_PARAMS.keys.all?{|k| !conf.has_key?(k) }
|
147
|
+
|
148
|
+
# TODO: warn obsolete parameters if these are deprecated
|
149
|
+
attr = compat_parameters_copy_to_subsection_attributes(conf, INJECT_PARAMS)
|
150
|
+
|
151
|
+
if conf.has_key?('include_time_key') && Fluent::Config.bool_value(conf['include_time_key'])
|
152
|
+
attr['time_key'] ||= 'time'
|
153
|
+
attr['time_type'] ||= 'string'
|
154
|
+
end
|
155
|
+
if conf.has_key?('time_as_epoch') && Fluent::Config.bool_value(conf['time_as_epoch'])
|
156
|
+
attr['time_type'] = 'unixtime'
|
157
|
+
end
|
158
|
+
if conf.has_key?('localtime') || conf.has_key?('utc')
|
159
|
+
if conf.has_key?('localtime') && conf.has_key?('utc')
|
160
|
+
raise Fluent::ConfigError, "both of utc and localtime are specified, use only one of them"
|
161
|
+
elsif conf.has_key?('localtime')
|
162
|
+
attr['localtime'] = Fluent::Config.bool_value(conf['localtime'])
|
163
|
+
elsif conf.has_key?('utc')
|
164
|
+
attr['localtime'] = !(Fluent::Config.bool_value(conf['utc']))
|
165
|
+
# Specifying "localtime false" means using UTC in TimeFormatter
|
166
|
+
# And specifying "utc" is different from specifying "timezone +0000"(it's not always UTC).
|
167
|
+
# There are difference between "Z" and "+0000" in timezone formatting.
|
168
|
+
# TODO: add kwargs to TimeFormatter to specify "using localtime", "using UTC" or "using specified timezone" in more explicit way
|
89
169
|
end
|
170
|
+
end
|
90
171
|
|
91
|
-
|
92
|
-
|
172
|
+
if conf.has_key?('include_tag_key') && Fluent::Config.bool_value(conf['include_tag_key'])
|
173
|
+
attr['tag_key'] ||= 'tag'
|
93
174
|
end
|
94
175
|
|
95
|
-
|
176
|
+
e = Fluent::Config::Element.new('inject', '', attr, [])
|
177
|
+
conf.elements << e
|
178
|
+
|
179
|
+
conf
|
180
|
+
end
|
181
|
+
|
182
|
+
def compat_parameters_parser(conf)
|
183
|
+
return unless conf.elements('parse').empty?
|
184
|
+
return if PARSER_PARAMS.keys.all?{|k| !conf.has_key?(k) }
|
185
|
+
|
186
|
+
# TODO: warn obsolete parameters if these are deprecated
|
187
|
+
attr = compat_parameters_copy_to_subsection_attributes(conf, PARSER_PARAMS)
|
188
|
+
|
189
|
+
e = Fluent::Config::Element.new('parse', '', attr, [])
|
190
|
+
conf.elements << e
|
191
|
+
|
192
|
+
conf
|
193
|
+
end
|
194
|
+
|
195
|
+
def compat_parameters_formatter(conf)
|
196
|
+
return unless conf.elements('format').empty?
|
197
|
+
return if FORMATTER_PARAMS.keys.all?{|k| !conf.has_key?(k) }
|
198
|
+
|
199
|
+
# TODO: warn obsolete parameters if these are deprecated
|
200
|
+
attr = compat_parameters_copy_to_subsection_attributes(conf, FORMATTER_PARAMS)
|
201
|
+
|
202
|
+
e = Fluent::Config::Element.new('format', '', attr, [])
|
203
|
+
conf.elements << e
|
204
|
+
|
205
|
+
conf
|
206
|
+
end
|
207
|
+
|
208
|
+
def compat_parameters_copy_to_subsection_attributes(conf, params, &block)
|
209
|
+
attr = {}
|
210
|
+
params.each do |compat, current|
|
211
|
+
next unless current
|
212
|
+
if conf.has_key?(compat)
|
213
|
+
if block_given?
|
214
|
+
attr[current] = block.call(compat, conf[compat])
|
215
|
+
else
|
216
|
+
attr[current] = conf[compat]
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
attr
|
96
221
|
end
|
97
222
|
end
|
98
223
|
end
|
@@ -17,19 +17,25 @@
|
|
17
17
|
require 'fluent/plugin'
|
18
18
|
require 'fluent/plugin/formatter'
|
19
19
|
require 'fluent/config/element'
|
20
|
+
require 'fluent/configurable'
|
20
21
|
|
21
22
|
module Fluent
|
22
23
|
module PluginHelper
|
23
24
|
module Formatter
|
24
|
-
def formatter_create(usage: '', type: nil, conf: nil)
|
25
|
+
def formatter_create(usage: '', type: nil, conf: nil, default_type: nil)
|
25
26
|
formatter = @_formatters[usage]
|
26
27
|
return formatter if formatter
|
27
28
|
|
28
|
-
if
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
type = if type
|
30
|
+
type
|
31
|
+
elsif conf && conf.respond_to?(:[])
|
32
|
+
raise Fluent::ConfigError, "@type is required in <format>" unless conf['@type']
|
33
|
+
conf['@type']
|
34
|
+
elsif default_type
|
35
|
+
default_type
|
36
|
+
else
|
37
|
+
raise ArgumentError, "BUG: both type and conf are not specified"
|
38
|
+
end
|
33
39
|
formatter = Fluent::Plugin.new_formatter(type, parent: self)
|
34
40
|
config = case conf
|
35
41
|
when Fluent::Config::Element
|
@@ -52,16 +58,19 @@ module Fluent
|
|
52
58
|
formatter
|
53
59
|
end
|
54
60
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
end
|
61
|
+
module FormatterParams
|
62
|
+
include Fluent::Configurable
|
63
|
+
# minimum section definition to instantiate formatter plugin instances
|
64
|
+
config_section :format, required: false, multi: true, param_name: :formatter_configs do
|
65
|
+
config_argument :usage, :string, default: ''
|
66
|
+
config_param :@type, :string
|
62
67
|
end
|
63
68
|
end
|
64
69
|
|
70
|
+
def self.included(mod)
|
71
|
+
mod.include FormatterParams
|
72
|
+
end
|
73
|
+
|
65
74
|
attr_reader :_formatters # for tests
|
66
75
|
|
67
76
|
def initialize
|
@@ -73,13 +82,15 @@ module Fluent
|
|
73
82
|
def configure(conf)
|
74
83
|
super
|
75
84
|
|
76
|
-
@formatter_configs
|
77
|
-
|
78
|
-
|
85
|
+
if @formatter_configs
|
86
|
+
@formatter_configs.each do |section|
|
87
|
+
if @_formatters[section.usage]
|
88
|
+
raise Fluent::ConfigError, "duplicated formatter configured: #{section.usage}"
|
89
|
+
end
|
90
|
+
formatter = Plugin.new_formatter(section[:@type], parent: self)
|
91
|
+
formatter.configure(section.corresponding_config_element)
|
92
|
+
@_formatters[section.usage] = formatter
|
79
93
|
end
|
80
|
-
formatter = Plugin.new_formatter(section[:@type], parent: self)
|
81
|
-
formatter.configure(section.corresponding_config_element)
|
82
|
-
@_formatters[section.usage] = formatter
|
83
94
|
end
|
84
95
|
end
|
85
96
|
|
@@ -16,6 +16,7 @@
|
|
16
16
|
|
17
17
|
require 'fluent/event'
|
18
18
|
require 'time'
|
19
|
+
require 'fluent/configurable'
|
19
20
|
|
20
21
|
module Fluent
|
21
22
|
module PluginHelper
|
@@ -58,22 +59,28 @@ module Fluent
|
|
58
59
|
new_es
|
59
60
|
end
|
60
61
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
62
|
+
module InjectParams
|
63
|
+
include Fluent::Configurable
|
64
|
+
config_section :inject, required: false, multi: false, param_name: :inject_config do
|
65
|
+
config_param :hostname_key, :string, default: nil
|
66
|
+
config_param :hostname, :string, default: nil
|
67
|
+
config_param :tag_key, :string, default: nil
|
68
|
+
config_param :time_key, :string, default: nil
|
69
|
+
config_param :time_type, :enum, list: [:float, :unixtime, :string], default: :float
|
70
|
+
config_param :time_format, :string, default: nil
|
71
|
+
config_param :localtime, :bool, default: true # if localtime is false and timezone is nil, then utc
|
72
|
+
config_param :utc, :bool, default: false # placeholder to turn localtime to false
|
73
|
+
config_param :timezone, :string, default: nil
|
72
74
|
end
|
73
75
|
end
|
74
76
|
|
77
|
+
def self.included(mod)
|
78
|
+
mod.include InjectParams
|
79
|
+
end
|
80
|
+
|
75
81
|
def initialize
|
76
82
|
super
|
83
|
+
@_inject_enabled = false
|
77
84
|
@_inject_hostname_key = nil
|
78
85
|
@_inject_hostname = nil
|
79
86
|
@_inject_tag_key = nil
|
@@ -82,6 +89,12 @@ module Fluent
|
|
82
89
|
end
|
83
90
|
|
84
91
|
def configure(conf)
|
92
|
+
conf.elements('inject').each do |e|
|
93
|
+
if e.has_key?('utc') && Fluent::Config.bool_value(e['utc'])
|
94
|
+
e['localtime'] = 'false'
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
85
98
|
super
|
86
99
|
|
87
100
|
if @inject_config
|
@@ -100,7 +113,7 @@ module Fluent
|
|
100
113
|
when :float then ->(time){ time.to_r.truncate(+6).to_f } # microsecond floating point value
|
101
114
|
when :unixtime then ->(time){ time.to_i }
|
102
115
|
else
|
103
|
-
Fluent::TimeFormatter.new(@inject_config.time_format,
|
116
|
+
Fluent::TimeFormatter.new(@inject_config.time_format, @inject_config.localtime, @inject_config.timezone)
|
104
117
|
end
|
105
118
|
end
|
106
119
|
|
@@ -17,19 +17,25 @@
|
|
17
17
|
require 'fluent/plugin'
|
18
18
|
require 'fluent/plugin/parser'
|
19
19
|
require 'fluent/config/element'
|
20
|
+
require 'fluent/configurable'
|
20
21
|
|
21
22
|
module Fluent
|
22
23
|
module PluginHelper
|
23
24
|
module Parser
|
24
|
-
def parser_create(usage: '', type: nil, conf: nil)
|
25
|
+
def parser_create(usage: '', type: nil, conf: nil, default_type: nil)
|
25
26
|
parser = @_parsers[usage]
|
26
27
|
return parser if parser
|
27
28
|
|
28
|
-
if
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
type = if type
|
30
|
+
type
|
31
|
+
elsif conf && conf.respond_to?(:[])
|
32
|
+
raise Fluent::ConfigError, "@type is required in <parse>" unless conf['@type']
|
33
|
+
conf['@type']
|
34
|
+
elsif default_type
|
35
|
+
default_type
|
36
|
+
else
|
37
|
+
raise ArgumentError, "BUG: both type and conf are not specified"
|
38
|
+
end
|
33
39
|
parser = Fluent::Plugin.new_parser(type, parent: self)
|
34
40
|
config = case conf
|
35
41
|
when Fluent::Config::Element
|
@@ -52,16 +58,19 @@ module Fluent
|
|
52
58
|
parser
|
53
59
|
end
|
54
60
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
end
|
61
|
+
module ParserParams
|
62
|
+
include Fluent::Configurable
|
63
|
+
# minimum section definition to instantiate parser plugin instances
|
64
|
+
config_section :parse, required: false, multi: true, param_name: :parser_configs do
|
65
|
+
config_argument :usage, :string, default: ''
|
66
|
+
config_param :@type, :string
|
62
67
|
end
|
63
68
|
end
|
64
69
|
|
70
|
+
def self.included(mod)
|
71
|
+
mod.include ParserParams
|
72
|
+
end
|
73
|
+
|
65
74
|
attr_reader :_parsers # for tests
|
66
75
|
|
67
76
|
def initialize
|
@@ -20,6 +20,7 @@ require 'fluent/plugin'
|
|
20
20
|
require 'fluent/plugin/storage'
|
21
21
|
require 'fluent/plugin_helper/timer'
|
22
22
|
require 'fluent/config/element'
|
23
|
+
require 'fluent/configurable'
|
23
24
|
|
24
25
|
module Fluent
|
25
26
|
module PluginHelper
|
@@ -28,18 +29,23 @@ module Fluent
|
|
28
29
|
|
29
30
|
StorageState = Struct.new(:storage, :running)
|
30
31
|
|
31
|
-
def storage_create(usage: '', type: nil, conf: nil)
|
32
|
+
def storage_create(usage: '', type: nil, conf: nil, default_type: nil)
|
32
33
|
s = @_storages[usage]
|
33
34
|
if s && s.running
|
34
35
|
return s.storage
|
35
36
|
elsif s
|
36
37
|
# storage is already created, but not loaded / started
|
37
38
|
else # !s
|
38
|
-
if
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
type = if type
|
40
|
+
type
|
41
|
+
elsif conf && conf.respond_to?(:[])
|
42
|
+
raise Fluent::ConfigError, "@type is required in <storage>" unless conf['@type']
|
43
|
+
conf['@type']
|
44
|
+
elsif default_type
|
45
|
+
default_type
|
46
|
+
else
|
47
|
+
raise ArgumentError, "BUG: both type and conf are not specified"
|
48
|
+
end
|
43
49
|
storage = Plugin.new_storage(type, parent: self)
|
44
50
|
config = case conf
|
45
51
|
when Fluent::Config::Element
|
@@ -63,16 +69,19 @@ module Fluent
|
|
63
69
|
s.storage
|
64
70
|
end
|
65
71
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
end
|
72
|
+
module StorageParams
|
73
|
+
include Fluent::Configurable
|
74
|
+
# minimum section definition to instantiate storage plugin instances
|
75
|
+
config_section :storage, required: false, multi: true, param_name: :storage_configs do
|
76
|
+
config_argument :usage, :string, default: ''
|
77
|
+
config_param :@type, :string, default: Fluent::Plugin::Storage::DEFAULT_TYPE
|
73
78
|
end
|
74
79
|
end
|
75
80
|
|
81
|
+
def self.included(mod)
|
82
|
+
mod.include StorageParams
|
83
|
+
end
|
84
|
+
|
76
85
|
attr_reader :_storages # for tests
|
77
86
|
|
78
87
|
def initialize
|