Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Fluentd v1 #238

Merged
merged 137 commits into from
Jun 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
137 commits
Select commit Hold shift + click to select a range
ac8c1fa
Add custom types
okkez May 24, 2018
4f2a06f
Add concerns to define models for fluent-plugin
okkez May 24, 2018
e51c43b
Depend on fluent-plugins
okkez May 24, 2018
a840153
Use new style definition
okkez May 24, 2018
03a5d86
Add specs for previous change
okkez May 24, 2018
1bde0ba
Rename out_td to out_tdlog
okkez May 24, 2018
73ee6dd
Add partial template for in_forward setting
okkez May 14, 2018
f2f8d27
Remove setting_params
okkez May 25, 2018
eab7224
Use plugins' config definition to construct setting form
okkez May 25, 2018
c1398a3
Bundle update
okkez May 28, 2018
a849fde
Remove unused module
okkez May 28, 2018
7c5b420
Log unknown aatributes
okkez May 28, 2018
b7e1ed0
Set atttibutes log_levele aand id
okkez May 28, 2018
d67ed8f
Display type in panel header properly
okkez Apr 24, 2018
6b3584e
Display caret-down sign in front of plugin name
okkez May 28, 2018
9af0361
Use `@type` in default config
okkez May 28, 2018
94de13c
Initialize instance variables when finish
okkez May 28, 2018
58f5ab3
Construct section class properly
okkez May 28, 2018
cecbe74
Overwrite options of config parameters
okkez May 28, 2018
8e11483
Use `pattern` instead of `match`
okkez May 28, 2018
66e7977
Permit `pattern`
okkez May 28, 2018
ea61957
Use Pattern instead of Match
okkez May 28, 2018
3e24f7e
Use out_file as secondary output
okkez May 28, 2018
6993887
Define permit_params to use strong parameters
okkez May 28, 2018
7a09c95
Drop TLS support for now
okkez May 28, 2018
c675753
Set default values to in_monitor_agent
okkez Jun 5, 2018
5971b57
Omit values same as default value when save configuration
okkez Jun 5, 2018
d69aefc
in_http: Organize options
okkez Jun 5, 2018
bae1411
Add margin-top to fluentd.common.finish button
okkez Jun 5, 2018
92dd311
Remove unused module
okkez Jun 5, 2018
f9a0801
Display owned plugin's type as select box
okkez Jun 5, 2018
204c3d9
in_http: Display parse type
okkez Jun 5, 2018
5750349
Add models for parser plugins
okkez Jun 5, 2018
59ac411
Add models for formatter plugins
okkez Jun 5, 2018
893bafa
Indent
okkez Jun 6, 2018
0edf43f
Set class to select
okkez Jun 6, 2018
ed3ede6
Fix typos
okkez Jun 6, 2018
9f75208
Add parser_in_http
okkez Jun 6, 2018
12c5681
Add parameters to some parser plugins
okkez Jun 7, 2018
6128141
Load Fluentd plugins
okkez Jun 7, 2018
0cb0484
Add parse_type and format_type attribute to owner plugins if needed
okkez Jun 7, 2018
f6a3d9d
Add methods to support parse section and format section
okkez Jun 7, 2018
0d01c76
Add FluentdFormBuilder
okkez Jun 7, 2018
5f76e4e
Add partial template for parse and format section
okkez Jun 7, 2018
f1204bd
Use new partial template and form_with
okkez Jun 7, 2018
2e3f242
Add owned_plugin_section.js
okkez Jun 7, 2018
89296a3
Organize some input plugins' parameters
okkez Jun 7, 2018
421cbdd
Avoid unsupported type error
okkez Jun 7, 2018
6ef0380
Add configure action to configure parse/format section
okkez Jun 7, 2018
e4a33d2
Add Fluentd::Setting::Type::Regexp
okkez Jun 7, 2018
adc1284
Define options for parser_regexp
okkez Jun 7, 2018
acf4004
Define options for parser_ltsv
okkez Jun 7, 2018
2061392
Define options for parser_multiline
okkez Jun 7, 2018
35049a7
Define options for parser_none
okkez Jun 7, 2018
448b5fd
Define options for formatter plugins
okkez Jun 7, 2018
9cbc616
Support buffer section
okkez Jun 8, 2018
b14da41
Support storage section
okkez Jun 8, 2018
f4ceb7b
Display description on tooltip
okkez Jun 8, 2018
daf5bf0
Add buffer_type/storage_type attribute to owner plugins that have buf…
okkez Jun 8, 2018
97ef81a
Handle onChange event of buffer/storage section configuration
okkez Jun 8, 2018
c7695cf
Fix errors
okkez Jun 8, 2018
db062ee
Set scope to make shot parameter name
okkez Jun 8, 2018
a6d27c0
Remove unused method
okkez Jun 8, 2018
322bfef
Add Api::ConfigDefinitionsController to fetch plugin definitions
okkez Jun 12, 2018
1e763ac
Enable tooltip
okkez Jun 12, 2018
893cb2f
Use Vue.js component to handle owned plugin configuration
okkez Jun 12, 2018
643a227
Remove unused action
okkez Jun 12, 2018
75f6d0f
Organize tooltip position
okkez Jun 12, 2018
54a9dc5
Remove unused partial templates
okkez Jun 12, 2018
fad62d8
Use new Hash syntax
okkez Jun 12, 2018
b642961
Remove an unused file
okkez Jun 12, 2018
620372d
Extract owned_plugin_form.js
okkez Jun 12, 2018
9d1c4f9
Remove unused methods
okkez Jun 12, 2018
4eb54f0
Rename guess_format -> guess_parse_type
okkez Jun 12, 2018
d80afa5
Fix typos
okkez Jun 12, 2018
6e8f5a2
Set default value to /api/config_definitions' return value
okkez Jun 12, 2018
f194aae
Set default value to owned plugin form
okkez Jun 12, 2018
72d377b
Handle time_key without error
okkez Jun 12, 2018
3a80c94
Render shared/vue/in_tail_parse to set configuration for in_tail's pa…
okkez Jun 12, 2018
089ce6b
Add missing files
okkez Jun 13, 2018
838a3e4
Change argument name format to parse_type
okkez Jun 13, 2018
a0ecbfa
Use v-model for expression and time_format
okkez Jun 13, 2018
a806ac7
Add custom events to handle data changed in child component
okkez Jun 13, 2018
bdea8c7
Follow the parameter name change
okkez Jun 14, 2018
d351691
Fix a typo
okkez Jun 14, 2018
e4e2da3
Use function instead of arrow function
okkez Jun 14, 2018
e2fd7a9
Fix a typo
okkez Jun 14, 2018
c513c35
Change variable name targetFile to path
okkez Jun 14, 2018
38d4fba
Rewrite RegexpPreview::SingleLine using Fluentd's parser plugin instance
okkez Jun 14, 2018
55f7ebe
Follow the previous change
okkez Jun 14, 2018
951b444
Remove useless code
okkez Jun 14, 2018
809c2a0
Fix typos
okkez Jun 14, 2018
b96a6ed
Enable tooltip
okkez Jun 14, 2018
81be779
Rewrite RegexpPreview::MultiLine using Fluentd's parser plugin
okkez Jun 14, 2018
9b0abd9
Remove garbage
okkez Jun 14, 2018
ef9c554
Handle API error
okkez Jun 14, 2018
e6d2c40
Run one Ajax request at once
okkez Jun 14, 2018
cbbd169
Add Vue component for parser_multiline
okkez Jun 15, 2018
81b063a
Use ParserMultilineForm
okkez Jun 15, 2018
076e692
Handle custom event change-formats
okkez Jun 15, 2018
e7580f4
Use underscored name for query parameter
okkez Jun 15, 2018
404f292
Move parse plugin config under plugin_config
okkez Jun 15, 2018
d1781d9
Clear parse plugin configuration when parser plugin type is changed
okkez Jun 15, 2018
39bbcf8
Remove unused methods
okkez Jun 15, 2018
0e4f972
Add format_firstline
okkez Jun 15, 2018
10373a2
Add prepare_plugin_config
okkez Jun 15, 2018
b70cc1c
Set formats and format_firstline to plugin_config
okkez Jun 15, 2018
8c708c0
Remove unused code
okkez Jun 15, 2018
1cd2282
Set empty hash if params[:plugin_config] is null
okkez Jun 15, 2018
fe32983
Remove unused methods
okkez Jun 15, 2018
c55038e
Rescue Fluent::ConfigError
okkez Jun 15, 2018
600d934
Update setting_params to apply strong parameter
okkez Jun 15, 2018
908c4ef
Use local variables instead of instance variables
okkez Jun 15, 2018
8962784
Use form_with instead of form_for
okkez Jun 15, 2018
193fe57
Use FluentdFormBuilder's method
okkez Jun 15, 2018
51e7652
Rename `f` to `form`
okkez Jun 15, 2018
e0557c5
Support options
okkez Jun 15, 2018
90a88ec
Display parser common options
okkez Jun 15, 2018
c8fde46
Indent
okkez Jun 15, 2018
dc44aaf
Add missing hidden field
okkez Jun 15, 2018
f8d1a5c
Use to_config instead of to_conf
okkez Jun 15, 2018
6c36d5e
Use POST instead of XHR
okkez Jun 15, 2018
8644549
Apply changes same as after_format
okkez Jun 15, 2018
2f2b388
Support storage
okkez Jun 15, 2018
215da19
Remove parse_type like attributes from owner plugin configuration
okkez Jun 15, 2018
f1d3269
Dump `@type` attribute of owned plugins
okkez Jun 15, 2018
41b18ff
Add hidden field for owned plugin type
okkez Jun 15, 2018
fce12c5
Display tooltip and guide for parser_multiline
okkez Jun 15, 2018
e766677
Use FluentdFormBuilder
okkez Jun 18, 2018
d58640f
Drop TLS support for now
okkez Jun 18, 2018
15530c2
Handle nested section properly
okkez Jun 18, 2018
2b577a1
Hide hidden options
okkez Jun 18, 2018
05f8952
Simplify markup
okkez Jun 18, 2018
085226e
Use card
okkez Jun 18, 2018
1145123
Remove unnecessary code
okkez Jun 18, 2018
cac3956
Add icon method
okkez Jun 18, 2018
8b77646
Organize initial parameters
okkez Jun 18, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ PATH
bundler
diff-lcs
draper (~> 3.0)
fluent-plugin-elasticsearch (~> 2.10)
fluent-plugin-mongo (~> 1.1)
fluent-plugin-s3 (~> 1.1)
fluent-plugin-td (~> 1.0)
fluentd (>= 1.0.0, < 2)
font-awesome-rails
haml-rails (~> 1.0)
Expand Down Expand Up @@ -74,6 +78,24 @@ GEM
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
arel (9.0.0)
aws-eventstream (1.0.0)
aws-partitions (1.87.0)
aws-sdk-core (3.21.2)
aws-eventstream (~> 1.0)
aws-partitions (~> 1.0)
aws-sigv4 (~> 1.0)
jmespath (~> 1.0)
aws-sdk-kms (1.5.0)
aws-sdk-core (~> 3)
aws-sigv4 (~> 1.0)
aws-sdk-s3 (1.13.0)
aws-sdk-core (~> 3, >= 3.21.2)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.0)
aws-sdk-sqs (1.3.0)
aws-sdk-core (~> 3)
aws-sigv4 (~> 1.0)
aws-sigv4 (1.0.2)
better_errors (2.1.1)
coderay (>= 1.0.0)
erubis (>= 2.6.6)
Expand All @@ -83,6 +105,7 @@ GEM
debug_inspector (>= 0.0.1)
bootsnap (1.3.0)
msgpack (~> 1.0)
bson (4.3.0)
builder (3.2.3)
capybara (3.0.2)
addressable
Expand Down Expand Up @@ -112,14 +135,39 @@ GEM
activemodel-serializers-xml (~> 1.0)
activesupport (~> 5.0)
request_store (~> 1.0)
elasticsearch (6.0.2)
elasticsearch-api (= 6.0.2)
elasticsearch-transport (= 6.0.2)
elasticsearch-api (6.0.2)
multi_json
elasticsearch-transport (6.0.2)
faraday
multi_json
erubi (1.7.1)
erubis (2.7.0)
excon (0.62.0)
factory_bot (4.8.2)
activesupport (>= 3.0.0)
factory_bot_rails (4.8.2)
factory_bot (~> 4.8.2)
railties (>= 3.0.0)
faraday (0.15.2)
multipart-post (>= 1.2, < 3)
ffi (1.9.23)
fluent-plugin-elasticsearch (2.10.1)
elasticsearch
excon
fluentd (>= 0.14.20)
fluent-plugin-mongo (1.1.1)
fluentd (>= 0.14.12, < 2)
mongo (~> 2.2.0)
fluent-plugin-s3 (1.1.3)
aws-sdk-s3 (~> 1.0)
aws-sdk-sqs (~> 1.0)
fluentd (>= 0.14.2, < 2)
fluent-plugin-td (1.0.0)
fluentd (>= 0.14.13, < 2)
td-client (~> 1.0)
fluentd (1.2.1)
cool.io (>= 1.4.5, < 2.0.0)
dig_rb (~> 1.0.0)
Expand Down Expand Up @@ -159,6 +207,7 @@ GEM
jbuilder (2.7.0)
activesupport (>= 4.2.0)
multi_json (>= 1.2)
jmespath (1.4.0)
json (2.1.0)
kramdown (1.16.2)
kramdown-haml (0.0.3)
Expand All @@ -181,8 +230,11 @@ GEM
mini_mime (1.0.0)
mini_portile2 (2.3.0)
minitest (5.11.3)
mongo (2.2.7)
bson (~> 4.0)
msgpack (1.2.4)
multi_json (1.13.1)
multipart-post (2.0.0)
nio4r (2.3.0)
nokogiri (1.8.2)
mini_portile2 (~> 2.3.0)
Expand Down Expand Up @@ -286,6 +338,9 @@ GEM
strptime (0.2.3)
sucker_punch (2.0.4)
concurrent-ruby (~> 1.0.0)
td-client (1.0.6)
httpclient (>= 2.7)
msgpack (>= 0.5.6, < 2)
temple (0.8.0)
thor (0.20.0)
thread_safe (0.3.6)
Expand Down
55 changes: 55 additions & 0 deletions app/controllers/api/config_definitions_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
class Api::ConfigDefinitionsController < ApplicationController
before_action :login_required

