diff --git a/app/controllers/fluentd/settings/in_forward_controller.rb b/app/controllers/fluentd/settings/in_forward_controller.rb new file mode 100644 index 0000000..742b86d --- /dev/null +++ b/app/controllers/fluentd/settings/in_forward_controller.rb @@ -0,0 +1,9 @@ +class Fluentd::Settings::InForwardController < ApplicationController + include SettingConcern + + private + + def target_class + Fluentd::Setting::InForward + end +end diff --git a/app/controllers/fluentd/settings/in_http_controller.rb b/app/controllers/fluentd/settings/in_http_controller.rb new file mode 100644 index 0000000..a80a564 --- /dev/null +++ b/app/controllers/fluentd/settings/in_http_controller.rb @@ -0,0 +1,9 @@ +class Fluentd::Settings::InHttpController < ApplicationController + include SettingConcern + + private + + def target_class + Fluentd::Setting::InHttp + end +end diff --git a/app/controllers/fluentd/settings/in_monitor_agent_controller.rb b/app/controllers/fluentd/settings/in_monitor_agent_controller.rb new file mode 100644 index 0000000..19f7e96 --- /dev/null +++ b/app/controllers/fluentd/settings/in_monitor_agent_controller.rb @@ -0,0 +1,9 @@ +class Fluentd::Settings::InMonitorAgentController < ApplicationController + include SettingConcern + + private + + def target_class + Fluentd::Setting::InMonitorAgent + end +end diff --git a/app/controllers/fluentd/settings/out_stdout_controller.rb b/app/controllers/fluentd/settings/out_stdout_controller.rb new file mode 100644 index 0000000..b43f71d --- /dev/null +++ b/app/controllers/fluentd/settings/out_stdout_controller.rb @@ -0,0 +1,9 @@ +class Fluentd::Settings::OutStdoutController < ApplicationController + include SettingConcern + + private + + def target_class + Fluentd::Setting::OutStdout + end +end diff --git a/app/models/fluentd/setting/in_forward.rb b/app/models/fluentd/setting/in_forward.rb new file mode 100644 index 0000000..70627ad --- /dev/null +++ b/app/models/fluentd/setting/in_forward.rb @@ -0,0 +1,44 @@ +class Fluentd + module Setting + class InForward + include ActiveModel::Model + include Common + + KEYS = [ + :bind, :port, :linger_timeout, :chunk_size_limit, :chunk_size_warn_limit, :log_level + ].freeze + + attr_accessor(*KEYS) + + validates :bind, presence: true + validates :port, presence: true + + def self.initial_params + { + bind: "0.0.0.0", + port: 24224, + linger_timeout: 0, + chunk_size_limit: nil, + chunk_size_warn_limit: nil, + log_level: "info", + } + end + + def common_options + [ + :bind, :port + ] + end + + def advanced_options + [ + :linger_timeout, :chunk_size_limit, :chunk_size_warn_limit, :log_level + ] + end + + def plugin_name + "forward" + end + end + end +end diff --git a/app/models/fluentd/setting/in_http.rb b/app/models/fluentd/setting/in_http.rb new file mode 100644 index 0000000..788a37d --- /dev/null +++ b/app/models/fluentd/setting/in_http.rb @@ -0,0 +1,45 @@ +class Fluentd + module Setting + class InHttp + include ActiveModel::Model + include Common + + KEYS = [ + :bind, :port, :body_size_limit, :keepalive_timeout, :add_http_headers, :format, :log_level + ].freeze + + attr_accessor(*KEYS) + + validates :bind, presence: true + validates :port, presence: true + + def self.initial_params + { + bind: "0.0.0.0", + port: 8888, + body_size_limit: "32m", + keepalive_timeout: "10s", + add_http_headers: false, + format: "default", + log_level: "info", + } + end + + def common_options + [ + :bind, :port + ] + end + + def advanced_options + [ + :body_size_limit, :keepalive_timeout, :add_http_headers, :format, :log_level + ] + end + + def plugin_name + "http" + end + end + end +end diff --git a/app/models/fluentd/setting/in_monitor_agent.rb b/app/models/fluentd/setting/in_monitor_agent.rb new file mode 100644 index 0000000..672b604 --- /dev/null +++ b/app/models/fluentd/setting/in_monitor_agent.rb @@ -0,0 +1,38 @@ +class Fluentd + module Setting + class InMonitorAgent + include ActiveModel::Model + include Common + + KEYS = [ + :bind, :port + ].freeze + + attr_accessor(*KEYS) + + validates :bind, presence: true + validates :port, presence: true + + def self.initial_params + { + bind: "0.0.0.0", + port: 24220, + } + end + + def common_options + [ + :bind, :port + ] + end + + def advanced_options + [] + end + + def plugin_name + "monitor_agent" + end + end + end +end diff --git a/app/models/fluentd/setting/out_stdout.rb b/app/models/fluentd/setting/out_stdout.rb new file mode 100644 index 0000000..51ba319 --- /dev/null +++ b/app/models/fluentd/setting/out_stdout.rb @@ -0,0 +1,37 @@ +class Fluentd + module Setting + class OutStdout + include Common + + KEYS = [:match, :output_type].freeze + + attr_accessor(*KEYS) + + choice :output_type, %w(json hash) + + validates :match, presence: true + validates :output_type, inclusion: { in: %w(json hash) } + + def self.initial_params + { + match: "debug.**", + output_type: "json", + } + end + + def common_options + [ + :match, :output_type + ] + end + + def advanced_options + [] + end + + def plugin_name + "stdout" + end + end + end +end diff --git a/app/views/fluentd/settings/source_and_output.html.haml b/app/views/fluentd/settings/source_and_output.html.haml index 28dba99..646a38f 100644 --- a/app/views/fluentd/settings/source_and_output.html.haml +++ b/app/views/fluentd/settings/source_and_output.html.haml @@ -6,14 +6,11 @@ .panel-heading %h4= t('.in') .panel-body - %p - = link_to(daemon_setting_in_tail_path(@fluentd)) do - = icon('fa-file-text-o fa-lg') - = t("fluentd.common.setup_in_tail") - %p - = link_to(daemon_setting_in_syslog_path(@fluentd)) do - = icon('fa-file-text-o fa-lg') - = t("fluentd.common.setup_in_syslog") + - %w|in_tail in_syslog in_monitor_agent in_http in_forward|.each do |type| + %p + = link_to(send("daemon_setting_#{type}_path", @fluentd)) do + = icon('fa-file-text-o fa-lg') + = t("fluentd.common.setup_#{type}") .col-xs-1.arrow-right = icon "fa-arrow-circle-right" .col-xs-2 @@ -25,6 +22,10 @@ .panel-heading %h4= t('.out') .panel-body + %p + = link_to(daemon_setting_out_stdout_path(@fluentd)) do + = icon('fa-file-text-o fa-lg') + = t("fluentd.common.setup_out_stdout") %p = link_to(daemon_setting_out_td_path(@fluentd)) do = icon('fa-file-text-o fa-lg') diff --git a/config/locales/translation_en.yml b/config/locales/translation_en.yml index 6ca673f..288ca63 100644 --- a/config/locales/translation_en.yml +++ b/config/locales/translation_en.yml @@ -97,8 +97,12 @@ en: page_title: "%{label}" setup_in_tail: File setup_in_syslog: Syslog Protocol + setup_in_monitor_agent: Monitoring Agent + setup_in_http: http + setup_in_forward: forward (receiving events from another fluentd) setup_out_td: Treasure Data setup_out_mongo: MongoDB + setup_out_stdout: stdout (log) setup_out_forward: Forwarding setup_out_s3: Amazon S3 setup_out_elasticsearch: Elasticsearch @@ -109,7 +113,7 @@ en: destroy_fluentd_setting: "Delete %{brand} setting" destroy_fluentd_setting_warning: | Delete %{brand} setting. - +

