diff --git a/app/views/tutorials/chapter1.html.erb b/app/views/tutorials/chapter1.html.erb index aa3cc55..285e7b1 100644 --- a/app/views/tutorials/chapter1.html.erb +++ b/app/views/tutorials/chapter1.html.erb @@ -29,10 +29,6 @@ -

-<%= raw t ".learn_more" %> -

-

<%= link_to t('tutorials.chapter2.page_title') << " >>", tutorials_chapter2_path, class: "pull-right" %>

diff --git a/app/views/tutorials/chapter2.html.haml b/app/views/tutorials/chapter2.html.haml index e219e69..cd1dd8b 100644 --- a/app/views/tutorials/chapter2.html.haml +++ b/app/views/tutorials/chapter2.html.haml @@ -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" diff --git a/app/views/tutorials/chapter3.html.haml b/app/views/tutorials/chapter3.html.haml new file mode 100644 index 0000000..b34f292 --- /dev/null +++ b/app/views/tutorials/chapter3.html.haml @@ -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" diff --git a/app/views/tutorials/chapter4.html.haml b/app/views/tutorials/chapter4.html.haml new file mode 100644 index 0000000..de617b1 --- /dev/null +++ b/app/views/tutorials/chapter4.html.haml @@ -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" diff --git a/app/views/tutorials/chapter5.html.haml b/app/views/tutorials/chapter5.html.haml new file mode 100644 index 0000000..9213ac1 --- /dev/null +++ b/app/views/tutorials/chapter5.html.haml @@ -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" diff --git a/config/locales/translation_en.yml b/config/locales/translation_en.yml index 1249118..65c8fae 100644 --- a/config/locales/translation_en.yml +++ b/config/locales/translation_en.yml @@ -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. - Learn More send: Send chapter2: <<: *tutorials_common @@ -146,6 +143,93 @@ en: type stdout + 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** + + + type tail + format apache2 + path /var/log/apache2/access.log #This is the location of your Apache log + tag 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 + + + + # 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. + + + **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 diff --git a/config/locales/translation_ja.yml b/config/locales/translation_ja.yml index 67f835e..dea1dd6 100644 --- a/config/locales/translation_ja.yml +++ b/config/locales/translation_ja.yml @@ -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: type stdout + 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 + + **設定ファイル例** + + + type tail + format apache2 + path /var/log/apache2/access.log #This is the location of your Apache log + tag 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 + + + + # 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. + + + **処理の流れ** + + [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の再起動が必要です diff --git a/config/routes.rb b/config/routes.rb index ec94b20..c0e3440 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 diff --git a/public/fluentd.png b/public/fluentd.png new file mode 100644 index 0000000..d2f5f52 Binary files /dev/null and b/public/fluentd.png differ