From f44e6791e72f811d0522f55793cc1608d8588013 Mon Sep 17 00:00:00 2001 From: uu59 Date: Tue, 25 Nov 2014 13:29:33 +0900 Subject: [PATCH 1/8] Add in_monitor_agent setting --- .../settings/in_monitor_agent_controller.rb | 9 +++++ .../fluentd/setting/in_monitor_agent.rb | 38 +++++++++++++++++++ .../settings/source_and_output.html.haml | 4 ++ config/locales/translation_en.yml | 7 ++++ config/locales/translation_ja.yml | 7 ++++ config/routes.rb | 4 ++ .../fluentd/setting/in_monitor_agent_spec.rb | 35 +++++++++++++++++ 7 files changed, 104 insertions(+) create mode 100644 app/controllers/fluentd/settings/in_monitor_agent_controller.rb create mode 100644 app/models/fluentd/setting/in_monitor_agent.rb create mode 100644 spec/features/fluentd/setting/in_monitor_agent_spec.rb 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/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/views/fluentd/settings/source_and_output.html.haml b/app/views/fluentd/settings/source_and_output.html.haml index 28dba99..1164d64 100644 --- a/app/views/fluentd/settings/source_and_output.html.haml +++ b/app/views/fluentd/settings/source_and_output.html.haml @@ -14,6 +14,10 @@ = link_to(daemon_setting_in_syslog_path(@fluentd)) do = icon('fa-file-text-o fa-lg') = t("fluentd.common.setup_in_syslog") + %p + = link_to(daemon_setting_in_monitor_agent_path(@fluentd)) do + = icon('fa-file-text-o fa-lg') + = t("fluentd.common.setup_in_monitor_agent") .col-xs-1.arrow-right = icon "fa-arrow-circle-right" .col-xs-2 diff --git a/config/locales/translation_en.yml b/config/locales/translation_en.yml index 6ca673f..40d3d3b 100644 --- a/config/locales/translation_en.yml +++ b/config/locales/translation_en.yml @@ -97,6 +97,7 @@ en: page_title: "%{label}" setup_in_tail: File setup_in_syslog: Syslog Protocol + setup_in_monitor_agent: Monitoring Agent setup_out_td: Treasure Data setup_out_mongo: MongoDB setup_out_forward: Forwarding @@ -166,6 +167,12 @@ en: 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_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..89f609f 100644 --- a/config/locales/translation_ja.yml +++ b/config/locales/translation_ja.yml @@ -96,6 +96,7 @@ ja: page_title: "%{label}" setup_in_tail: ファイル setup_in_syslog: syslogプロトコル + setup_in_monitor_agent: 監視エージェント setup_out_td: Treasure Data setup_out_mongo: MongoDB setup_out_forward: 転送 @@ -167,6 +168,12 @@ ja: in_syslogプラグイン解説ページもご参照ください。 show: page_title: Syslog読み込み設定 + in_monitor_agent: + option_guide: | + HTTP経由で現在稼働中のfluentdが使用しているconfigやプラグインをJSONやLTSV形式で取得できます。
+ 監視エージェントのページもご参照ください。 + show: + page_title: 監視エージェント設定(monitor_agent) in_tail_option_guide: | in_tailプラグインの解説ページFluentularもご参照ください。 diff --git a/config/routes.rb b/config/routes.rb index c698a5d..d19a35d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -28,6 +28,10 @@ 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 :out_mongo, only: [:show], module: :settings, controller: :out_mongo do post "finish" 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..60d35a7 --- /dev/null +++ b/spec/features/fluentd/setting/in_monitor_agent_spec.rb @@ -0,0 +1,35 @@ +require "spec_helper" + +describe "in_monitor_agent" do + let(:exists_user) { build(:user) } + let(:daemon) { build(:fluentd, variant: "td-agent") } + let(:port) { "12345" } + + before do + Fluentd.stub(:instance).and_return(daemon) + Fluentd::Agent::TdAgent.any_instance.stub(:detached_command).and_return(true) + daemon.agent.config_write "" + + visit '/sessions/new' + within("form") do + fill_in 'session_name', :with => exists_user.name + fill_in 'session_password', :with => exists_user.password + end + click_button I18n.t("terms.sign_in") + end + + 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 From 9ac66f05d35902b9065002cfaccb4764be503080 Mon Sep 17 00:00:00 2001 From: uu59 Date: Tue, 25 Nov 2014 14:06:17 +0900 Subject: [PATCH 2/8] Add out_stdout setting --- .../fluentd/settings/out_stdout_controller.rb | 9 +++++ app/models/fluentd/setting/out_stdout.rb | 37 +++++++++++++++++++ .../settings/source_and_output.html.haml | 4 ++ config/locales/translation_en.yml | 6 +++ config/locales/translation_ja.yml | 7 ++++ config/routes.rb | 4 ++ .../fluentd/setting/out_stdout_spec.rb | 35 ++++++++++++++++++ 7 files changed, 102 insertions(+) create mode 100644 app/controllers/fluentd/settings/out_stdout_controller.rb create mode 100644 app/models/fluentd/setting/out_stdout.rb create mode 100644 spec/features/fluentd/setting/out_stdout_spec.rb 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/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 1164d64..09fa2fb 100644 --- a/app/views/fluentd/settings/source_and_output.html.haml +++ b/app/views/fluentd/settings/source_and_output.html.haml @@ -29,6 +29,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 40d3d3b..283ede8 100644 --- a/config/locales/translation_en.yml +++ b/config/locales/translation_en.yml @@ -100,6 +100,7 @@ en: setup_in_monitor_agent: Monitoring Agent 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 @@ -162,6 +163,11 @@ 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. diff --git a/config/locales/translation_ja.yml b/config/locales/translation_ja.yml index 89f609f..1a9fb1d 100644 --- a/config/locales/translation_ja.yml +++ b/config/locales/translation_ja.yml @@ -98,6 +98,7 @@ ja: setup_in_syslog: syslogプロトコル setup_in_monitor_agent: 監視エージェント setup_out_td: Treasure Data + setup_out_stdout: 標準出力(ログ) setup_out_mongo: MongoDB setup_out_forward: 転送 setup_out_s3: AWS S3 @@ -163,6 +164,12 @@ ja: out_mongoプラグインの解説もご参照ください。 show: page_title: MongoDB書き出し設定 + out_stdout: + option_guide: | + 標準出力(デーモンとして起動しているときはログファイル)へイベントを書き出します。
+ out_stdoutプラグインの解説もご参照ください。 + show: + page_title: 標準出力(ログ) in_syslog: option_guide: | in_syslogプラグイン解説ページもご参照ください。 diff --git a/config/routes.rb b/config/routes.rb index d19a35d..1afcd06 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -32,6 +32,10 @@ Rails.application.routes.draw 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/out_stdout_spec.rb b/spec/features/fluentd/setting/out_stdout_spec.rb new file mode 100644 index 0000000..3d27b0b --- /dev/null +++ b/spec/features/fluentd/setting/out_stdout_spec.rb @@ -0,0 +1,35 @@ +require "spec_helper" + +describe "out_stdout" do + let(:exists_user) { build(:user) } + let(:daemon) { build(:fluentd, variant: "td-agent") } + let(:match) { "stdout.**" } + + before do + Fluentd.stub(:instance).and_return(daemon) + Fluentd::Agent::TdAgent.any_instance.stub(:detached_command).and_return(true) + daemon.agent.config_write "" + + visit '/sessions/new' + within("form") do + fill_in 'session_name', :with => exists_user.name + fill_in 'session_password', :with => exists_user.password + end + click_button I18n.t("terms.sign_in") + end + + 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 From 155e33d6dd078fb17542d046d1600c5ceb97c36e Mon Sep 17 00:00:00 2001 From: hassaku Date: Wed, 3 Dec 2014 12:02:40 +0900 Subject: [PATCH 3/8] Add http input settings. --- .../fluentd/settings/in_http_controller.rb | 9 ++++ app/models/fluentd/setting/in_http.rb | 45 +++++++++++++++++++ .../settings/source_and_output.html.haml | 4 ++ config/locales/translation_en.yml | 10 ++++- config/locales/translation_ja.yml | 10 ++++- config/routes.rb | 4 ++ 6 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 app/controllers/fluentd/settings/in_http_controller.rb create mode 100644 app/models/fluentd/setting/in_http.rb 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/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/views/fluentd/settings/source_and_output.html.haml b/app/views/fluentd/settings/source_and_output.html.haml index 09fa2fb..abf67f0 100644 --- a/app/views/fluentd/settings/source_and_output.html.haml +++ b/app/views/fluentd/settings/source_and_output.html.haml @@ -18,6 +18,10 @@ = link_to(daemon_setting_in_monitor_agent_path(@fluentd)) do = icon('fa-file-text-o fa-lg') = t("fluentd.common.setup_in_monitor_agent") + %p + = link_to(daemon_setting_in_http_path(@fluentd)) do + = icon('fa-file-text-o fa-lg') + = t("fluentd.common.setup_in_http") .col-xs-1.arrow-right = icon "fa-arrow-circle-right" .col-xs-2 diff --git a/config/locales/translation_en.yml b/config/locales/translation_en.yml index 283ede8..b2e6c5b 100644 --- a/config/locales/translation_en.yml +++ b/config/locales/translation_en.yml @@ -98,6 +98,7 @@ en: setup_in_tail: File setup_in_syslog: Syslog Protocol setup_in_monitor_agent: Monitoring Agent + setup_in_http: http setup_out_td: Treasure Data setup_out_mongo: MongoDB setup_out_stdout: stdout (log) @@ -111,7 +112,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 @@ -179,6 +180,13 @@ en: 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_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 1a9fb1d..58c41b1 100644 --- a/config/locales/translation_ja.yml +++ b/config/locales/translation_ja.yml @@ -97,6 +97,7 @@ ja: setup_in_tail: ファイル setup_in_syslog: syslogプロトコル setup_in_monitor_agent: 監視エージェント + setup_in_http: http setup_out_td: Treasure Data setup_out_stdout: 標準出力(ログ) setup_out_mongo: MongoDB @@ -110,7 +111,7 @@ ja: destroy_fluentd_setting: "%{brand}の設定情報を削除" destroy_fluentd_setting_warning: | %{brand}の設定を削除します。 - +

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