def index
name = params[:name]
type = params[:type]
prefix = case type
when "input"
"in"
when "output"
"out"
when "filter"
"filter"
when "parse"
"parser"
when "format"
"formatter"
when "parser", "formatter", "buffer", "storage"
type
end

target_class = Fluentd::Setting.const_get("#{prefix}_#{name}".classify)
target = target_class.new

common_options = target.common_options.map do |key|
h = {
name: key,
type: target.column_type(key),
desc: target.desc(key),
default: target.default(key)
}
h[:list] = target.list_of(key) if target.column_type(key) == :enum
h
end

advanced_options = target.advanced_options.map do |key|
h = {
name: key,
type: target.column_type(key),
desc: target.desc(key),
default: target.default(key)
}
h[:list] = target.list_of(key) if target.column_type(key) == :enum
h
end

options = {
type: type,
name: name,
commonOptions: common_options,
advancedOptions: advanced_options
}
render json: options
end
end
23 changes: 20 additions & 3 deletions app/controllers/api_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,32 @@ def empty_json
end

def regexp_preview
preview = RegexpPreview.processor(params[:format]).new(params[:file], params[:format], params)
plugin_config = prepare_plugin_config || {}
preview = RegexpPreview.processor(params[:parse_type]).new(params[:file], params[:parse_type], plugin_config)

