Tutorials done

This commit is contained in:
uu59 2014-06-06 17:36:19 +09:00
parent 6c3ef9bcf5
commit a47e339b0e
9 changed files with 216 additions and 9 deletions

View File

@ -29,10 +29,6 @@
</div>
<!-- /vue.js -->
<p>
<%= raw t ".learn_more" %>
</p>
<p class="clearfix">
<%= link_to t('tutorials.chapter2.page_title') << " >>", tutorials_chapter2_path, class: "pull-right" %>
</p>

View File

@ -2,9 +2,11 @@
%p.clearfix
= link_to "<< " << t('tutorials.chapter1.page_title'), tutorials_chapter1_path, class: "pull-left"
= link_to t('tutorials.chapter3.page_title') << " >>", tutorials_chapter3_path, class: "pull-right"
:markdown
#{t('.lesson_markdown')}
%p.clearfix
= link_to "<< " << t('tutorials.chapter1.page_title'), tutorials_chapter1_path, class: "pull-left"
= link_to t('tutorials.chapter3.page_title') << " >>", tutorials_chapter3_path, class: "pull-right"

View File

@ -0,0 +1,12 @@
- page_title t(".page_title")
%p.clearfix
= link_to "<< " << t('tutorials.chapter2.page_title'), tutorials_chapter2_path, class: "pull-left"
= link_to t('tutorials.chapter4.page_title') << " >>", tutorials_chapter4_path, class: "pull-right"
:markdown
#{t(".lesson_markdown", edit_config_url: edit_fluentd_setting_path(@fluentd))}
%p.clearfix
= link_to "<< " << t('tutorials.chapter2.page_title'), tutorials_chapter2_path, class: "pull-left"
= link_to t('tutorials.chapter4.page_title') << " >>", tutorials_chapter4_path, class: "pull-right"

View File

@ -0,0 +1,12 @@
- page_title t(".page_title")
%p.clearfix
= link_to "<< " << t('tutorials.chapter3.page_title'), tutorials_chapter3_path, class: "pull-left"
= link_to t('tutorials.chapter5.page_title') << " >>", tutorials_chapter5_path, class: "pull-right"
:markdown
#{t ".lesson_markdown"}
%p.clearfix
= link_to "<< " << t('tutorials.chapter3.page_title'), tutorials_chapter3_path, class: "pull-left"
= link_to t('tutorials.chapter5.page_title') << " >>", tutorials_chapter5_path, class: "pull-right"

View File

@ -0,0 +1,10 @@
- page_title t(".page_title")
%p.clearfix
= link_to "<< " << t('tutorials.chapter4.page_title'), tutorials_chapter4_path, class: "pull-left"
:markdown
#{t ".lesson_markdown"}
%p.clearfix
= link_to "<< " << t('tutorials.chapter4.page_title'), tutorials_chapter4_path, class: "pull-left"

View File