Running %{brand} will be stopped, but log and config file are still exists.

show: page_title: Dashboard @@ -161,11 +165,35 @@ en: For each config parameter, please refer to the MongoDB output plugin documentation page. show: page_title: Add Output to MongoDB + out_stdout: + option_guide: | + Print events to STDOUT (or fluentd log file if launched with daemon mode). Please refer to the stdout output plugin documentation page. + show: + page_title: stdout (log) in_syslog: option_guide: | For each config parameter, please refer to the MongoDB output plugin documentation page. show: page_title: Add Input from Syslog Protocol + in_monitor_agent: + option_guide: | + Monitoring agent returns current fluentd/td-agent setting as JSON via HTTP.
+ Please see refer to the Monitoring Agent documentation page. + show: + page_title: Monitoring Agent (monitor_agent) + in_http: + option_guide: | + Retrieve records from http POST.
+ The URL path becomes the tag of the Fluentd event log and the POSTed body element becomes the record itself.
+ Please see refer to the http Input Plugin documentation page. + show: + page_title: Add http Input Plugin + in_forward: + option_guide: | + Listen to a TCP socket to receive the event stream and an UDP socket to receive heartbeat messages. + Please see refer to the forward Input Plugin documentation page. + show: + page_title: Add forward Input Plugin in_tail_option_guide: | For each config parameter, please refer to the Tail input plugin documentation page. in_tail: diff --git a/config/locales/translation_ja.yml b/config/locales/translation_ja.yml index 0e77d10..239cafd 100644 --- a/config/locales/translation_ja.yml +++ b/config/locales/translation_ja.yml @@ -96,7 +96,11 @@ ja: page_title: "%{label}" setup_in_tail: ファイル setup_in_syslog: syslogプロトコル + setup_in_monitor_agent: 監視エージェント + setup_in_http: http + setup_in_forward: forward(他Fluentdからのイベント受信) setup_out_td: Treasure Data + setup_out_stdout: 標準出力(ログ) setup_out_mongo: MongoDB setup_out_forward: 転送 setup_out_s3: AWS S3 @@ -108,7 +112,7 @@ ja: destroy_fluentd_setting: "%{brand}の設定情報を削除" destroy_fluentd_setting_warning: | %{brand}の設定を削除します。 - +

