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
@@ -1,32 +1,34 @@
1
1
  class Fluentd
2
2
  module Setting
3
3
  class InSyslog
4
- include ActiveModel::Model
5
- include Common
4
+ include Fluentd::Setting::Plugin
6
5
 
7
- KEYS = [
8
- :port, :bind, :tag, :types
9
- ].freeze
10
-
11
- attr_accessor(*KEYS)
12
-
13
- validates :tag, presence: true
6
+ register_plugin("input", "syslog")
14
7
 
15
8
  def self.initial_params
16
9
  {
17
10
  bind: "0.0.0.0",
18
11
  port: 5140,
12
+ parse_type: "syslog",
13
+ parse: {
14
+ "0" => {
15
+ "type" => "syslog"
16
+ }
17
+ },
18
+ protocol_type: :udp,
19
19
  }
20
20
  end
21
21
 
22
22
  def common_options
23
23
  [
24
- :tag, :bind, :port, :types,
24
+ :tag, :bind, :port
25
25
  ]
26
26
  end
27
27
 
28
- def advanced_options
29
- []
28
+ def hidden_options
29
+ [
30
+ :parse
31
+ ]
30
32
  end
31
33
  end
32
34
  end
@@ -1,38 +1,16 @@
1
+ require "fluent/plugin/parser_multiline"
2
+
1
3
  class Fluentd
2
4
  module Setting
3
5
  class InTail
4
- MULTI_LINE_MAX_FORMAT_COUNT = 20
5
-
6
- include ActiveModel::Model
7
- attr_accessor :path, :tag, :format, :regexp, :time_format, :rotate_wait, :pos_file, :read_from_head, :refresh_interval
8
-
9
- validates :path, presence: true
10
- validates :tag, presence: true
11
- #validates :format, presence: true
6
+ include Fluentd::Setting::Plugin
12
7
 
13
- def self.known_formats
14
- {
15
- :apache2 => [:time_format],
16
- :nginx => [:time_format],
17
- :syslog => [:time_format],
18
- :tsv => [:keys, :time_key],
19
- :csv => [:keys, :time_key],
20
- :ltsv => [:delimiter, :time_key],
21
- :json => [:time_key],
22
- :regexp => [:time_format, :regexp],
23
- :multiline => [:format_firstline] + (1..MULTI_LINE_MAX_FORMAT_COUNT).map{|n| "format#{n}".to_sym }
24
- # TODO: Grok could generate Regexp including \d, \s, etc. fluentd config parser raise error with them for escape sequence check.
25
- # TBD How to handle Grok/Regexp later, just comment out for hide
26
- # :grok => [:grok_str],
27
- }
28
- end
29
- attr_accessor *known_formats.values.flatten.compact.uniq
8
+ register_plugin("input", "tail")
9
+ # TODO support formatN ???
30
10
 
31
- def known_formats
32
- self.class.known_formats
33
- end
11
+ MULTI_LINE_MAX_FORMAT_COUNT = ::Fluent::Plugin::MultilineParser::FORMAT_MAX_NUM
34
12
 
35
- def guess_format
13
+ def guess_parse_type
36
14
  case path
37
15
  when /\.json$/
38
16
  :json
@@ -53,43 +31,6 @@ class Fluentd
53
31
  end
54
32
  end
55
33
 
56
- def extra_format_options
57
- self.class.known_formats[format.to_sym] || []
58
- end
59
-
60
- def format_specific_conf
61
- return "" if %w(grok regexp).include?(format)
62
-
63
- indent = " " * 2
64
- format_specific_conf = ""
65
-
66
- if format.to_sym == :multiline
67
- known_formats[:multiline].each do |key|
68
- value = send(key)
69
- if value.present?
70
- format_specific_conf << "#{indent}#{key} /#{value}/\n"
71
- end
72
- end
73
- else
74
- extra_format_options.each do |key|
75
- format_specific_conf << "#{indent}#{key} #{send(key)}\n"
76
- end
77
- end
78
-
79
- format_specific_conf
80
- end
81
-
82
- def certain_format_line
83
- case format
84
- when "grok"
85
- "format /#{grok.convert_to_regexp(grok_str).source.gsub("/", "\\/")}/ # grok: '#{grok_str}'"
86
- when "regexp"
87
- "format /#{regexp}/"
88
- else
89
- "format #{format}"
90
- end
91
- end
92
-
93
34
  def grok