show: page_title: "ダッシュボード" @@ -181,6 +182,13 @@ ja: 監視エージェントのページもご参照ください。 show: page_title: 監視エージェント設定(monitor_agent) + in_http: + option_guide: | + http POSTからレコードを取得可能にします。
+ URLパスはFluentdイベントログのタグとなり、ポストされたbody要素はレコードそのものになります。
+ httpインプットプラグイン解説ページもご参照ください。 + show: + page_title: http入力設定 in_tail_option_guide: | in_tailプラグインの解説ページFluentularもご参照ください。 diff --git a/config/routes.rb b/config/routes.rb index 1afcd06..2eb6f93 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -32,6 +32,10 @@ Rails.application.routes.draw do post "finish" end + resource :in_http, only: [:show], module: :settings, controller: :in_http do + post "finish" + end + resource :out_stdout, only: [:show], module: :settings, controller: :out_stdout do post "finish" end From c1a35ffbf41149f6a428355d155e3fcb19065bcf Mon Sep 17 00:00:00 2001 From: hassaku Date: Wed, 3 Dec 2014 13:37:27 +0900 Subject: [PATCH 4/8] Add feature spec for in_http setting. --- spec/features/fluentd/setting/in_http_spec.rb | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 spec/features/fluentd/setting/in_http_spec.rb 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..d890db6 --- /dev/null +++ b/spec/features/fluentd/setting/in_http_spec.rb @@ -0,0 +1,36 @@ +require "spec_helper" + +describe "in_http" do + let(:exists_user) { build(:user) } + let(:daemon) { build(:fluentd, variant: "td-agent") } + let(:port) { "12345" } + + #TODO: wanna DRY with shared_context + before do + Fluentd.stub(:instance).and_return(daemon) + Fluentd::Agent::TdAgent.any_instance.stub(:detached_command).and_return(true) + daemon.agent.config_write "" + + visit '/sessions/new' + within("form") do + fill_in 'session_name', :with => exists_user.name + fill_in 'session_password', :with => exists_user.password + end + click_button I18n.t("terms.sign_in") + end + + 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 From 3b60d85baf66798c1009986424608cfb50a8d6a9 Mon Sep 17 00:00:00 2001 From: hassaku Date: Wed, 3 Dec 2014 14:02:13 +0900 Subject: [PATCH 5/8] Make link to select an input type DRY. --- .../settings/source_and_output.html.haml | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/app/views/fluentd/settings/source_and_output.html.haml b/app/views/fluentd/settings/source_and_output.html.haml index abf67f0..8808de4 100644 --- a/app/views/fluentd/settings/source_and_output.html.haml +++ b/app/views/fluentd/settings/source_and_output.html.haml @@ -6,22 +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") - %p - = link_to(daemon_setting_in_monitor_agent_path(@fluentd)) do - = icon('fa-file-text-o fa-lg') - = t("fluentd.common.setup_in_monitor_agent") - %p - = link_to(daemon_setting_in_http_path(@fluentd)) do - = icon('fa-file-text-o fa-lg') - = t("fluentd.common.setup_in_http") + - %w|in_tail in_syslog in_monitor_agent in_http|.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 From 963307c7b52f300134694e34fba81e39080f73f1 Mon Sep 17 00:00:00 2001 From: hassaku Date: Wed, 3 Dec 2014 14:33:52 +0900 Subject: [PATCH 6/8] Add forward input settings. --- .../fluentd/settings/in_forward_controller.rb | 9 ++++ app/models/fluentd/setting/in_forward.rb | 44 +++++++++++++++++++ .../settings/source_and_output.html.haml | 2 +- config/locales/translation_en.yml | 7 +++ config/locales/translation_ja.yml | 10 +++++ config/routes.rb | 4 ++ 6 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 app/controllers/fluentd/settings/in_forward_controller.rb create mode 100644 app/models/fluentd/setting/in_forward.rb 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/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/views/fluentd/settings/source_and_output.html.haml b/app/views/fluentd/settings/source_and_output.html.haml index 8808de4..646a38f 100644 --- a/app/views/fluentd/settings/source_and_output.html.haml +++ b/app/views/fluentd/settings/source_and_output.html.haml @@ -6,7 +6,7 @@ .panel-heading %h4= t('.in') .panel-body - - %w|in_tail in_syslog in_monitor_agent in_http|.each do |type| + - %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') diff --git a/config/locales/translation_en.yml b/config/locales/translation_en.yml index b2e6c5b..288ca63 100644 --- a/config/locales/translation_en.yml +++ b/config/locales/translation_en.yml @@ -99,6 +99,7 @@ en: 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) @@ -187,6 +188,12 @@ en: 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 58c41b1..239cafd 100644 --- a/config/locales/translation_ja.yml +++ b/config/locales/translation_ja.yml @@ -98,6 +98,7 @@ ja: 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 @@ -189,6 +190,15 @@ ja: 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 2eb6f93..ccf0cd6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -36,6 +36,10 @@ Rails.application.routes.draw 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 From f6a9c4ac5eab664e28ab8ce03dae8042a765225c Mon Sep 17 00:00:00 2001 From: hassaku Date: Wed, 3 Dec 2014 14:38:35 +0900 Subject: [PATCH 7/8] Add feature spec for in_forward setting. --- .../fluentd/setting/in_forward_spec.rb | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 spec/features/fluentd/setting/in_forward_spec.rb 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..b5c6d12 --- /dev/null +++ b/spec/features/fluentd/setting/in_forward_spec.rb @@ -0,0 +1,36 @@ +require "spec_helper" + +describe "in_forward" do + let(:exists_user) { build(:user) } + let(:daemon) { build(:fluentd, variant: "td-agent") } + let(:port) { "12345" } + + #TODO: wanna DRY with shared_context + before do + Fluentd.stub(:instance).and_return(daemon) + Fluentd::Agent::TdAgent.any_instance.stub(:detached_command).and_return(true) + daemon.agent.config_write "" + + visit '/sessions/new' + within("form") do + fill_in 'session_name', :with => exists_user.name + fill_in 'session_password', :with => exists_user.password + end + click_button I18n.t("terms.sign_in") + end + + 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 From 3be2bcb226d79919b8e9d764856cd75585f4fc9a Mon Sep 17 00:00:00 2001 From: hassaku Date: Wed, 3 Dec 2014 15:30:31 +0900 Subject: [PATCH 8/8] Refactor feature specs for settings. --- .../fluentd/setting/in_forward_spec.rb | 18 ++---------------- spec/features/fluentd/setting/in_http_spec.rb | 18 ++---------------- .../fluentd/setting/in_monitor_agent_spec.rb | 17 ++--------------- .../fluentd/setting/out_stdout_spec.rb | 17 ++--------------- 4 files changed, 8 insertions(+), 62 deletions(-) diff --git a/spec/features/fluentd/setting/in_forward_spec.rb b/spec/features/fluentd/setting/in_forward_spec.rb index b5c6d12..b668623 100644 --- a/spec/features/fluentd/setting/in_forward_spec.rb +++ b/spec/features/fluentd/setting/in_forward_spec.rb @@ -1,23 +1,9 @@ require "spec_helper" -describe "in_forward" do - let(:exists_user) { build(:user) } - let(:daemon) { build(:fluentd, variant: "td-agent") } +describe "in_forward", stub: :daemon do let(:port) { "12345" } - #TODO: wanna DRY with shared_context - before do - Fluentd.stub(:instance).and_return(daemon) - Fluentd::Agent::TdAgent.any_instance.stub(:detached_command).and_return(true) - daemon.agent.config_write "" - - visit '/sessions/new' - within("form") do - fill_in 'session_name', :with => exists_user.name - fill_in 'session_password', :with => exists_user.password - end - click_button I18n.t("terms.sign_in") - end + before { login_with exists_user } it "Shown form with filled in td.*.* on match" do visit daemon_setting_in_forward_path diff --git a/spec/features/fluentd/setting/in_http_spec.rb b/spec/features/fluentd/setting/in_http_spec.rb index d890db6..d2b14ca 100644 --- a/spec/features/fluentd/setting/in_http_spec.rb +++ b/spec/features/fluentd/setting/in_http_spec.rb @@ -1,23 +1,9 @@ require "spec_helper" -describe "in_http" do - let(:exists_user) { build(:user) } - let(:daemon) { build(:fluentd, variant: "td-agent") } +describe "in_http", stub: :daemon do let(:port) { "12345" } - #TODO: wanna DRY with shared_context - before do - Fluentd.stub(:instance).and_return(daemon) - Fluentd::Agent::TdAgent.any_instance.stub(:detached_command).and_return(true) - daemon.agent.config_write "" - - visit '/sessions/new' - within("form") do - fill_in 'session_name', :with => exists_user.name - fill_in 'session_password', :with => exists_user.password - end - click_button I18n.t("terms.sign_in") - end + before { login_with exists_user } it "Shown form with filled in td.*.* on match" do visit daemon_setting_in_http_path diff --git a/spec/features/fluentd/setting/in_monitor_agent_spec.rb b/spec/features/fluentd/setting/in_monitor_agent_spec.rb index 60d35a7..01660f5 100644 --- a/spec/features/fluentd/setting/in_monitor_agent_spec.rb +++ b/spec/features/fluentd/setting/in_monitor_agent_spec.rb @@ -1,22 +1,9 @@ require "spec_helper" -describe "in_monitor_agent" do - let(:exists_user) { build(:user) } - let(:daemon) { build(:fluentd, variant: "td-agent") } +describe "in_monitor_agent", stub: :daemon do let(:port) { "12345" } - before do - Fluentd.stub(:instance).and_return(daemon) - Fluentd::Agent::TdAgent.any_instance.stub(:detached_command).and_return(true) - daemon.agent.config_write "" - - visit '/sessions/new' - within("form") do - fill_in 'session_name', :with => exists_user.name - fill_in 'session_password', :with => exists_user.password - end - click_button I18n.t("terms.sign_in") - end + before { login_with exists_user } it "Shown form with filled in td.*.* on match" do visit daemon_setting_in_monitor_agent_path diff --git a/spec/features/fluentd/setting/out_stdout_spec.rb b/spec/features/fluentd/setting/out_stdout_spec.rb index 3d27b0b..22550ae 100644 --- a/spec/features/fluentd/setting/out_stdout_spec.rb +++ b/spec/features/fluentd/setting/out_stdout_spec.rb @@ -1,22 +1,9 @@ require "spec_helper" -describe "out_stdout" do - let(:exists_user) { build(:user) } - let(:daemon) { build(:fluentd, variant: "td-agent") } +describe "out_stdout", stub: :daemon do let(:match) { "stdout.**" } - before do - Fluentd.stub(:instance).and_return(daemon) - Fluentd::Agent::TdAgent.any_instance.stub(:detached_command).and_return(true) - daemon.agent.config_write "" - - visit '/sessions/new' - within("form") do - fill_in 'session_name', :with => exists_user.name - fill_in 'session_password', :with => exists_user.password - end - click_button I18n.t("terms.sign_in") - end + before { login_with exists_user } it "Shown form with filled in td.*.* on match" do visit daemon_setting_out_stdout_path