起動中の%{brand}は停止し、ログや設定ファイルはそのまま残存します。

show: page_title: "ダッシュボード" @@ -162,11 +166,39 @@ ja: out_mongoプラグインの解説もご参照ください。 show: page_title: MongoDB書き出し設定 + out_stdout: + option_guide: | + 標準出力(デーモンとして起動しているときはログファイル)へイベントを書き出します。
+ out_stdoutプラグインの解説もご参照ください。 + show: + page_title: 標準出力(ログ) in_syslog: option_guide: | in_syslogプラグイン解説ページもご参照ください。 show: page_title: Syslog読み込み設定 + in_monitor_agent: + option_guide: | + HTTP経由で現在稼働中のfluentdが使用しているconfigやプラグインをJSONやLTSV形式で取得できます。
+ 監視エージェントのページもご参照ください。 + show: + page_title: 監視エージェント設定(monitor_agent) + in_http: + option_guide: | + http POSTからレコードを取得可能にします。
+ URLパスはFluentdイベントログのタグとなり、ポストされたbody要素はレコードそのものになります。
+ httpインプットプラグイン解説ページもご参照ください。 + show: + page_title: http入力設定 + in_forward: + option_guide: | + TCPソケットをリッスンし、イベントストリームを受信します。
+ UDPソケットもリッスンし、ハートビートメッセージを受信します。
+ 他のFluentdインスタンス、fluent-catコマンドまたはクライアントライブラリーからイベントログを受信するために使用されます。
+ forwardインプットプラグイン解説ページもご参照ください。 + show: + page_title: forward入力設定 + in_tail_option_guide: | in_tailプラグインの解説ページFluentularもご参照ください。 diff --git a/config/routes.rb b/config/routes.rb index c698a5d..ccf0cd6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -28,6 +28,22 @@ Rails.application.routes.draw do post "finish" end + resource :in_monitor_agent, only: [:show], module: :settings, controller: :in_monitor_agent do + post "finish" + end + + resource :in_http, only: [:show], module: :settings, controller: :in_http do + post "finish" + end + + resource :in_forward, only: [:show], module: :settings, controller: :in_forward do + post "finish" + end + + resource :out_stdout, only: [:show], module: :settings, controller: :out_stdout do + post "finish" + end + resource :out_mongo, only: [:show], module: :settings, controller: :out_mongo do post "finish" end diff --git a/spec/features/fluentd/setting/in_forward_spec.rb b/spec/features/fluentd/setting/in_forward_spec.rb new file mode 100644 index 0000000..b668623 --- /dev/null +++ b/spec/features/fluentd/setting/in_forward_spec.rb @@ -0,0 +1,22 @@ +require "spec_helper" + +describe "in_forward", stub: :daemon do + let(:port) { "12345" } + + before { login_with exists_user } + + it "Shown form with filled in td.*.* on match" do + visit daemon_setting_in_forward_path + page.should have_css('input[name="fluentd_setting_in_forward[port]"]') + end + + it "Updated config after submit" do + daemon.agent.config.should_not include(port) + visit daemon_setting_in_forward_path + within('#new_fluentd_setting_in_forward') do + fill_in "Port", with: port + end + click_button I18n.t("fluentd.common.finish") + daemon.agent.config.should include(port) + end +end diff --git a/spec/features/fluentd/setting/in_http_spec.rb b/spec/features/fluentd/setting/in_http_spec.rb new file mode 100644 index 0000000..d2b14ca --- /dev/null +++ b/spec/features/fluentd/setting/in_http_spec.rb @@ -0,0 +1,22 @@ +require "spec_helper" + +describe "in_http", stub: :daemon do + let(:port) { "12345" } + + before { login_with exists_user } + + it "Shown form with filled in td.*.* on match" do + visit daemon_setting_in_http_path + page.should have_css('input[name="fluentd_setting_in_http[port]"]') + end + + it "Updated config after submit" do + daemon.agent.config.should_not include(port) + visit daemon_setting_in_http_path + within('#new_fluentd_setting_in_http') do + fill_in "Port", with: port + end + click_button I18n.t("fluentd.common.finish") + daemon.agent.config.should include(port) + end +end diff --git a/spec/features/fluentd/setting/in_monitor_agent_spec.rb b/spec/features/fluentd/setting/in_monitor_agent_spec.rb new file mode 100644 index 0000000..01660f5 --- /dev/null +++ b/spec/features/fluentd/setting/in_monitor_agent_spec.rb @@ -0,0 +1,22 @@ +require "spec_helper" + +describe "in_monitor_agent", stub: :daemon do + let(:port) { "12345" } + + before { login_with exists_user } + + it "Shown form with filled in td.*.* on match" do + visit daemon_setting_in_monitor_agent_path + page.should have_css('input[name="fluentd_setting_in_monitor_agent[port]"]') + end + + it "Updated config after submit" do + daemon.agent.config.should_not include(port) + visit daemon_setting_in_monitor_agent_path + within('#new_fluentd_setting_in_monitor_agent') do + fill_in "Port", with: port + end + click_button I18n.t("fluentd.common.finish") + daemon.agent.config.should include(port) + end +end diff --git a/spec/features/fluentd/setting/out_stdout_spec.rb b/spec/features/fluentd/setting/out_stdout_spec.rb new file mode 100644 index 0000000..22550ae --- /dev/null +++ b/spec/features/fluentd/setting/out_stdout_spec.rb @@ -0,0 +1,22 @@ +require "spec_helper" + +describe "out_stdout", stub: :daemon do + let(:match) { "stdout.**" } + + before { login_with exists_user } + + it "Shown form with filled in td.*.* on match" do + visit daemon_setting_out_stdout_path + page.should have_css('input[name="fluentd_setting_out_stdout[match]"]') + end + + it "Updated config after submit" do + daemon.agent.config.should_not include(match) + visit daemon_setting_out_stdout_path + within('#new_fluentd_setting_out_stdout') do + fill_in "Match", with: match + end + click_button I18n.t("fluentd.common.finish") + daemon.agent.config.should include(match) + end +end