render json: preview.matches_json
render json: preview.matches
rescue Fluent::ConfigError => ex
render json: { error: "#{ex.class}: #{ex.message}" }
end

def grok_to_regexp
grok = GrokConverter.new
grok.load_patterns
render text: grok.convert_to_regexp(params[:grok_str]).source
end
end

private

def prepare_plugin_config
plugin_config = params[:plugin_config]
case params[:parse_type]
when "multiline"
plugin_config[:formats].lines.each.with_index do |line, index|
plugin_config["format#{index + 1}"] = line.chomp
end
plugin_config
else
plugin_config
end
end
end
20 changes: 18 additions & 2 deletions app/controllers/concerns/setting_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,19 @@ module SettingConcern

def show
@setting = target_class.new(initial_params)
@buffer = @setting.create_buffer
@storage = @setting.create_storage
@parser = @setting.create_parser
@formatter = @setting.create_formatter
@_used_param = {}
@_used_section = {}
render "shared/settings/show"
end

def finish
@setting = target_class.new(setting_params)
@_used_param = {}
@_used_section = {}
unless @setting.valid?
return render "shared/settings/show"
end
Expand All @@ -32,15 +40,23 @@ def finish
private

def setting_params
params.require(target_class.to_s.underscore.gsub("/", "_")).permit(*target_class.const_get(:KEYS))
params.require(:setting).permit(*target_class.permit_params)
end

