mirror of
https://github.com/fluent/fluentd-ui.git
synced 2025-08-09 15:57:05 +02:00
Add tutorial chapter 2
This commit is contained in:
parent
dbe8cacd35
commit
7b1e66a7d0
@ -12,6 +12,8 @@ PATH
|
|||||||
i18n_generators (= 1.2.1)
|
i18n_generators (= 1.2.1)
|
||||||
jbuilder (~> 2.0)
|
jbuilder (~> 2.0)
|
||||||
jquery-rails (~> 3.1.0)
|
jquery-rails (~> 3.1.0)
|
||||||
|
kramdown (> 1.0.0)
|
||||||
|
kramdown-haml
|
||||||
puma
|
puma
|
||||||
rails (= 4.1.1)
|
rails (= 4.1.1)
|
||||||
sass-rails (~> 4.0.3)
|
sass-rails (~> 4.0.3)
|
||||||
@ -75,7 +77,7 @@ GEM
|
|||||||
factory_girl_rails (4.4.1)
|
factory_girl_rails (4.4.1)
|
||||||
factory_girl (~> 4.4.0)
|
factory_girl (~> 4.4.0)
|
||||||
railties (>= 3.0.0)
|
railties (>= 3.0.0)
|
||||||
fluentd (0.10.48)
|
fluentd (0.10.49)
|
||||||
cool.io (>= 1.1.1, < 2.0.0, != 1.2.0)
|
cool.io (>= 1.1.1, < 2.0.0, != 1.2.0)
|
||||||
http_parser.rb (>= 0.5.1, < 0.7.0)
|
http_parser.rb (>= 0.5.1, < 0.7.0)
|
||||||
json (>= 1.4.3)
|
json (>= 1.4.3)
|
||||||
@ -107,6 +109,9 @@ GEM
|
|||||||
railties (>= 3.0, < 5.0)
|
railties (>= 3.0, < 5.0)
|
||||||
thor (>= 0.14, < 2.0)
|
thor (>= 0.14, < 2.0)
|
||||||
json (1.8.1)
|
json (1.8.1)
|
||||||
|
kramdown (1.3.3)
|
||||||
|
kramdown-haml (0.0.3)
|
||||||
|
haml
|
||||||
mail (2.5.4)
|
mail (2.5.4)
|
||||||
mime-types (~> 1.16)
|
mime-types (~> 1.16)
|
||||||
treetop (~> 1.4.8)
|
treetop (~> 1.4.8)
|
||||||
@ -215,7 +220,7 @@ GEM
|
|||||||
webrobots (0.1.1)
|
webrobots (0.1.1)
|
||||||
xpath (2.0.0)
|
xpath (2.0.0)
|
||||||
nokogiri (~> 1.3)
|
nokogiri (~> 1.3)
|
||||||
yajl-ruby (1.2.0)
|
yajl-ruby (1.2.1)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
ruby
|
ruby
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
class TutorialsController < ApplicationController
|
class TutorialsController < ApplicationController
|
||||||
before_action :find_fluentd
|
before_action :find_fluentd
|
||||||
|
before_action :check_ready, only: [:chapter1, :chapter2]
|
||||||
helper_method :tutorial_ready?
|
helper_method :tutorial_ready?
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@ -7,7 +8,10 @@ class TutorialsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def chapter1
|
def chapter1
|
||||||
return redirect_to tutorials_url unless tutorial_ready?
|
end
|
||||||
|
|
||||||
|
def chapter2
|
||||||
|
@default_conf = Fluentd::DEFAULT_CONF
|
||||||
end
|
end
|
||||||
|
|
||||||
def log_tail
|
def log_tail
|
||||||
@ -27,6 +31,10 @@ class TutorialsController < ApplicationController
|
|||||||
@fluentd = Fluentd.first
|
@fluentd = Fluentd.first
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_ready
|
||||||
|
return redirect_to tutorials_url unless tutorial_ready?
|
||||||
|
end
|
||||||
|
|
||||||
def tutorial_ready?
|
def tutorial_ready?
|
||||||
@fluentd && @fluentd.agent.running?
|
@fluentd && @fluentd.agent.running?
|
||||||
end
|
end
|
||||||
|
@ -8,6 +8,29 @@ class Fluentd < ActiveRecord::Base
|
|||||||
before_validation :expand_paths
|
before_validation :expand_paths
|
||||||
after_save :ensure_default_config_file
|
after_save :ensure_default_config_file
|
||||||
|
|
||||||
|
DEFAULT_CONF = <<-CONF.strip_heredoc
|
||||||
|
<source>
|
||||||
|
type forward
|
||||||
|
port 24224
|
||||||
|
</source>
|
||||||
|
<source>
|
||||||
|
type monitor_agent
|
||||||
|
port 24220
|
||||||
|
</source>
|
||||||
|
<source>
|
||||||
|
type http
|
||||||
|
port 8888
|
||||||
|
</source>
|
||||||
|
<source>
|
||||||
|
type debug_agent
|
||||||
|
port 24230
|
||||||
|
</source>
|
||||||
|
|
||||||
|
<match debug.*>
|
||||||
|
type stdout
|
||||||
|
</match>
|
||||||
|
CONF
|
||||||
|
|
||||||
def self.variants
|
def self.variants
|
||||||
%w(fluentd td-agent)
|
%w(fluentd td-agent)
|
||||||
end
|
end
|
||||||
@ -82,28 +105,7 @@ class Fluentd < ActiveRecord::Base
|
|||||||
return true if File.size?(config_file)
|
return true if File.size?(config_file)
|
||||||
|
|
||||||
File.open(config_file, "w") do |f|
|
File.open(config_file, "w") do |f|
|
||||||
f.write <<-XML.strip_heredoc
|
f.write DEFAULT_CONF
|
||||||
<source>
|
|
||||||
type forward
|
|
||||||
port 24224
|
|
||||||
</source>
|
|
||||||
<source>
|
|
||||||
type monitor_agent
|
|
||||||
port 24220
|
|
||||||
</source>
|
|
||||||
<source>
|
|
||||||
type http
|
|
||||||
port 9880
|
|
||||||
</source>
|
|
||||||
<source>
|
|
||||||
type debug_agent
|
|
||||||
port 24230
|
|
||||||
</source>
|
|
||||||
|
|
||||||
<match debug.*>
|
|
||||||
type stdout
|
|
||||||
</match>
|
|
||||||
XML
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -30,5 +30,5 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
TODO: (chapter 2: output/buffer plugin) To Be Continued→...
|
<%= link_to t('tutorials.chapter2.page_title') << " >>", tutorials_chapter2_path, class: "pull-right" %>
|
||||||
</p>
|
</p>
|
||||||
|
23
app/views/tutorials/chapter2.html.haml
Normal file
23
app/views/tutorials/chapter2.html.haml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
- page_title t(".page_title")
|
||||||
|
|
||||||
|
%pre
|
||||||
|
2014-06-05 14:43:14 +0900 [info]: adding source type="http"
|
||||||
|
2014-06-05 14:43:14 +0900 [info]: adding match pattern="debug.*" type="stdout"
|
||||||
|
|
||||||
|
:markdown
|
||||||
|
#{t('.lesson_markdown')}
|
||||||
|
|
||||||
|
%pre
|
||||||
|
:escaped
|
||||||
|
<source>
|
||||||
|
type http
|
||||||
|
port 8888
|
||||||
|
</source>
|
||||||
|
|
||||||
|
<match debug.*>
|
||||||
|
type stdout
|
||||||
|
</match>
|
||||||
|
|
||||||
|
|
||||||
|
%p
|
||||||
|
= link_to "<< " << t('tutorials.chapter1.page_title'), tutorials_chapter1_path, class: "pull-left"
|
@ -18,6 +18,7 @@ require "haml-rails"
|
|||||||
require "jquery-rails"
|
require "jquery-rails"
|
||||||
require "sucker_punch"
|
require "sucker_punch"
|
||||||
require "settingslogic"
|
require "settingslogic"
|
||||||
|
require "kramdown-haml"
|
||||||
|
|
||||||
module FluentdUi
|
module FluentdUi
|
||||||
class Application < Rails::Application
|
class Application < Rails::Application
|
||||||
|
@ -116,13 +116,24 @@ en:
|
|||||||
start_tutorial: Start tutorial
|
start_tutorial: Start tutorial
|
||||||
chapter1:
|
chapter1:
|
||||||
<<: *tutorials_common
|
<<: *tutorials_common
|
||||||
page_title: "Tutorial | Receive data via in_http"
|
page_title: "Chapter 1 | Receive data via in_http"
|
||||||
reload_log: Reload fluend log
|
reload_log: Reload fluend log
|
||||||
description: You can send an arbitrary JSON data via HTTP. URL path will be tag name.
|
description: You can send an arbitrary JSON data via HTTP. URL path will be tag name.
|
||||||
learn_more: |
|
learn_more: |
|
||||||
Other input plugins are available such as in_syslog, in_tail, etc.
|
Other input plugins are available such as in_syslog, in_tail, etc.
|
||||||
<a href="http://docs.fluentd.org/articles/input-plugin-overview">Learn More</a>
|
<a href="http://docs.fluentd.org/articles/input-plugin-overview">Learn More</a>
|
||||||
send: Send
|
send: Send
|
||||||
|
chapter2:
|
||||||
|
<<: *tutorials_common
|
||||||
|
page_title: "Chapter 2 | in_http and out_stdout"
|
||||||
|
lesson_markdown: |
|
||||||
|
You can see the log as above when fluentd started.
|
||||||
|
|
||||||
|
Line 1 enable http plugin that allows to receive HTTP requests.
|
||||||
|
|
||||||
|
Line 2 enable stdout plugin that process the data with matched `debug.*` tag.
|
||||||
|
|
||||||
|
These settings are defined as following fluent.conf:
|
||||||
|
|
||||||
messages:
|
messages:
|
||||||
need_restart: need to restart fluentd-ui
|
need_restart: need to restart fluentd-ui
|
||||||
|
@ -116,13 +116,24 @@ ja:
|
|||||||
start_tutorial: "チュートリアルを始める"
|
start_tutorial: "チュートリアルを始める"
|
||||||
chapter1:
|
chapter1:
|
||||||
<<: *tutorials_common
|
<<: *tutorials_common
|
||||||
page_title: "チュートリアル | in_httpでデータを受け取る"
|
page_title: "Chapter 1 | in_httpでデータを受け取る"
|
||||||
reload_log: fluentdのログを更新
|
reload_log: fluentdのログを更新
|
||||||
description: fluentdに任意のデータをJSONで送ることができます。URLのパスがタグの名前になります。
|
description: fluentdに任意のデータをJSONで送ることができます。URLのパスがタグの名前になります。
|
||||||
learn_more: |
|
learn_more: |
|
||||||
他にもin_tail, in_syslogなどのinputプラグインがあります。
|
他にもin_tail, in_syslogなどのinputプラグインがあります。
|
||||||
<a href="http://docs.fluentd.org/ja/articles/input-plugin-overview">Learn More</a>
|
<a href="http://docs.fluentd.org/ja/articles/input-plugin-overview">Learn More</a>
|
||||||
send: 送信
|
send: 送信
|
||||||
|
chapter2:
|
||||||
|
<<: *tutorials_common
|
||||||
|
page_title: "Chapter 2 | in_httpとout_stdout"
|
||||||
|
lesson_markdown: |
|
||||||
|
fluentdの起動時にこのようなログがあるかと思います。
|
||||||
|
|
||||||
|
この1行目でhttpが有効化されています。これでHTTPリクエストを受け付けるようになります。
|
||||||
|
|
||||||
|
2行目でstdoutが有効化されています。受け取ったデータのうち、タグが`debug.*`にマッチするものはstdoutへと渡されます。
|
||||||
|
|
||||||
|
この2つはfluent.confでそれぞれ次のように設定されています。
|
||||||
|
|
||||||
messages:
|
messages:
|
||||||
need_restart: fluentd-uiの再起動が必要です
|
need_restart: fluentd-uiの再起動が必要です
|
||||||
|
@ -37,6 +37,7 @@ Rails.application.routes.draw do
|
|||||||
namespace :tutorials do
|
namespace :tutorials do
|
||||||
get "/" => :index
|
get "/" => :index
|
||||||
get "chapter1"
|
get "chapter1"
|
||||||
|
get "chapter2"
|
||||||
get "log_tail"
|
get "log_tail"
|
||||||
post "request_fluentd"
|
post "request_fluentd"
|
||||||
end
|
end
|
||||||
|
@ -35,4 +35,6 @@ Gem::Specification.new do |spec|
|
|||||||
spec.add_dependency "settingslogic"
|
spec.add_dependency "settingslogic"
|
||||||
spec.add_dependency "puma"
|
spec.add_dependency "puma"
|
||||||
spec.add_dependency "thor"
|
spec.add_dependency "thor"
|
||||||
|
spec.add_dependency "kramdown", "> 1.0.0"
|
||||||
|
spec.add_dependency "kramdown-haml"
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user