94
35
  @grok ||=
95
36
  begin
@@ -98,24 +39,6 @@ class Fluentd
98
39
  grok
99
40
  end
100
41
  end
101
-
102
- def to_conf
103
- # NOTE: Using strip_heredoc makes more complex for format_specific_conf indent
104
- <<-CONFIG.gsub(/^[ ]*\n/m, "")
105
- <source>
106
- type tail
107
- path #{path}
108
- tag #{tag}
109
- #{certain_format_line}
110
- #{format_specific_conf}
111
-
112
- #{read_from_head.to_i.zero? ? "" : "read_from_head true"}
113
- #{pos_file.present? ? "pos_file #{pos_file}" : ""}
114
- #{rotate_wait.present? ? "rotate_wait #{rotate_wait}" : ""}
115
- #{refresh_interval.present? ? "refresh_interval #{refresh_interval}" : ""}
116
- </source>
117
- CONFIG
118
- end
119
42
  end
120
43
  end
121
44
  end
@@ -1,24 +1,9 @@
1
1
  class Fluentd
2
2
  module Setting
3
3
  class OutElasticsearch
4
- include Common
4
+ include Fluentd::Setting::Plugin
5
5
 
6
- KEYS = [
7
- :match,
8
- :host, :port, :index_name, :type_name,
9
- :logstash_format, :logstash_prefix, :logstash_dateformat, :utc_index,
10
- :hosts, :request_timeout, :include_tag_key
11
- ].freeze
12
-
13
- attr_accessor(*KEYS)
14
-
15
- booleans :logstash_format, :utc_index, :include_tag_key
16
-
17
- validates :match, presence: true
18
- validates :host, presence: true
19
- validates :port, presence: true
20
- validates :index_name, presence: true
21
- validates :type_name, presence: true
6
+ register_plugin("output", "elasticsearch")
22
7
 
23
8
  def self.initial_params
24
9
  {
@@ -29,20 +14,26 @@ class Fluentd
29
14
  logstash_format: true,
30
15
  include_tag_key: false,
31
16
  utc_index: true,
17
+ buffer_type: "file",
18
+ buffer: {
19
+ "0" => {
20
+ "type" => "file",
21
+ "path" => "/var/log/td-agent/buffer/elasticsearch",
22
+ }
23
+ },
32
24
  }
33
25
  end
34
26
 
35
27
  def common_options
36
28
  [
37
- :match, :host, :port, :logstash_format,
29
+ :pattern, :host, :port, :logstash_format,
38
30
  :index_name, :type_name,
39
31
  ]
40
32
  end
41
33
 
42
- def advanced_options
34
+ def hidden_options
43
35
  [
44
- :hosts, :logstash_prefix, :logstash_dateformat,
45
- :utc_index, :request_timeout, :include_tag_key,
36
+ :secondary, :inject, :buffer
46
37
  ]
47
38
  end
48
39
  end
@@ -1,91 +1,47 @@
1
1
  class Fluentd
2
2
  module Setting
3
3
  class OutForward
4
- class Server
5
- include Common
6
- KEYS = [
7
- :name, :host, :port, :weight, :standby
8
- ].freeze
4
+ include Fluentd::Setting::Plugin
9
5
 
10
- attr_accessor(*KEYS)
6
+ register_plugin("output", "forward")
11
7
 