def initial_params
target_class.initial_params
end

def target_plugin_name
target_class.to_s.split("::").last.underscore
prefix = case target_class.plugin_type
when "input"
"in"
when "output"
"out"
else
target_class.plugin_type
end
"#{prefix}_#{target_class.plugin_name}"
end

def plugin_setting_form_action_url(*args)
Expand Down
18 changes: 13 additions & 5 deletions app/controllers/fluentd/settings/in_tail_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ class Fluentd::Settings::InTailController < ApplicationController

def after_file_choose
@setting = Fluentd::Setting::InTail.new({
:path => params[:path],
:tag => nil,
path: params[:path],
tag: nil
})
end

Expand Down Expand Up @@ -38,20 +38,28 @@ def finish
return render "after_format"
end

if @fluentd.agent.configuration.to_s.include?(@setting.to_conf.strip)
if @fluentd.agent.configuration.to_s.include?(@setting.to_config.to_s.strip)
@setting.errors.add(:base, :duplicated_conf)
return render "after_format"
end

@fluentd.agent.config_append @setting.to_conf
@fluentd.agent.config_append @setting.to_config.to_s
@fluentd.agent.restart if @fluentd.agent.running?
redirect_to daemon_setting_path(@fluentd)
end

def target_class
Fluentd::Setting::InTail
end

