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.

Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog.md +5 -0
  3. data/Gemfile.lock +56 -1
  4. data/README.md +2 -2
  5. data/app/controllers/api/config_definitions_controller.rb +55 -0
  6. data/app/controllers/api_controller.rb +20 -3
  7. data/app/controllers/concerns/setting_concern.rb +18 -2
  8. data/app/controllers/fluentd/settings/in_tail_controller.rb +13 -5
  9. data/app/controllers/fluentd/settings/out_forward_controller.rb +0 -9
  10. data/app/controllers/fluentd/settings/out_s3_controller.rb +0 -5
  11. data/app/controllers/fluentd/settings/out_tdlog_controller.rb +9 -0
  12. data/app/form_builders/fluentd_form_builder.rb +83 -0
  13. data/app/helpers/settings_helper.rb +81 -18
  14. data/app/javascript/packs/application.js +4 -0
  15. data/app/javascript/packs/in_tail_parse.js +159 -0
  16. data/app/javascript/packs/owned_plugin_form.js +141 -0
  17. data/app/javascript/packs/parser_multiline_form.js +51 -0
  18. data/app/javascript/packs/plugin_setting.js +19 -0
  19. data/app/models/concerns/fluentd/setting/configurable.rb +113 -0
  20. data/app/models/concerns/fluentd/setting/pattern.rb +11 -0
  21. data/app/models/concerns/fluentd/setting/plugin.rb +78 -0
  22. data/app/models/concerns/fluentd/setting/plugin_config.rb +74 -0
  23. data/app/models/concerns/fluentd/setting/plugin_parameter.rb +121 -0
  24. data/app/models/concerns/fluentd/setting/section_parser.rb +36 -0
  25. data/app/models/concerns/fluentd/setting/section_validator.rb +21 -0
  26. data/app/models/fluentd.rb +5 -5
  27. data/app/models/fluentd/setting/buffer_file.rb +23 -0
  28. data/app/models/fluentd/setting/buffer_memory.rb +17 -0
  29. data/app/models/fluentd/setting/formatter_csv.rb +21 -0
  30. data/app/models/fluentd/setting/formatter_hash.rb +19 -0
  31. data/app/models/fluentd/setting/formatter_json.rb +25 -0
  32. data/app/models/fluentd/setting/formatter_ltsv.rb +21 -0
  33. data/app/models/fluentd/setting/formatter_msgpack.rb +13 -0
  34. data/app/models/fluentd/setting/formatter_out_file.rb +21 -0
  35. data/app/models/fluentd/setting/formatter_single_value.rb +20 -0
  36. data/app/models/fluentd/setting/formatter_stdout.rb +19 -0
  37. data/app/models/fluentd/setting/formatter_tsv.rb +21 -0
  38. data/app/models/fluentd/setting/in_forward.rb +7 -17
  39. data/app/models/fluentd/setting/in_http.rb +13 -19
  40. data/app/models/fluentd/setting/in_monitor_agent.rb +6 -19
  41. data/app/models/fluentd/setting/in_syslog.rb +14 -12
  42. data/app/models/fluentd/setting/in_tail.rb +7 -84
  43. data/app/models/fluentd/setting/out_elasticsearch.rb +12 -21
  44. data/app/models/fluentd/setting/out_forward.rb +22 -66
  45. data/app/models/fluentd/setting/out_mongo.rb +20 -26
  46. data/app/models/fluentd/setting/out_s3.rb +18 -30
  47. data/app/models/fluentd/setting/out_stdout.rb +21 -18
  48. data/app/models/fluentd/setting/out_tdlog.rb +35 -0
  49. data/app/models/fluentd/setting/parser_apache.rb +13 -0
  50. data/app/models/fluentd/setting/parser_apache2.rb +13 -0
  51. data/app/models/fluentd/setting/parser_apache_error.rb +13 -0
  52. data/app/models/fluentd/setting/parser_csv.rb +22 -0
  53. data/app/models/fluentd/setting/parser_in_http.rb +13 -0
  54. data/app/models/fluentd/setting/parser_json.rb +25 -0
  55. data/app/models/fluentd/setting/parser_ltsv.rb +30 -0
  56. data/app/models/fluentd/setting/parser_msgpack.rb +13 -0
  57. data/app/models/fluentd/setting/parser_multiline.rb +24 -0
  58. data/app/models/fluentd/setting/parser_nginx.rb +13 -0
  59. data/app/models/fluentd/setting/parser_none.rb +19 -0
  60. data/app/models/fluentd/setting/parser_regexp.rb +26 -0
  61. data/app/models/fluentd/setting/parser_syslog.rb +29 -0
  62. data/app/models/fluentd/setting/parser_tsv.rb +19 -0
  63. data/app/models/fluentd/setting/section.rb +38 -0
  64. data/app/models/fluentd/setting/storage_local.rb +22 -0
  65. data/app/models/fluentd/setting/type/array.rb +17 -0
  66. data/app/models/fluentd/setting/type/bool.rb +18 -0
  67. data/app/models/fluentd/setting/type/enum.rb +17 -0
  68. data/app/models/fluentd/setting/type/hash.rb +17 -0
  69. data/app/models/fluentd/setting/type/regexp.rb +17 -0
  70. data/app/models/fluentd/setting/type/section.rb +17 -0
  71. data/app/models/fluentd/setting/type/size.rb +17 -0
  72. data/app/models/fluentd/setting/type/time.rb +17 -0
  73. data/app/views/api/settings/_element.json.jbuilder +1 -1
  74. data/app/views/fluentd/settings/in_forward/_form.html.haml +16 -0
  75. data/app/views/fluentd/settings/in_tail/_form.html.haml +22 -29
  76. data/app/views/fluentd/settings/in_tail/after_file_choose.html.haml +1 -1
  77. data/app/views/fluentd/settings/in_tail/after_format.html.haml +4 -4
  78. data/app/views/fluentd/settings/in_tail/confirm.html.haml +5 -5
  79. data/app/views/fluentd/settings/source_and_output.html.haml +1 -1
  80. data/app/views/shared/_global_nav.html.erb +8 -8
  81. data/app/views/shared/settings/_form.html.haml +40 -9
  82. data/app/views/shared/settings/show.html.haml +4 -1
  83. data/app/views/shared/vue/_in_tail_parse.html.haml +20 -0
  84. data/app/views/shared/vue/_owned_plugin_form.html.haml +68 -0
  85. data/app/views/shared/vue/_parser_multiline_form.html.haml +19 -0
  86. data/app/views/shared/vue/_setting.html.erb +1 -1
  87. data/config/application.rb +1 -1
  88. data/config/environment.rb +3 -0
  89. data/config/initializers/types.rb +7 -0
  90. data/config/routes.rb +2 -1
  91. data/fluentd-ui.gemspec +5 -0
  92. data/lib/fluentd-ui/version.rb +1 -1
  93. data/lib/regexp_preview.rb +2 -2
  94. data/lib/regexp_preview/multi_line.rb +53 -63
  95. data/lib/regexp_preview/single_line.rb +40 -46
  96. data/spec/features/fluentd/setting/out_forward_spec.rb +1 -1
  97. data/spec/features/fluentd/setting/out_stdout_spec.rb +1 -1
  98. data/spec/features/{out_td_spec.rb → out_tdlog_spec.rb} +3 -3
  99. data/spec/lib/regexp_preview/multi_line_spec.rb +29 -34
  100. data/spec/lib/regexp_preview/single_line_spec.rb +89 -87
  101. data/spec/models/fluentd/setting/in_forward_spec.rb +75 -0
  102. data/spec/models/fluentd/setting/in_http_spec.rb +31 -0
  103. data/spec/models/fluentd/setting/in_monitor_agent_spec.rb +31 -0
  104. data/spec/models/fluentd/setting/in_syslog_spec.rb +65 -7
  105. data/spec/models/fluentd/setting/in_tail_spec.rb +47 -0
  106. data/spec/models/fluentd/setting/out_elasticsearch_spec.rb +31 -0
  107. data/spec/models/fluentd/setting/out_mongo_spec.rb +35 -12
  108. data/spec/models/fluentd/setting/out_s3_spec.rb +128 -0
  109. data/spec/models/fluentd/setting/out_stdout_spec.rb +31 -0
  110. data/spec/models/fluentd/setting/out_tdlog_spec.rb +47 -0
  111. metadata +164 -38
  112. data/app/controllers/fluentd/settings/out_td_controller.rb +0 -18
  113. data/app/helpers/fluentd/settings_helper.rb +0 -2
  114. data/app/javascript/packs/in_tail_format.js +0 -174
  115. data/app/models/fluentd/setting/common.rb +0 -185
  116. data/app/models/fluentd/setting/out_td.rb +0 -48
  117. data/app/views/shared/vue/_in_tail_format.html.erb +0 -43
  118. data/spec/models/fluentd/setting/common_spec.rb +0 -178
  119. 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>
