mirror of
https://github.com/fluent/fluentd-ui.git
synced 2025-08-11 08:47:06 +02:00
in_tail guide to be fluentd/settings/in_tail
This commit is contained in:
parent
e37197bf5c
commit
bd1134f9a9
58
app/controllers/fluentd/settings/in_tail_controller.rb
Normal file
58
app/controllers/fluentd/settings/in_tail_controller.rb
Normal 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
|
43
app/views/fluentd/settings/in_tail/_form.html.haml
Normal file
43
app/views/fluentd/settings/in_tail/_form.html.haml
Normal 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"
|
||||
|
@ -1,8 +1,8 @@
|
||||
- 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|
|
||||
%div.alert.alert-danger= e
|
||||
|
||||
@ -16,4 +16,4 @@
|
||||
|
||||
%p
|
||||
= 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"
|
@ -1,8 +1,8 @@
|
||||
- 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 }
|
||||
|
||||
%p
|
13
app/views/fluentd/settings/in_tail/confirm.html.haml
Normal file
13
app/views/fluentd/settings/in_tail/confirm.html.haml
Normal 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')
|
@ -1,4 +1,4 @@
|
||||
- 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')}
|
||||
|
@ -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')
|
@ -10,5 +10,6 @@
|
||||
|
||||
.row
|
||||
.col-lg-4.well
|
||||
= link_to icon('fa-file-text-o fa-lg'), in_tail_fluentd_setting_path(@fluentd)
|
||||
= link_to t(".setup_in_tail"), in_tail_fluentd_setting_path(@fluentd)
|
||||
= link_to(fluentd_setting_in_tail_path(@fluentd)) do
|
||||
= icon('fa-file-text-o fa-lg')
|
||||
= t("fluentd.common.setup_in_tail")
|
||||
|
@ -106,62 +106,64 @@ en:
|
||||
<<: *fluentd_common
|
||||
page_title: fluentd | Log
|
||||
settings:
|
||||
restart_from_first: Restart from first
|
||||
grok_manual: |
|
||||
<p>
|
||||
Grok syntax, for example, <code>%{INT:foo}</code> pattern given then translate to <code>/(?<foo>(?:[+-]?(?:[0-9]+)))/</code> regexp.
|
||||
</p>
|
||||
<p>
|
||||
Available key/value are <a href="http://grokdebug.herokuapp.com/patterns" target="_blank">here</a>.
|
||||
</p>
|
||||
|
||||
<h4>Example</h4>
|
||||
|
||||
<p>
|
||||
<code>Nov 29 17:02:55 MacBook-Pro-2.local UserEventAgent[239] : cannot find fw daemon port 1102</code> the log you have,<br />
|
||||
<code>%{MONTH:month}%{SPACE}%{MONTHDAY:day} %{TIME:time} %{DATA} \[%{INT:pid}\]</code> for matching that, you will gain following result.
|
||||
</p>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Key</th>
|
||||
<th>Value</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tr>
|
||||
<th>month</th><td>Nov</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>day</th><td>29</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>time</th><td>17:02:55</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>pid</th><td>239</td>
|
||||
</tr>
|
||||
</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:
|
||||
<<: *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
|
||||
page_title: "File readling | Choosing File"
|
||||
in_tail_after_file_choose:
|
||||
<<: *fluentd_common
|
||||
page_title: "File readling | Setting format"
|
||||
in_tail_after_format:
|
||||
<<: *fluentd_common
|
||||
page_title: "File readling | Other config"
|
||||
in_tail_confirm:
|
||||
<<: *fluentd_common
|
||||
page_title: "File readling | Confirmation"
|
||||
restart_from_first: Restart from first
|
||||
grok_manual: |
|
||||
<p>
|
||||
Grok syntax, for example, <code>%{INT:foo}</code> pattern given then translate to <code>/(?<foo>(?:[+-]?(?:[0-9]+)))/</code> regexp.
|
||||
</p>
|
||||
<p>
|
||||
Available key/value are <a href="http://grokdebug.herokuapp.com/patterns" target="_blank">here</a>.
|
||||
</p>
|
||||
|
||||
<h4>Example</h4>
|
||||
|
||||
<p>
|
||||
<code>Nov 29 17:02:55 MacBook-Pro-2.local UserEventAgent[239] : cannot find fw daemon port 1102</code> the log you have,<br />
|
||||
<code>%{MONTH:month}%{SPACE}%{MONTHDAY:day} %{TIME:time} %{DATA} \[%{INT:pid}\]</code> for matching that, you will gain following result.
|
||||
</p>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Key</th>
|
||||
<th>Value</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tr>
|
||||
<th>month</th><td>Nov</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>day</th><td>29</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>time</th><td>17:02:55</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>pid</th><td>239</td>
|
||||
</tr>
|
||||
</table>
|
||||
show:
|
||||
<<: *fluentd_common
|
||||
page_title: "File readling | Choosing File"
|
||||
after_file_choose:
|
||||
<<: *fluentd_common
|
||||
page_title: "File readling | Setting format"
|
||||
after_format:
|
||||
<<: *fluentd_common
|
||||
page_title: "File readling | Other config"
|
||||
confirm:
|
||||
<<: *fluentd_common
|
||||
page_title: "File readling | Confirmation"
|
||||
|
||||
misc:
|
||||
common: &misc_common
|
||||
|
@ -106,61 +106,60 @@ ja:
|
||||
<<: *fluentd_common
|
||||
page_title: fluentd | ログ
|
||||
settings:
|
||||
restart_from_first: 最初からやり直す
|
||||
in_tail_option_guide: |
|
||||
<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>もご参照ください。
|
||||
grok_manual: |
|
||||
<p>
|
||||
Grokの記法が使えます。例えば<code>%{INT:foo}</code>とすると、<code>/(?<foo>(?:[+-]?(?:[0-9]+)))/</code>という正規表現に変換されます。
|
||||
</p>
|
||||
<p>
|
||||
使えるキー・値については<a href="http://grokdebug.herokuapp.com/patterns" target="_blank">リファレンス</a>をご確認ください。
|
||||
</p>
|
||||
<p>
|
||||
<h4>例</h4>
|
||||
|
||||
<code>Nov 29 17:02:55 MacBook-Pro-2.local UserEventAgent[239] : cannot find fw daemon port 1102</code>というログに対し、<br />
|
||||
<code>%{MONTH:month}%{SPACE}%{MONTHDAY:day} %{TIME:time} %{DATA} \[%{INT:pid}\]</code>というパターンを適用すると以下の結果が得られます。
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>キー名</th>
|
||||
<th>値</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tr>
|
||||
<th>month</th><td>Nov</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>day</th><td>29</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>time</th><td>17:02:55</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>pid</th><td>239</td>
|
||||
</tr>
|
||||
</table>
|
||||
</p>
|
||||
<<: *fluentd_common
|
||||
show:
|
||||
<<: *fluentd_common
|
||||
edit:
|
||||
<<: *fluentd_common
|
||||
in_tail_option_guide: |
|
||||
<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>もご参照ください。
|
||||
in_tail:
|
||||
<<: *fluentd_common
|
||||
page_title: "ファイル読み込み | ファイルの選択"
|
||||
in_tail_after_file_choose:
|
||||
<<: *fluentd_common
|
||||
page_title: "ファイル読み込み | フォーマットの設定"
|
||||
in_tail_after_format:
|
||||
<<: *fluentd_common
|
||||
page_title: "ファイル読み込み | その他の設定"
|
||||
in_tail_confirm:
|
||||
<<: *fluentd_common
|
||||
page_title: "ファイル読み込み | 確認"
|
||||
restart_from_first: 最初からやり直す
|
||||
grok_manual: |
|
||||
<p>
|
||||
Grokの記法が使えます。例えば<code>%{INT:foo}</code>とすると、<code>/(?<foo>(?:[+-]?(?:[0-9]+)))/</code>という正規表現に変換されます。
|
||||
</p>
|
||||
<p>
|
||||
使えるキー・値については<a href="http://grokdebug.herokuapp.com/patterns" target="_blank">リファレンス</a>をご確認ください。
|
||||
</p>
|
||||
<p>
|
||||
<h4>例</h4>
|
||||
|
||||
<code>Nov 29 17:02:55 MacBook-Pro-2.local UserEventAgent[239] : cannot find fw daemon port 1102</code>というログに対し、<br />
|
||||
<code>%{MONTH:month}%{SPACE}%{MONTHDAY:day} %{TIME:time} %{DATA} \[%{INT:pid}\]</code>というパターンを適用すると以下の結果が得られます。
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>キー名</th>
|
||||
<th>値</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tr>
|
||||
<th>month</th><td>Nov</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>day</th><td>29</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>time</th><td>17:02:55</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>pid</th><td>239</td>
|
||||
</tr>
|
||||
</table>
|
||||
</p>
|
||||
show:
|
||||
page_title: "ファイル読み込み | ファイルの選択"
|
||||
after_file_choose:
|
||||
page_title: "ファイル読み込み | フォーマットの設定"
|
||||
after_format:
|
||||
page_title: "ファイル読み込み | その他の設定"
|
||||
confirm:
|
||||
page_title: "ファイル読み込み | 確認"
|
||||
|
||||
misc:
|
||||
common: &misc_common
|
||||
|
@ -11,11 +11,12 @@ Rails.application.routes.draw do
|
||||
get "log_tail"
|
||||
end
|
||||
resource :setting, only: [:show, :edit, :update], module: :fluentd do
|
||||
get "in_tail"
|
||||
post "in_tail_after_file_choose"
|
||||
post "in_tail_after_format"
|
||||
post "in_tail_confirm"
|
||||
post "in_tail_finish"
|
||||
resource :in_tail, only: ["show"], module: :settings, controller: :in_tail do
|
||||
post "after_file_choose"
|
||||
post "after_format"
|
||||
post "confirm"
|
||||
post "finish"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user