private

def setting_params
params.require(:setting).permit(:path, :format, :regexp, *Fluentd::Setting::InTail.known_formats, :tag, :rotate_wait, :pos_file, :read_from_head, :refresh_interval)
permit_params = target_class._types.keys
permit_params << :parse_type
section_class = Fluentd::Setting.const_get("parser_#{params.dig(:setting, :parse_type)}".classify)
permit_params << { parse: section_class._types.keys }
params.require(:setting).permit(*permit_params)
end

end
9 changes: 0 additions & 9 deletions app/controllers/fluentd/settings/out_forward_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,4 @@ class Fluentd::Settings::OutForwardController < ApplicationController
def target_class
Fluentd::Setting::OutForward
end

def setting_params
params.require(:fluentd_setting_out_forward).permit(*Fluentd::Setting::OutForward::KEYS).merge(
params.require(:fluentd_setting_out_forward).permit(
:server => Fluentd::Setting::OutForward::Server::KEYS,
:secondary => Fluentd::Setting::OutForward::Secondary::KEYS,
),
)
end
end
5 changes: 0 additions & 5 deletions app/controllers/fluentd/settings/out_s3_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,4 @@ class Fluentd::Settings::OutS3Controller < ApplicationController
def target_class
Fluentd::Setting::OutS3
end

def setting_params
params.require(:fluentd_setting_out_s3).permit(*Fluentd::Setting::OutS3::KEYS)
end

end
18 changes: 0 additions & 18 deletions app/controllers/fluentd/settings/out_td_controller.rb

This file was deleted.

9 changes: 9 additions & 0 deletions app/controllers/fluentd/settings/out_tdlog_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Fluentd::Settings::OutTdlogController < ApplicationController
include SettingConcern

private

def target_class
Fluentd::Setting::OutTdlog
end
end
Loading