@ -116,12 +116,9 @@ en:
start_tutorial: Start tutorial
chapter1:
<<: *tutorials_common
page_title: "Chapter 1 | Receive data via in_http"
page_title: "Chapter 1 | Try to send data"
reload_log: Reload fluend log
description: You can send an arbitrary JSON data via HTTP. URL path will be tag name.
learn_more: |
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>
send: Send
chapter2:
<<: *tutorials_common
@ -146,6 +143,93 @@ en:
<match debug.*>
type stdout
</match>
chapter3:
<<: *tutorials_common
page_title: "Chapter 3 | Build your fluentd!"
lesson_markdown: |
fluentd can receive from [syslog protocol](http://docs.fluentd.org/articles/in_syslog), [file](http://docs.fluentd.org/articles/in_tail), etc.
Also fluentd can output to [MongoDB](http://docs.fluentd.org/articles/out_mongo), [AWS S3](http://docs.fluentd.org/articles/out_s3), etc.
![fluentd](/fluentd.png)
These input/output are provided as plugin. Install them and write a setting, then restart fluentd, you can get the power!
[Many plugins](/plugins/recommended) are available. And you can [edit config file from here](%{edit_config_url}).
chapter4:
<<: *tutorials_common
page_title: "Chapter 4 | Use case"
lesson_markdown: |
### Monitoring Apache 5xx response and email it
**Required plugins**
- fluent-plugin-grepcounter
- fluent-plugin-mail
**config file example**
<source>
type tail
format apache2
path /var/log/apache2/access.log #This is the location of your Apache log
tag apache.access
</source>
<match apache.access>
type grepcounter
count_interval 3 # Time window to grep and count the # of events
input_key code # We look at the (http status) "code" field
regexp ^5\d\d$ # This regexp matches 5xx status codes
threshold 1 # The # of events to trigger emitting an output
add_tag_prefix error_5xx # The output event's tag will be error_5xx.apache.access
</match>
<match error_5xx.apache.access>
# The event that comes here looks like
# {
# "count":1,
# "input_tag":"error_5xx.apache.access",
# "input_tag_last":"access",
# "message":[500]
# }
type mail
host smtp.gmail.com # This is for Gmail and Google Apps. Any SMTP server should work
port 587 # port for smtp.gmail.com
user example@gmail.com # your Gmail here for login
password XXXXXX # Gmail password
enable_starttls_auto true # Gmail required this
from YOUR_SENDER_EMAIL_HERE
to YOUR_RECIPIENT_EMAIL_HERE
subject [URGENT] APACHE 5XX ERROR
message Total 5xx error count: %s\n\nPlease check your Apache webserver ASAP
message_out_keys count # The value of 'count' will be substituted into %s above.
</match>
**process flow**
[log file] ->
(in_tail) ->
Capturing file content with tagged as apache.access ->
(match apache.access) ->
"grepcounter" re-send data with appending prefix ->
(match error_5xx.apache.access) ->
"mail" send a mail
chapter5:
<<: *tutorials_common
page_title: "Chapter 5 | Finish!"
lesson_markdown: |
Tutorial is over. congratulation!
Other resources:
- [Quick start](http://docs.fluentd.org/articles/quickstart)
- [Forum](https://groups.google.com/forum/?fromgroups#!forum/fluentd)
- [Source code(GitHub)](https://github.com/fluent/fluentd)
- [Twitter @fluentd](https://twitter.com/fluentd)
messages:
need_restart: need to restart fluentd-ui

View File

@ -116,7 +116,7 @@ ja:
start_tutorial: "チュートリアルを始める"
chapter1:
<<: *tutorials_common
page_title: "Chapter 1 | in_httpでデータを受け取る"
page_title: "Chapter 1 | データを渡してみる"
reload_log: fluentdのログを更新
description: fluentdに任意のデータをJSONで送ることができます。URLのパスがタグの名前になります。
learn_more: |
@ -146,6 +146,94 @@ ja:
<match debug.*>
type stdout
</match>
chapter3:
<<: *tutorials_common
page_title: "Chapter 3 | fluentdを構築しよう"
lesson_markdown: |
fluentdはHTTP以外にも[syslogプロトコル](http://docs.fluentd.org/ja/articles/in_syslog)や[ファイル](http://docs.fluentd.org/ja/articles/in_tail)を入力として受け取ることができます。
また出力についても、stdout以外に[MongoDB](http://docs.fluentd.org/ja/articles/out_mongo)や[AWS S3](http://docs.fluentd.org/ja/articles/out_s3)などを出力先として指定できます。
![fluentd](/fluentd.png)
これらはプラグインとして提供されています。プラグインをインストールし、設定ファイルに追記してfluentdを再起動すると使用可能となります。
[数多くのプラグイン](/plugins/recommended)がありますので、用途にあったものを探して使いましょう! 設定ファイルは[ここから編集できます。](%{edit_config_url})
chapter4:
<<: *tutorials_common
page_title: "Chapter 4 | 設定事例"
lesson_markdown: |
### 例Apacheの5xxレスポンスを検知してメールを送る
**必要なプラグイン**
- fluent-plugin-grepcounter
- fluent-plugin-mail
**設定ファイル例**
<source>
type tail
format apache2
path /var/log/apache2/access.log #This is the location of your Apache log
tag apache.access
</source>
<match apache.access>
type grepcounter
count_interval 3 # Time window to grep and count the # of events
input_key code # We look at the (http status) "code" field
regexp ^5\d\d$ # This regexp matches 5xx status codes
threshold 1 # The # of events to trigger emitting an output
add_tag_prefix error_5xx # The output event's tag will be error_5xx.apache.access
</match>
<match error_5xx.apache.access>
# The event that comes here looks like
# {
# "count":1,
# "input_tag":"error_5xx.apache.access",
# "input_tag_last":"access",
# "message":[500]
# }
type mail
host smtp.gmail.com # This is for Gmail and Google Apps. Any SMTP server should work
port 587 # port for smtp.gmail.com
user example@gmail.com # your Gmail here for login
password XXXXXX # Gmail password
enable_starttls_auto true # Gmail required this
from YOUR_SENDER_EMAIL_HERE
to YOUR_RECIPIENT_EMAIL_HERE
subject [URGENT] APACHE 5XX ERROR
message Total 5xx error count: %s\n\nPlease check your Apache webserver ASAP
message_out_keys count # The value of 'count' will be substituted into %s above.
</match>
**処理の流れ**
[log file] ->
(in_tail) ->
apache.accessタグでfluentdに取り込む ->
(apache.accessにマッチ) ->
grepcounterがタグにprefixを追加して再送 ->
(error_5xx.apache.accessにマッチ) ->
mailがメール送信
chapter5:
<<: *tutorials_common
page_title: "Chapter 5 | チュートリアル完了"
lesson_markdown: |
以上でチュートリアルは終了です。お疲れさまでした!
関連リソース:
- [クイックスタートガイド](http://docs.fluentd.org/ja/articles/quickstart)
- [メーリングリスト](https://groups.google.com/forum/?fromgroups#!forum/fluentd)
- [ソースコード(GitHub)](https://github.com/fluent/fluentd)
- [Twitter @fluentd](https://twitter.com/fluentd)
messages:
need_restart: fluentd-uiの再起動が必要です

View File

@ -38,6 +38,9 @@ Rails.application.routes.draw do
get "/" => :index
get "chapter1"
get "chapter2"
get "chapter3"
get "chapter4"
get "chapter5"
get "log_tail"
post "request_fluentd"
end

BIN
public/fluentd.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB