in_tail guide to be fluentd/settings/in_tail

This commit is contained in:
uu59 2014-06-30 18:45:27 +09:00
parent e37197bf5c
commit bd1134f9a9
11 changed files with 229 additions and 125 deletions

View File

@ -0,0 +1,58 @@
class Fluentd::Settings::InTailController < ApplicationController
before_action :login_required
before_action :find_fluentd
def after_file_choose
@setting = Fluentd::Setting::InTail.new({
:path => params[:path],
:tag => nil,
})
end
def after_format
@setting = Fluentd::Setting::InTail.new(setting_params)
end
def confirm
@setting = Fluentd::Setting::InTail.new(setting_params)
if params[:back]
return render :after_file_choose
end
unless @setting.valid?
return render :after_format
end
end
def finish
@setting = Fluentd::Setting::InTail.new(setting_params)
if params[:back]
return render :after_format
end
unless @setting.valid?
return render "after_format"
end
if @fluentd.agent.configuration.to_s.include?(@setting.to_conf.strip)
@setting.errors.add(:base, :duplicated_conf)
return render "after_format"
end
File.open(@fluentd.agent.config_file, "a") do |f| # TODO: should update by agent class
f.write "\n"
f.write @setting.to_conf
end
@fluentd.agent.restart if @fluentd.agent.running?
redirect_to fluentd_setting_path(@fluentd)
end
private
def setting_params
setting_params = params.require(:setting).permit(:path, :format, :regexp, *Fluentd::Setting::InTail.known_formats, :tag, :rotate_wait, :pos_file, :read_from_head, :refresh_interval)
{
:pos_file => "/tmp/fluentd-#{@fluentd.id}-#{Time.now.to_i}.pos",
}.merge setting_params
end
end

View File

@ -0,0 +1,43 @@
- @setting.errors.full_messages.each do |e|
%div.alert.alert-danger= e
%div.form-group
= f.label :path
= f.hidden_field :path
= f.text_field :path, class: "form-control", disabled: true
%div.form-group
= f.label :format
= f.hidden_field :format
= f.text_field :format, class: "form-control", disabled: true
- if @setting.known_formats[@setting.format.to_sym]
- @setting.known_formats[@setting.format.to_sym].each do |key|
%label= key
= f.hidden_field key
= @setting.send(key)
%br
- else
%label= @setting.format
= f.hidden_field :regexp
= @setting.regexp
%div.form-group
= f.label :tag
= f.text_field :tag, class: "form-control"
%div.form-group
= f.label :pos_file
= f.text_field :pos_file, class: "form-control"
.well.well-sm
%h4{"data-toggle" => "collapse", "href" => "#advanced-setting"}
= icon('fa-caret-down')
= t('terms.advanced_setting')
#advanced-setting.collapse
%div.form-group
= f.label :rotate_wait
= f.text_field :rotate_wait, class: "form-control"
%div.form-group
= f.label :read_from_head
= f.check_box :read_from_head, class: "form-control"
%div.form-group
= f.label :refresh_interval
= f.text_field :refresh_interval, class: "form-control"

View File

@ -1,8 +1,8 @@
- page_title t(".page_title") - page_title t(".page_title")
= link_to t('fluentd.settings.restart_from_first'), in_tail_fluentd_setting_path = link_to t('fluentd.settings.in_tail.restart_from_first'), fluentd_setting_in_tail_path(@fluentd)
= form_for(@setting, as: "setting", url: in_tail_after_format_fluentd_setting_path(@fluentd)) do |f| = form_for(@setting, as: "setting", url: after_format_fluentd_setting_in_tail_path(@fluentd)) do |f|
- @setting.errors.full_messages.each do |e| - @setting.errors.full_messages.each do |e|
%div.alert.alert-danger= e %div.alert.alert-danger= e
@ -16,4 +16,4 @@
%p %p
= f.submit t('terms.next'), class: "btn btn-lg btn-primary pull-right" = f.submit t('terms.next'), class: "btn btn-lg btn-primary pull-right"
= link_to t('terms.prev'), in_tail_fluentd_setting_path, class: "btn btn-lg btn-default" = link_to t('terms.prev'), fluentd_setting_in_tail_path(@fluentd), class: "btn btn-lg btn-default"

View File

@ -1,8 +1,8 @@
- page_title t(".page_title") - page_title t(".page_title")
= link_to t('fluentd.settings.restart_from_first'), in_tail_fluentd_setting_path = link_to t('fluentd.settings.in_tail.restart_from_first'), fluentd_setting_in_tail_path(@fluentds)
= form_for(@setting, as: "setting", url: in_tail_confirm_fluentd_setting_path(@fluentd)) do |f| = form_for(@setting, as: "setting", url: confirm_fluentd_setting_in_tail_path(@fluentd)) do |f|
= render partial: "form", locals: { f: f } = render partial: "form", locals: { f: f }
%p %p

View File

@ -0,0 +1,13 @@
- page_title t(".page_title")
= link_to t('fluentd.settings.in_tail.restart_from_first'), fluentd_setting_in_tail_path(@fluentd)
= form_for(@setting, as: "setting", url: finish_fluentd_setting_in_tail_path(@fluentd)) do |f|
= render partial: "form", locals: { f: f }
%pre= @setting.to_conf
%p
= f.submit t('fluentd.common.finish') , class: "btn btn-lg btn-primary pull-right"
= f.submit t('terms.prev'), class: "btn btn-lg btn-default", name: "back"
.clearfix.pull-right= t('terms.notice_restart_for_config_edit')

View File

@ -1,4 +1,4 @@
- page_title t(".page_title") - page_title t(".page_title")
= render partial: "shared/vue/treeview", locals: {name: "path", action: in_tail_after_file_choose_fluentd_setting_path(@fluentd), submit_button: t('terms.next')} = render partial: "shared/vue/treeview", locals: {name: "path", action: after_file_choose_fluentd_setting_in_tail_path(@fluentd), submit_button: t('terms.next')}

View File

@ -1,13 +0,0 @@
- page_title t(".page_title")
= link_to t('fluentd.settings.restart_from_first'), in_tail_fluentd_setting_path
= form_for(@setting, as: "setting", url: in_tail_finish_fluentd_setting_path(@fluentd)) do |f|
= render partial: "form", locals: { f: f }
%pre= @setting.to_conf
%p
= f.submit t('.finish') , class: "btn btn-lg btn-primary pull-right"
= f.submit t('terms.prev'), class: "btn btn-lg btn-default", name: "back"
.clearfix.pull-right= t('.notice_restart_for_config_edit')

View File

@ -10,5 +10,6 @@
.row .row
.col-lg-4.well .col-lg-4.well
= link_to icon('fa-file-text-o fa-lg'), in_tail_fluentd_setting_path(@fluentd) = link_to(fluentd_setting_in_tail_path(@fluentd)) do
= link_to t(".setup_in_tail"), in_tail_fluentd_setting_path(@fluentd) = icon('fa-file-text-o fa-lg')
= t("fluentd.common.setup_in_tail")

View File

@ -106,6 +106,15 @@ en:
<<: *fluentd_common <<: *fluentd_common
page_title: fluentd | Log page_title: fluentd | Log
settings: settings:
show:
<<: *fluentd_common
edit:
<<: *fluentd_common
in_tail_option_guide: |
See <a target="_blank" href="http://docs.fluentd.org/articles/in_tail">in_tail Plugin</a> or
<a target="_blank" href="http://fluentular.herokuapp.com/">Fluentular</a> for more details.
in_tail:
<<: *fluentd_common
restart_from_first: Restart from first restart_from_first: Restart from first
grok_manual: | grok_manual: |
<p> <p>
@ -143,23 +152,16 @@ en:
<th>pid</th><td>239</td> <th>pid</th><td>239</td>
</tr> </tr>
</table> </table>
in_tail_option_guide: |
See <a target="_blank" href="http://docs.fluentd.org/articles/in_tail">in_tail Plugin</a> or
<a target="_blank" href="http://fluentular.herokuapp.com/">Fluentular</a> for more details.
show: show:
<<: *fluentd_common <<: *fluentd_common
edit:
<<: *fluentd_common
in_tail:
<<: *fluentd_common
page_title: "File readling | Choosing File" page_title: "File readling | Choosing File"
in_tail_after_file_choose: after_file_choose:
<<: *fluentd_common <<: *fluentd_common
page_title: "File readling | Setting format" page_title: "File readling | Setting format"
in_tail_after_format: after_format:
<<: *fluentd_common <<: *fluentd_common
page_title: "File readling | Other config" page_title: "File readling | Other config"
in_tail_confirm: confirm:
<<: *fluentd_common <<: *fluentd_common
page_title: "File readling | Confirmation" page_title: "File readling | Confirmation"

View File

@ -106,10 +106,17 @@ ja:
<<: *fluentd_common <<: *fluentd_common
page_title: fluentd | ログ page_title: fluentd | ログ
settings: settings:
restart_from_first: 最初からやり直す <<: *fluentd_common
show:
<<: *fluentd_common
edit:
<<: *fluentd_common
in_tail_option_guide: | in_tail_option_guide: |
<a target="_blank" href="http://docs.fluentd.org/ja/articles/in_tail">in_tailプラグインの解説ページ</a>や <a target="_blank" href="http://docs.fluentd.org/ja/articles/in_tail">in_tailプラグインの解説ページ</a>や
<a target="_blank" href="http://fluentular.herokuapp.com/">Fluentular</a>もご参照ください。 <a target="_blank" href="http://fluentular.herokuapp.com/">Fluentular</a>もご参照ください。
in_tail:
<<: *fluentd_common
restart_from_first: 最初からやり直す
grok_manual: | grok_manual: |
<p> <p>
Grokの記法が使えます。例えば<code>%{INT:foo}</code>とすると、<code>/(?&lt;foo&gt;(?:[+-]?(?:[0-9]+)))/</code>という正規表現に変換されます。 Grokの記法が使えます。例えば<code>%{INT:foo}</code>とすると、<code>/(?&lt;foo&gt;(?:[+-]?(?:[0-9]+)))/</code>という正規表現に変換されます。
@ -146,20 +153,12 @@ ja:
</table> </table>
</p> </p>
show: show:
<<: *fluentd_common
edit:
<<: *fluentd_common
in_tail:
<<: *fluentd_common
page_title: "ファイル読み込み | ファイルの選択" page_title: "ファイル読み込み | ファイルの選択"
in_tail_after_file_choose: after_file_choose:
<<: *fluentd_common
page_title: "ファイル読み込み | フォーマットの設定" page_title: "ファイル読み込み | フォーマットの設定"
in_tail_after_format: after_format:
<<: *fluentd_common
page_title: "ファイル読み込み | その他の設定" page_title: "ファイル読み込み | その他の設定"
in_tail_confirm: confirm:
<<: *fluentd_common
page_title: "ファイル読み込み | 確認" page_title: "ファイル読み込み | 確認"
misc: misc:

View File

@ -11,11 +11,12 @@ Rails.application.routes.draw do
get "log_tail" get "log_tail"
end end
resource :setting, only: [:show, :edit, :update], module: :fluentd do resource :setting, only: [:show, :edit, :update], module: :fluentd do
get "in_tail" resource :in_tail, only: ["show"], module: :settings, controller: :in_tail do
post "in_tail_after_file_choose" post "after_file_choose"
post "in_tail_after_format" post "after_format"
post "in_tail_confirm" post "confirm"
post "in_tail_finish" post "finish"
end
end end
end end