@@ -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
 
@@ -1,5 +1,8 @@
1
1
  # Load the Rails application.
2
2
  require_relative 'application'
3
3
 
4
+ # Load fluentd libraries & plugins
5
+ require "fluent/load"
6
+
4
7
  # Initialize the Rails application.
5
8
  Rails.application.initialize!
@@ -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 :out_td, only: [:show], module: :settings, controller: :out_td do
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
@@ -1,3 +1,3 @@
1
1
  module FluentdUI
2
- VERSION = "1.0.0.alpha.2"
2
+ VERSION = "1.0.0.alpha.3"
3
3
  end
@@ -6,8 +6,8 @@ require "regexp_preview/single_line"
6
6
  require "regexp_preview/multi_line"
7
7
 
8
8
  module RegexpPreview
9
- def self.processor(format)
10
- case format
9
+ def self.processor(parse_type)
10
+ case parse_type
11
11
  when "multiline"
12
12
  RegexpPreview::MultiLine
13
13
  else
@@ -1,80 +1,70 @@
1
1
  module RegexpPreview
2
2
  class MultiLine
3
- attr_reader :file, :format, :params
3
+ attr_reader :path, :plugin_name, :plugin_config, :plugin
4
4
 
5
- def initialize(file, format, params = {})
6
- @file = file
7
- @format = format
8
- @params = params[:params]
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 matches_json
16
+ def matches
12
17
  {
13
- params: {
14
- setting: { # for vue.js
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 matches
26
- return [] if patterns.empty?
27
- reader = FileReverseReader.new(File.open(file))
28
- result = []
29
- target_lines = reader.tail(Settings.in_tail_preview_line_count).map{|line| line << "\n" }
30
- whole_string = target_lines.join
31
- re_firstline = Regexp.new(params[:format_firstline])
32
- indexes = []
33
- cur = 0
34
- while first_index = whole_string.index(re_firstline, cur)
35
- indexes << first_index
36
- cur = first_index + 1
37
- end
38
- indexes.each_with_index do |index, i|
39
- next_index = indexes[i + 1] || -1
40
- chunk = whole_string[index...next_index]
41
- ret = detect_chunk(chunk)
42
- next unless ret
43
- result << ret
44
- end
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
- whole << match[0]
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 :file, :format, :params, :regexp, :time_format
3
+ attr_reader :path, :plugin_name, :plugin_config, :plugin
4
4
 
5
- def initialize(file, format, params = {})
6
- @file = file
7
- @format = format
8
- @time_format = params[:time_format]
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
- case format
12
- when "regexp"
13
- @regexp = Regexp.new(params[:regexp])
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 matches_json
16
+ def matches
28
17
  {
29
- params: {
30
- setting: {
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 matches
43
- return [] unless @regexp # such as ltsv, json, etc
44
- reader = FileReverseReader.new(File.open(file))
45
- matches = reader.tail(Settings.in_tail_preview_line_count).map do |line|
46
- result = {
47
- :whole => line,
48
- :matches => [],
49
- }
50
- match = line.match(regexp)
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
- result
54
+ ensure
55
+ io.close
61
56
  end
62
- matches
63
57
  end
64
58
  end
65
59
  end
@@ -6,7 +6,7 @@ describe "out_forward", stub: :daemon do
6
6
  let(:type) { "out_forward" }
7
7
  let(:page_url) { send("daemon_setting_#{type}_path") }
8
8
  let(:form_values) { {
9
- Match: "*",
9
+ Pattern: "*",
10
10
  Name: "name",
11
11
  Host: "host",
12
12
  Port: "9999",
@@ -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", "match", "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 "out_td", stub: :daemon do
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 daemon_setting_out_td_path
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 daemon_setting_out_td_path
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 "#matches_json" do
5
- subject { parser.matches_json }
6
- let(:parser) { RegexpPreview::MultiLine.new(target_path, "multiline", params) }
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 :params do
12
- params = {
13
- format_firstline: "foo",
14
- time_format: "time_format",
11
+ let :plugin_config do
12
+ plugin_config = {
13
+ "format_firstline" => "/foo/",
14
+ "time_format" => "time_format",
15
15
  }
16
- params["format1"] = "(?<foo>foo)\n"
17
- params["format2"] = "(?<bar>bar)"
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
- params["format#{i}"] = ""
19
+ plugin_config["format#{i}"] = "//"
20
20
  end
21
- { params: params }
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(:params) do
48
- params = {
49
- format_firstline: "foo",
50
- time_format: "time_format",
42
+ let(:plugin_config) do
43
+ plugin_config = {
44
+ "format_firstline" => "/foo/",
45
+ "time_format" => "time_format",
51
46
  }
52
- params["format1"] = "(?<foo>foo)\n"
53
- params["format2"] = "(?<bar>baz)"
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
- params["format#{i}"] = ""
50
+ plugin_config["format#{i}"] = "//"
56
51
  end
57
- { params: params }
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 :params do
70
- params = {
71
- format_firstline: "\\d{4}-\\d{1,2}-\\d{1,2}",
72
- "format1" => "^(?<time>\\d{4}-\\d{1,2}-\\d{1,2} \\d{1,2}:\\d{1,2}:\\d{1,2}) \\[(?<thread>.*)\\] (?<level>[^\\s]+)(?<message>.*)",
73
- time_format: "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
- params["format#{i}"] = ""
72
+ plugin_config["format#{i}"] = "//"
77
73
  end
78
- { params: params }
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: [