12
- flags :standby
13
-
14
- validates :host, presence: true
15
- validates :port, presence: true
16
- end
17
-
18
- class Secondary
19
- include Common
20
- KEYS = [
21
- :type, :path
22
- ].freeze
23
-
24
- attr_accessor(*KEYS)
25
-
26
- hidden :type
27
- validates :path, presence: true
28
- end
29
-
30
- include Common
31
-
32
- KEYS = [
33
- :match,
34
- :send_timeout, :recover_wait, :heartbeat_type, :heartbeat_interval,
35
- :phi_threshold, :hard_timeout,
36
- :server, :secondary
37
- ].freeze
38
-
39
- attr_accessor(*KEYS)
40
- choice :heartbeat_type, %w(udp tcp)
41
- nested :server, Server, multiple: true
42
- nested :secondary, Secondary
43
-
44
- validates :match, presence: true
45
- validate :validate_has_at_least_one_server
46
- validate :validate_nested_values
47
-
48
- def validate_has_at_least_one_server
49
- if children_of(:server).reject{|s| s.empty_value? }.blank?
50
- errors.add(:base, :out_forward_blank_server)
51
- end
52
- end
53
-
54
- def validate_nested_values
55
- self.class.children.inject(true) do |result, (key, _)|
56
- children_of(key).each do |child|
57
- if !child.empty_value? && !child.valid?
58
- child.errors.full_messages.each do |message|
59
- errors.add(:base, "(#{key})#{message}")
60
- end
61
- result = false
62
- end
63
- result
64
- end
65
- result
66
- end
8
+ config_section :secondary do
9
+ config_param :path, :string
67
10
  end
68
11
 
69
12
  def self.initial_params
70
13
  {
14
+ buffer_type: "memory",
15
+ buffer: {
16
+ "0" => {
17
+ "type" => "memory",
18
+ }
19
+ },
71
20
  secondary: {
72
21
  "0" => {
73
- type: "file",
22
+ "type" => "file",
74
23
  }
75
24
  }
76
25
  }
77
26
  end
78
27
 
28
+ # TODO overwrite this method to support transport parameter and transport section
29
+ # def self.permit_params
30
+ # super
31
+ # end
32
+
79
33
  def common_options
80
34
  [
81
- :match, :server, :secondary,
35
+ :pattern, :server, :secondary,
82
36
  ]
83
37
  end
84
38
 
85
- def advanced_options
39
+ def hidden_options
86
40
  [
87
- :send_timeout, :recover_wait, :heartbeat_type, :heartbeat_interval,
88
- :phi_threshold, :hard_timeout,
41
+ :inject, :buffer,
42
+ :host, :port,
43
+ # We don't support TLS configuration via fluentd-ui for now.
44
+ :transport, :tls_version, :tls_ciphers, :tls_insecure_mode, :tls_verify_hostname, :tls_cert_path
89
45
  ]
90
46
  end
91
47
  end
@@ -1,34 +1,20 @@
1
1
  class Fluentd
2
2
  module Setting
3
3
  class OutMongo
4
- include Common
4
+ include Fluentd::Setting::Plugin
5
5
 
6
- KEYS = [
7
- :match,
8
- :host, :port, :database, :collection, :capped, :capped_size, :capped_max, :user, :password, :tag_mapped,
9
- :buffer_type, :buffer_path, :buffer_queue_limit, :buffer_chunk_limit, :flush_interval, :retry_wait, :retry_limit, :max_retry_wait, :num_threads,
10
- ].freeze
6
+ register_plugin("output", "mongo")
7
+ config_param(:capped, :bool, default: false)
8
+ config_param(:capped_size, :size, default: nil)
11
9
 
12
- attr_accessor(*KEYS)
13
-
14
- flags :capped, :tag_mapped
15
-
16
- validates :match, presence: true
17
- validates :host, presence: true
18
- validates :port, presence: true
10
+ # NOTE: fluent-plugin-mongo defines database parameter as required parameter
11
+ # But Fluentd tells us that the database parameter is not required.
19
12
  validates :database, presence: true
20
- validate :validate_capped
21
13
  validate :validate_collection
22
- validates :buffer_path, presence: true, if: ->{ buffer_type == "file" }
23
-
24
- def validate_capped
25
- return true if capped.blank?
26
- errors.add(:capped_size, :blank) if capped_size.blank?
27
- end
28
14
 
29
15
  def validate_collection
30
16
  if tag_mapped.blank? && collection.blank?
31
- errors.add(:collection, :blank)
17
+ errors.add(:collection, :blank)
32
18
  end
