fluentd-ui 1.0.0.alpha.2 → 1.0.0.alpha.3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of fluentd-ui might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/ChangeLog.md +5 -0
- data/Gemfile.lock +56 -1
- data/README.md +2 -2
- data/app/controllers/api/config_definitions_controller.rb +55 -0
- data/app/controllers/api_controller.rb +20 -3
- data/app/controllers/concerns/setting_concern.rb +18 -2
- data/app/controllers/fluentd/settings/in_tail_controller.rb +13 -5
- data/app/controllers/fluentd/settings/out_forward_controller.rb +0 -9
- data/app/controllers/fluentd/settings/out_s3_controller.rb +0 -5
- data/app/controllers/fluentd/settings/out_tdlog_controller.rb +9 -0
- data/app/form_builders/fluentd_form_builder.rb +83 -0
- data/app/helpers/settings_helper.rb +81 -18
- data/app/javascript/packs/application.js +4 -0
- data/app/javascript/packs/in_tail_parse.js +159 -0
- data/app/javascript/packs/owned_plugin_form.js +141 -0
- data/app/javascript/packs/parser_multiline_form.js +51 -0
- data/app/javascript/packs/plugin_setting.js +19 -0
- data/app/models/concerns/fluentd/setting/configurable.rb +113 -0
- data/app/models/concerns/fluentd/setting/pattern.rb +11 -0
- data/app/models/concerns/fluentd/setting/plugin.rb +78 -0
- data/app/models/concerns/fluentd/setting/plugin_config.rb +74 -0
- data/app/models/concerns/fluentd/setting/plugin_parameter.rb +121 -0
- data/app/models/concerns/fluentd/setting/section_parser.rb +36 -0
- data/app/models/concerns/fluentd/setting/section_validator.rb +21 -0
- data/app/models/fluentd.rb +5 -5
- data/app/models/fluentd/setting/buffer_file.rb +23 -0
- data/app/models/fluentd/setting/buffer_memory.rb +17 -0
- data/app/models/fluentd/setting/formatter_csv.rb +21 -0
- data/app/models/fluentd/setting/formatter_hash.rb +19 -0
- data/app/models/fluentd/setting/formatter_json.rb +25 -0
- data/app/models/fluentd/setting/formatter_ltsv.rb +21 -0
- data/app/models/fluentd/setting/formatter_msgpack.rb +13 -0
- data/app/models/fluentd/setting/formatter_out_file.rb +21 -0
- data/app/models/fluentd/setting/formatter_single_value.rb +20 -0
- data/app/models/fluentd/setting/formatter_stdout.rb +19 -0
- data/app/models/fluentd/setting/formatter_tsv.rb +21 -0
- data/app/models/fluentd/setting/in_forward.rb +7 -17
- data/app/models/fluentd/setting/in_http.rb +13 -19
- data/app/models/fluentd/setting/in_monitor_agent.rb +6 -19
- data/app/models/fluentd/setting/in_syslog.rb +14 -12
- data/app/models/fluentd/setting/in_tail.rb +7 -84
- data/app/models/fluentd/setting/out_elasticsearch.rb +12 -21
- data/app/models/fluentd/setting/out_forward.rb +22 -66
- data/app/models/fluentd/setting/out_mongo.rb +20 -26
- data/app/models/fluentd/setting/out_s3.rb +18 -30
- data/app/models/fluentd/setting/out_stdout.rb +21 -18
- data/app/models/fluentd/setting/out_tdlog.rb +35 -0
- data/app/models/fluentd/setting/parser_apache.rb +13 -0
- data/app/models/fluentd/setting/parser_apache2.rb +13 -0
- data/app/models/fluentd/setting/parser_apache_error.rb +13 -0
- data/app/models/fluentd/setting/parser_csv.rb +22 -0
- data/app/models/fluentd/setting/parser_in_http.rb +13 -0
- data/app/models/fluentd/setting/parser_json.rb +25 -0
- data/app/models/fluentd/setting/parser_ltsv.rb +30 -0
- data/app/models/fluentd/setting/parser_msgpack.rb +13 -0
- data/app/models/fluentd/setting/parser_multiline.rb +24 -0
- data/app/models/fluentd/setting/parser_nginx.rb +13 -0
- data/app/models/fluentd/setting/parser_none.rb +19 -0
- data/app/models/fluentd/setting/parser_regexp.rb +26 -0
- data/app/models/fluentd/setting/parser_syslog.rb +29 -0
- data/app/models/fluentd/setting/parser_tsv.rb +19 -0
- data/app/models/fluentd/setting/section.rb +38 -0
- data/app/models/fluentd/setting/storage_local.rb +22 -0
- data/app/models/fluentd/setting/type/array.rb +17 -0
- data/app/models/fluentd/setting/type/bool.rb +18 -0
- data/app/models/fluentd/setting/type/enum.rb +17 -0
- data/app/models/fluentd/setting/type/hash.rb +17 -0
- data/app/models/fluentd/setting/type/regexp.rb +17 -0
- data/app/models/fluentd/setting/type/section.rb +17 -0
- data/app/models/fluentd/setting/type/size.rb +17 -0
- data/app/models/fluentd/setting/type/time.rb +17 -0
- data/app/views/api/settings/_element.json.jbuilder +1 -1
- data/app/views/fluentd/settings/in_forward/_form.html.haml +16 -0
- data/app/views/fluentd/settings/in_tail/_form.html.haml +22 -29
- data/app/views/fluentd/settings/in_tail/after_file_choose.html.haml +1 -1
- data/app/views/fluentd/settings/in_tail/after_format.html.haml +4 -4
- data/app/views/fluentd/settings/in_tail/confirm.html.haml +5 -5
- data/app/views/fluentd/settings/source_and_output.html.haml +1 -1
- data/app/views/shared/_global_nav.html.erb +8 -8
- data/app/views/shared/settings/_form.html.haml +40 -9
- data/app/views/shared/settings/show.html.haml +4 -1
- data/app/views/shared/vue/_in_tail_parse.html.haml +20 -0
- data/app/views/shared/vue/_owned_plugin_form.html.haml +68 -0
- data/app/views/shared/vue/_parser_multiline_form.html.haml +19 -0
- data/app/views/shared/vue/_setting.html.erb +1 -1
- data/config/application.rb +1 -1
- data/config/environment.rb +3 -0
- data/config/initializers/types.rb +7 -0
- data/config/routes.rb +2 -1
- data/fluentd-ui.gemspec +5 -0
- data/lib/fluentd-ui/version.rb +1 -1
- data/lib/regexp_preview.rb +2 -2
- data/lib/regexp_preview/multi_line.rb +53 -63
- data/lib/regexp_preview/single_line.rb +40 -46
- data/spec/features/fluentd/setting/out_forward_spec.rb +1 -1
- data/spec/features/fluentd/setting/out_stdout_spec.rb +1 -1
- data/spec/features/{out_td_spec.rb → out_tdlog_spec.rb} +3 -3
- data/spec/lib/regexp_preview/multi_line_spec.rb +29 -34
- data/spec/lib/regexp_preview/single_line_spec.rb +89 -87
- data/spec/models/fluentd/setting/in_forward_spec.rb +75 -0
- data/spec/models/fluentd/setting/in_http_spec.rb +31 -0
- data/spec/models/fluentd/setting/in_monitor_agent_spec.rb +31 -0
- data/spec/models/fluentd/setting/in_syslog_spec.rb +65 -7
- data/spec/models/fluentd/setting/in_tail_spec.rb +47 -0
- data/spec/models/fluentd/setting/out_elasticsearch_spec.rb +31 -0
- data/spec/models/fluentd/setting/out_mongo_spec.rb +35 -12
- data/spec/models/fluentd/setting/out_s3_spec.rb +128 -0
- data/spec/models/fluentd/setting/out_stdout_spec.rb +31 -0
- data/spec/models/fluentd/setting/out_tdlog_spec.rb +47 -0
- metadata +164 -38
- data/app/controllers/fluentd/settings/out_td_controller.rb +0 -18
- data/app/helpers/fluentd/settings_helper.rb +0 -2
- data/app/javascript/packs/in_tail_format.js +0 -174
- data/app/models/fluentd/setting/common.rb +0 -185
- data/app/models/fluentd/setting/out_td.rb +0 -48
- data/app/views/shared/vue/_in_tail_format.html.erb +0 -43
- data/spec/models/fluentd/setting/common_spec.rb +0 -178
- data/spec/models/fluentd/setting/out_td_spec.rb +0 -38
@@ -0,0 +1,19 @@
|
|
1
|
+
%script{type: "text/x-template", id: "vue-parser-multiline-form"}
|
2
|
+
.form-group
|
3
|
+
%label{"for" => "setting_parse_0__format_firstline",
|
4
|
+
"data-toggle" => "tooltip",
|
5
|
+
"data-placement" => "right",
|
6
|
+
"v-bind:title" => "formatFirstlineDesc"}
|
7
|
+
Format first line
|
8
|
+
%input.form-control{"type" => "text",
|
9
|
+
"id" => "setting_parse_0__format_firstline",
|
10
|
+
"name" => "setting[parse[0]][format_firstline]",
|
11
|
+
"v-model.lazy" => "formatFirstline"}
|
12
|
+
%label.mt-3{"v-bind:for" => "textareaId(pluginType)"}
|
13
|
+
Formats
|
14
|
+
%p.alert.alert-warning
|
15
|
+
= t("fluentd.settings.in_tail.notice_for_multiline_limit")
|
16
|
+
%textarea.form-control{"v-bind:id" => "textareaId(pluginType)",
|
17
|
+
"v-bind:name" => "textareaName(pluginType)",
|
18
|
+
"v-model.lazy" => "formats",
|
19
|
+
"rows" => 20}
|
@@ -4,9 +4,9 @@
|
|
4
4
|
|
5
5
|
<div class="card card-primary mb-3">
|
6
6
|
<div class="card-header" data-toggle="collapse" v-bind:href="'#'+id" v-bind:title="content">
|
7
|
+
<i class="fa fa-caret-down"></i>
|
7
8
|
{{ type }}
|
8
9
|
<span v-if="name == 'match'">({{ arg }})</span>
|
9
|
-
<i class="fa fa-caret-down"></i>
|
10
10
|
</div>
|
11
11
|
<div class="card-body collapse" v-bind:id="id">
|
12
12
|
<pre v-if="mode != 'edit'">{{ content }}</pre>
|
data/config/application.rb
CHANGED
@@ -46,7 +46,7 @@ module FluentdUi
|
|
46
46
|
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
47
47
|
config.i18n.default_locale = 'en'
|
48
48
|
config.i18n.available_locales = %i(en ja)
|
49
|
-
config.autoload_paths += %W(#{config.root}/lib)
|
49
|
+
config.autoload_paths += %W(#{config.root}/lib #{Rails.root}/app/form_builders)
|
50
50
|
|
51
51
|
config.active_job.queue_adapter = :sucker_punch
|
52
52
|
|
data/config/environment.rb
CHANGED
@@ -0,0 +1,7 @@
|
|
1
|
+
ActiveModel::Type.register(:array, Fluentd::Setting::Type::Array)
|
2
|
+
ActiveModel::Type.register(:enum, Fluentd::Setting::Type::Enum)
|
3
|
+
ActiveModel::Type.register(:bool, Fluentd::Setting::Type::Bool)
|
4
|
+
ActiveModel::Type.register(:hash, Fluentd::Setting::Type::Hash)
|
5
|
+
ActiveModel::Type.register(:regexp, Fluentd::Setting::Type::Hash)
|
6
|
+
ActiveModel::Type.register(:size, Fluentd::Setting::Type::Size)
|
7
|
+
ActiveModel::Type.register(:section, Fluentd::Setting::Type::Section)
|
data/config/routes.rb
CHANGED
@@ -49,7 +49,7 @@ Rails.application.routes.draw do
|
|
49
49
|
post "finish"
|
50
50
|
end
|
51
51
|
|
52
|
-
resource :
|
52
|
+
resource :out_tdlog, only: [:show], module: :settings, controller: :out_tdlog do
|
53
53
|
post "finish"
|
54
54
|
end
|
55
55
|
|
@@ -124,5 +124,6 @@ Rails.application.routes.draw do
|
|
124
124
|
post "grok_to_regexp"
|
125
125
|
|
126
126
|
resources :settings, only: [:index, :show, :update, :destroy], defaults: { format: "json" }
|
127
|
+
resources :config_definitions, only: [:index], defaults: { format: "json" }
|
127
128
|
end
|
128
129
|
end
|
data/fluentd-ui.gemspec
CHANGED
@@ -53,4 +53,9 @@ Gem::Specification.new do |spec|
|
|
53
53
|
spec.add_dependency "rubyzip", "~> 1.1" # API changed as Zip::ZipFile -> Zip::File since v1.0.0
|
54
54
|
spec.add_dependency "diff-lcs"
|
55
55
|
spec.add_dependency "webpacker"
|
56
|
+
|
57
|
+
spec.add_dependency "fluent-plugin-td", "~> 1.0"
|
58
|
+
spec.add_dependency "fluent-plugin-mongo", "~> 1.1"
|
59
|
+
spec.add_dependency "fluent-plugin-elasticsearch", "~> 2.10"
|
60
|
+
spec.add_dependency "fluent-plugin-s3", "~> 1.1"
|
56
61
|
end
|
data/lib/fluentd-ui/version.rb
CHANGED
data/lib/regexp_preview.rb
CHANGED
@@ -1,80 +1,70 @@
|
|
1
1
|
module RegexpPreview
|
2
2
|
class MultiLine
|
3
|
-
attr_reader :
|
3
|
+
attr_reader :path, :plugin_name, :plugin_config, :plugin
|
4
4
|
|
5
|
-
def initialize(
|
6
|
-
@
|
7
|
-
@
|
8
|
-
@
|
5
|
+
def initialize(path, plugin_name, plugin_config = {})
|
6
|
+
@path = path
|
7
|
+
@plugin_name = plugin_name
|
8
|
+
@plugin_config = plugin_config
|
9
|
+
|
10
|
+
config = Fluent::Config::Element.new("ROOT", "", @plugin_config, [])
|
11
|
+
@plugin = Fluent::Plugin.new_parser(@plugin_name).tap do |instance|
|
12
|
+
instance.configure(config)
|
13
|
+
end
|
9
14
|
end
|
10
15
|
|
11
|
-
def
|
16
|
+
def matches
|
12
17
|
{
|
13
|
-
|
14
|
-
|
15
|
-
regexp: nil,
|
16
|
-
time_format: nil,
|
17
|
-
}
|
18
|
-
},
|
19
|
-
matches: matches.compact,
|
18
|
+
pluginConfig: @plugin_config,
|
19
|
+
matches: _matches,
|
20
20
|
}
|
21
21
|
end
|
22
22
|
|
23
23
|
private
|
24
24
|
|
25
|
-
def
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
result
|
46
|
-
end
|
47
|
-
|
48
|
-
def detect_chunk(chunk)
|
49
|
-
whole = ""
|
50
|
-
matches = []
|
51
|
-
offset = 0
|
52
|
-
patterns.each do |pat|
|
53
|
-
match = chunk.match(pat)
|
54
|
-
return nil unless match
|
55
|
-
offset = chunk.index(pat)
|
56
|
-
return nil if offset > 0
|
57
|
-
chunk = chunk[match[0].length..-1]
|
58
|
-
match.names.each_with_index do |name, index|
|
59
|
-
matches << {
|
60
|
-
key: name,
|
61
|
-
matched: match[name],
|
62
|
-
pos: match.offset(index + 1).map{|pos| pos + whole.length},
|
25
|
+
def _matches
|
26
|
+
begin
|
27
|
+
io = File.open(path)
|
28
|
+
reader = FileReverseReader.new(io)
|
29
|
+
parserd_chunks = []
|
30
|
+
target_lines = reader.tail(Settings.in_tail_preview_line_count).map{|line| line << "\n" }
|
31
|
+
whole_string = target_lines.join
|
32
|
+
firstline_regex = Regexp.new(plugin_config["format_firstline"][1..-2])
|
33
|
+
indexes = []
|
34
|
+
cur = 0
|
35
|
+
while first_index = whole_string.index(firstline_regex, cur)
|
36
|
+
indexes << first_index
|
37
|
+
cur = first_index + 1
|
38
|
+
end
|
39
|
+
indexes.each_with_index do |index, i|
|
40
|
+
next_index = indexes[i + 1] || -1
|
41
|
+
chunk = whole_string[index...next_index]
|
42
|
+
parsed = {
|
43
|
+
whole: chunk,
|
44
|
+
matches: []
|
63
45
|
}
|
46
|
+
@plugin.parse(chunk) do |time, record|
|
47
|
+
next unless record
|
48
|
+
last_pos = 0
|
49
|
+
record.each do |key, value|
|
50
|
+
start = chunk.index(value, last_pos)
|
51
|
+
finish = start + value.bytesize
|
52
|
+
last_pos = finish
|
53
|
+
parsed[:matches] << {
|
54
|
+
key: key,
|
55
|
+
matched: value,
|
56
|
+
pos: [start, finish]
|
57
|
+
}
|
58
|
+
end
|
59
|
+
end
|
60
|
+
parserd_chunks << parsed
|
64
61
|
end
|
65
|
-
|
62
|
+
parserd_chunks.reject do |parsed|
|
63
|
+
parsed[:matches].blank?
|
64
|
+
end
|
65
|
+
ensure
|
66
|
+
io.close
|
66
67
|
end
|
67
|
-
{
|
68
|
-
whole: whole,
|
69
|
-
matches: matches,
|
70
|
-
}
|
71
|
-
end
|
72
|
-
|
73
|
-
def patterns
|
74
|
-
@patterns ||= (1..20).map do |n|
|
75
|
-
params["format#{n}"].presence
|
76
|
-
end.compact.map {|pattern| Regexp.new(pattern, Regexp::MULTILINE)}
|
77
68
|
end
|
78
69
|
end
|
79
70
|
end
|
80
|
-
|
@@ -1,65 +1,59 @@
|
|
1
1
|
module RegexpPreview
|
2
2
|
class SingleLine
|
3
|
-
attr_reader :
|
3
|
+
attr_reader :path, :plugin_name, :plugin_config, :plugin
|
4
4
|
|
5
|
-
def initialize(
|
6
|
-
@
|
7
|
-
@
|
8
|
-
@
|
9
|
-
@params = params
|
5
|
+
def initialize(path, plugin_name, plugin_config = {})
|
6
|
+
@path = path
|
7
|
+
@plugin_name = plugin_name.to_sym
|
8
|
+
@plugin_config = plugin_config
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
@time_format = nil
|
15
|
-
when "ltsv", "json", "csv", "tsv"
|
16
|
-
@regexp = nil
|
17
|
-
@time_format = nil
|
18
|
-
else # apache, nginx, etc
|
19
|
-
parser_plugin = Fluent::Plugin.new_parser(format)
|
20
|
-
raise "Unknown format '#{format}'" unless parser_plugin
|
21
|
-
parser_plugin.configure(Fluent::Config::Element.new('ROOT', '', {}, [])) # NOTE: SyslogParser define @regexp in configure method so call it to grab Regexp object
|
22
|
-
@regexp = parser_plugin.instance_variable_get(:@regexp)
|
23
|
-
@time_format = parser_plugin.time_format
|
10
|
+
config = Fluent::Config::Element.new("ROOT", "", @plugin_config, [])
|
11
|
+
@plugin = Fluent::Plugin.new_parser(@plugin_name).tap do |instance|
|
12
|
+
instance.configure(config)
|
24
13
|
end
|
25
14
|
end
|
26
15
|
|
27
|
-
def
|
16
|
+
def matches
|
28
17
|
{
|
29
|
-
|
30
|
-
|
31
|
-
# NOTE: regexp and time_format are used when format == 'apache' || 'nginx' || etc.
|
32
|
-
regexp: regexp.try(:source),
|
33
|
-
time_format: time_format,
|
34
|
-
}
|
35
|
-
},
|
36
|
-
matches: matches.compact,
|
18
|
+
pluginConfig: @plugin_config,
|
19
|
+
matches: _matches
|
37
20
|
}
|
38
21
|
end
|
39
22
|
|
40
23
|
private
|
41
24
|
|
42
|
-
def
|
43
|
-
return []
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
next result unless match
|
52
|
-
|
53
|
-
match.names.each_with_index do |name, index|
|
54
|
-
result[:matches] << {
|
55
|
-
key: name,
|
56
|
-
matched: match[name],
|
57
|
-
pos: match.offset(index + 1),
|
25
|
+
def _matches
|
26
|
+
return [] if %i(json csv tsv ltsv).include?(@plugin_name)
|
27
|
+
begin
|
28
|
+
io = File.open(path)
|
29
|
+
reader = FileReverseReader.new(io)
|
30
|
+
parsed_lines = reader.tail(Settings.in_tail_preview_line_count).map do |line|
|
31
|
+
parsed = {
|
32
|
+
whole: line,
|
33
|
+
matches: []
|
58
34
|
}
|
35
|
+
@plugin.parse(line) do |time, record|
|
36
|
+
next unless record
|
37
|
+
last_pos = 0
|
38
|
+
record.each do |key, value|
|
39
|
+
start = line.index(value, last_pos)
|
40
|
+
finish = start + value.bytesize
|
41
|
+
last_pos = finish
|
42
|
+
parsed[:matches] << {
|
43
|
+
key: key,
|
44
|
+
matched: value,
|
45
|
+
pos: [start, finish]
|
46
|
+
}
|
47
|
+
end
|
48
|
+
end
|
49
|
+
parsed
|
50
|
+
end
|
51
|
+
parsed_lines.reject do |parsed|
|
52
|
+
parsed[:matches].blank?
|
59
53
|
end
|
60
|
-
|
54
|
+
ensure
|
55
|
+
io.close
|
61
56
|
end
|
62
|
-
matches
|
63
57
|
end
|
64
58
|
end
|
65
59
|
end
|
@@ -2,6 +2,6 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe "out_stdout", stub: :daemon do
|
4
4
|
before { login_with exists_user }
|
5
|
-
it_should_behave_like "configurable daemon settings", "out_stdout", "
|
5
|
+
it_should_behave_like "configurable daemon settings", "out_stdout", "pattern", "stdout.**"
|
6
6
|
|
7
7
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe "
|
3
|
+
describe "out_tdlog", stub: :daemon do
|
4
4
|
let(:exists_user) { build(:user) }
|
5
5
|
let(:api_key) { "dummydummy" }
|
6
6
|
|
@@ -9,13 +9,13 @@ describe "out_td", stub: :daemon do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
it "Shown form with filled in td.*.* on match" do
|
12
|
-
visit
|
12
|
+
visit daemon_setting_out_tdlog_path
|
13
13
|
page.should have_css('input[name="fluentd_setting_out_td[match]"]')
|
14
14
|
end
|
15
15
|
|
16
16
|
it "Updated config after submit" do
|
17
17
|
daemon.agent.config.should_not include(api_key)
|
18
|
-
visit
|
18
|
+
visit daemon_setting_out_tdlog_path
|
19
19
|
within('#new_fluentd_setting_out_td') do
|
20
20
|
fill_in "Apikey", with: api_key
|
21
21
|
end
|
@@ -1,33 +1,29 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RegexpPreview::MultiLine do
|
4
|
-
describe "#
|
5
|
-
subject { parser.
|
6
|
-
let(:parser) { RegexpPreview::MultiLine.new(target_path, "multiline",
|
4
|
+
describe "#matches" do
|
5
|
+
subject { parser.matches }
|
6
|
+
let(:parser) { RegexpPreview::MultiLine.new(target_path, "multiline", plugin_config) }
|
7
7
|
|
8
8
|
describe "simple usage" do
|
9
9
|
let(:target_path) { File.expand_path("./spec/support/fixtures/error0.log", Rails.root) }
|
10
10
|
|
11
|
-
let :
|
12
|
-
|
13
|
-
format_firstline
|
14
|
-
time_format
|
11
|
+
let :plugin_config do
|
12
|
+
plugin_config = {
|
13
|
+
"format_firstline" => "/foo/",
|
14
|
+
"time_format" => "time_format",
|
15
15
|
}
|
16
|
-
|
17
|
-
|
16
|
+
plugin_config["format1"] = "/(?<foo>foo)\n/"
|
17
|
+
plugin_config["format2"] = "/(?<bar>bar)/"
|
18
18
|
3.upto(Fluentd::Setting::InTail::MULTI_LINE_MAX_FORMAT_COUNT) do |i|
|
19
|
-
|
19
|
+
plugin_config["format#{i}"] = "//"
|
20
20
|
end
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'should not have regexp and time_format in [:params][:setting]' do
|
25
|
-
expect(subject[:params][:setting]).to eq(regexp: nil, time_format: nil)
|
21
|
+
plugin_config
|
26
22
|
end
|
27
23
|
|
28
24
|
it "should include matches info" do
|
29
25
|
matches_info = {
|
30
|
-
whole: "foo\nbar",
|
26
|
+
whole: "foo\nbar\nbaz\n1\n2\n3\n4\n5\n6\n10\n11\n12",
|
31
27
|
matches: [
|
32
28
|
{
|
33
29
|
key: "foo", matched: "foo", pos: [0, 3]
|
@@ -37,24 +33,23 @@ describe RegexpPreview::MultiLine do
|
|
37
33
|
}
|
38
34
|
]
|
39
35
|
}
|
40
|
-
|
41
36
|
expect(subject[:matches]).to include matches_info
|
42
37
|
end
|
43
38
|
end
|
44
39
|
|
45
40
|
describe "detect only continuos patterns" do
|
46
41
|
let(:target_path) { File.expand_path("./spec/support/fixtures/error0.log", Rails.root) }
|
47
|
-
let(:
|
48
|
-
|
49
|
-
format_firstline
|
50
|
-
time_format
|
42
|
+
let(:plugin_config) do
|
43
|
+
plugin_config = {
|
44
|
+
"format_firstline" => "/foo/",
|
45
|
+
"time_format" => "time_format",
|
51
46
|
}
|
52
|
-
|
53
|
-
|
47
|
+
plugin_config["format1"] = "/(?<foo>foo)\n/"
|
48
|
+
plugin_config["format2"] = "/(?<bar>baz)/"
|
54
49
|
3.upto(Fluentd::Setting::InTail::MULTI_LINE_MAX_FORMAT_COUNT) do |i|
|
55
|
-
|
50
|
+
plugin_config["format#{i}"] = "//"
|
56
51
|
end
|
57
|
-
|
52
|
+
plugin_config
|
58
53
|
end
|
59
54
|
|
60
55
|
it "shouldn't match" do
|
@@ -66,21 +61,21 @@ describe RegexpPreview::MultiLine do
|
|
66
61
|
# http://docs.fluentd.org/articles/in_tail
|
67
62
|
let(:target_path) { File.expand_path("./spec/support/fixtures/multiline_example.log", Rails.root) }
|
68
63
|
|
69
|
-
let :
|
70
|
-
|
71
|
-
format_firstline
|
72
|
-
"format1" => "
|
73
|
-
time_format
|
64
|
+
let :plugin_config do
|
65
|
+
plugin_config = {
|
66
|
+
"format_firstline" => "/\\d{4}-\\d{1,2}-\\d{1,2}/",
|
67
|
+
"format1" => "/^(?<time>\\d{4}-\\d{1,2}-\\d{1,2} \\d{1,2}:\\d{1,2}:\\d{1,2}) \\[(?<thread>.*)\\] (?<level>[^\\s]+)(?<message>.*)/",
|
68
|
+
"time_format" => "%Y-%m-%d %H:%M:%S",
|
69
|
+
"keep_time_key" => true
|
74
70
|
}
|
75
71
|
2.upto(Fluentd::Setting::InTail::MULTI_LINE_MAX_FORMAT_COUNT) do |i|
|
76
|
-
|
72
|
+
plugin_config["format#{i}"] = "//"
|
77
73
|
end
|
78
|
-
|
74
|
+
plugin_config
|
79
75
|
end
|
80
76
|
|
81
77
|
it "should include matches info" do
|
82
|
-
matches_info =
|
83
|
-
[
|
78
|
+
matches_info = [
|
84
79
|
{
|
85
80
|
whole: "2013-3-03 14:27:33 [main] INFO Main - Start\n",
|
86
81
|
matches: [
|