33
19
  end
34
20
 
@@ -38,20 +24,28 @@ class Fluentd
38
24
  port: 27017,
39
25
  capped: true,
40
26
  capped_size: "100m",
41
- }
27
+ buffer_type: "file",
28
+ buffer: {
29
+ "0" => {
30
+ "type" => "file",
31
+ "path" => "/var/log/td-agent/buffer/mongo",
32
+ }
33
+ },
34
+ }
42
35
  end
43
36
 
44
37
  def common_options
45
38
  [
46
- :match, :host, :port, :database, :collection,
39
+ :pattern, :host, :port, :database, :collection,
47
40
  :tag_mapped, :user, :password,
48
41
  ]
49
42
  end
50
43
 
51
- def advanced_options
44
+ def hidden_options
52
45
  [
53
- :capped, :capped_size, :capped_max, :buffer_type, :buffer_path, :buffer_queue_limit, :buffer_chunk_limit,
54
- :flush_interval, :retry_wait, :retry_limit, :max_retry_wait, :num_threads,
46
+ :secondary, :inject, :buffer,
47
+ :include_tag_key,
48
+ :include_time_key
55
49
  ]
56
50
  end
57
51
  end
@@ -1,51 +1,39 @@
1
1
  class Fluentd
2
2
  module Setting
3
3
  class OutS3
4
- include ActiveModel::Model
5
- include Common
4
+ include Fluentd::Setting::Plugin
6
5
 
7
- KEYS = [
8
- :match,
9
- :aws_key_id, :aws_sec_key, :s3_bucket, :s3_region, :path,
10
- # :reduced_redundancy, :check_apikey_on_start, :command_parameter, # not configurable?
11
- :format, :include_time_key, :time_key, :delimiter, :label_delimiter,
12
- :time_slice_format, :time_slice_wait, :time_format, :utc, :store_as, :proxy_uri, :use_ssl,
13
- :buffer_type, :buffer_path, :buffer_queue_limit, :buffer_chunk_limit, :flush_interval,
14
- :retry_wait, :retry_limit, :max_retry_wait, :num_threads,
15
- ].freeze
16
-
17
- attr_accessor(*KEYS)
18
-
19
- choice :format, %w(out_file json ltsv single_value)
20
- choice :store_as, %w(gzip lzo lzma2 json txt)
21
- choice :buffer_type, %w(memory file)
22
- booleans :include_time_key, :use_ssl
23
- flags :utc
24
-
25
- validates :match, presence: true
26
- validates :s3_bucket, presence: true
27
- validates :buffer_path, presence: true, if: ->{ buffer_type == "file" }
6
+ register_plugin("output", "s3")
28
7
 
29
8
  def self.initial_params
30
9
  {
31
10
  s3_region: "us-west-1",
32
- use_ssl: true,
11
+ buffer_type: "file",
12
+ buffer: {
13
+ "0" => {
14
+ "type" => "file",
15
+ "path" => "/var/log/td-agent/buffer/s3",
16
+ }
17
+ },
18
+ format_type: "out_file",
19
+ format: {
20
+ "0" => {
21
+ "type" => "out_file"
22
+ }
23
+ }
33
24
  }
34
25
  end
35
26
 
36
27
  def common_options
37
28
  [
38
- :match, :aws_key_id, :aws_sec_key,
29
+ :pattern, :aws_key_id, :aws_sec_key,
39
30
  :s3_region, :s3_bucket, :use_ssl, :path,
40
31
  ]
41
32
  end
42
33
 
43
- def advanced_options
34
+ def hidden
44
35
  [
45
- :format, :include_time_key, :time_key, :delimiter, :label_delimiter,
46
- :utc, :time_slice_format, :time_slice_wait, :store_as, :proxy_uri,
47
- :buffer_type, :buffer_path, :buffer_queue_limit, :buffer_chunk_limit, :flush_interval,
48
- :retry_wait, :retry_limit, :max_retry_wait, :num_threads,
36
+ :secondary, :inject, :buffer
49
37
  ]
50
38
  end
51
39
  end