Fluentdでログ収集「だけ」やる話 #study2study

14
Fluentdでログ収集「だけ」やる話 What to do is to collect raw logs #study2study 2012/03/29 @tagomoris 12330日金曜日

description

Webサーバ勉強会 2012/03/29

Transcript of Fluentdでログ収集「だけ」やる話 #study2study

Page 1: Fluentdでログ収集「だけ」やる話 #study2study

Fluentdでログ収集「だけ」やる話What to do is to collect raw logs

#study2study 2012/03/29@tagomoris

12年3月30日金曜日

Page 2: Fluentdでログ収集「だけ」やる話 #study2study

@tagomoris

NHN Japan Corp.Web Service Business DivisionDevelopment Department 2

Development Platforms

12年3月30日金曜日

Page 3: Fluentdでログ収集「だけ」やる話 #study2study

Fluentd

• 'That' we all love.

12年3月30日金曜日

Page 4: Fluentdでログ収集「だけ」やる話 #study2study

Basic method• Fluentd in_tail + out/in_forward + out_file

Web server

Web server

Web server

fluentd

fluentd

fluentd

Collect server

fluentd

12年3月30日金曜日

Page 5: Fluentdでログ収集「だけ」やる話 #study2study

in_tail + out_file: JSON

20120501 23:59:00 blog {"path":"/dankogai/archives/51780443.html","code":"200","size":"5031", ...}20120501 23:59:00 blog {"path":"/dankogai/archives/51780443.html","code":"200","size":"5031", ...}20120501 23:59:00 blog {"path":"/dankogai/archives/51780443.html","code":"200","size":"5031", ...}

• JSON is good for new systems

• But traditional (historically important) systems requires raw logs

• How do we get raw logs with Fluentd ?

12年3月30日金曜日

Page 6: Fluentdでログ収集「だけ」やる話 #study2study

we neeeeeed raw log• fluent-agent-lite

• Fluentd in_forward + out_file_alternative

Web server

Web server

Web server

fluent-agent-liteCollect server

fluentd

fluent-agent-lite

fluent-agent-lite

12年3月30日金曜日

Page 7: Fluentdでログ収集「だけ」やる話 #study2study

fluent-agent-lite• https://github.com/tagomoris/fluent-agent-lite

• easy to intall, run

• run with perl 5.8 (only!)

• bin/install.sh or rpm (.spec bundled)

• start-stop script bundled

• lightweight, raw log intensive

• read a line, send it as one msg with one field

• with high throughput and low load12年3月30日金曜日

Page 8: Fluentdでログ収集「だけ」やる話 #study2study

fluent-agent-lite

• many features

• fluentd cluster support (select one randomly)

• failover support (primary / secondary servers)

• configurations for high performance

12年3月30日金曜日

Page 9: Fluentdでログ収集「だけ」やる話 #study2study

fluent-plugin-file-alternative

• 100% compatible to standard out_file

• with same configuration, get same output

• simple configuration

• path w/ time placeholder w/o time_slice_format

• /path/to/log/access.%Y-%m-%d.log

12年3月30日金曜日

Page 10: Fluentdでログ収集「だけ」やる話 #study2study

fluent-plugin-file-alternative• custom output line formats

• time of fluentd message OR NOT

• tag of fluentd message OR NOT

• custom output data formats

• whole record as json

• selected single field

• selected multi fields seperated by TAB/SPACE/COMMA

12年3月30日金曜日

Page 11: Fluentdでログ収集「だけ」やる話 #study2study

fluent-plugin-file-alternative

• Misc

• add newline at the end of data OR NOT

• appending data to single file with flush_interval (without compression)

12年3月30日金曜日

Page 12: Fluentdでログ収集「だけ」やる話 #study2study

simple configuration

<match fluentd.status.gc.**> type file_alternative path /var/log/fluentd.status/gc.%Y-%m-%d.%H.log</match>

<match fluentd.status.gc.**> type file path /var/log/fluentd.status/gc time_slice_format %Y-%m-%d.%H</match>

12年3月30日金曜日

Page 13: Fluentdでログ収集「だけ」やる話 #study2study

for raw logs

<match apache.log.**> type file_alternative path /var/log/archive/access.%Y-%m-%d.%H.log output_include_time false output_include_tag false output_data_type attr:message add_newline true</match>

12年3月30日金曜日

Page 14: Fluentdでログ収集「だけ」やる話 #study2study

Thanks!

12年3月30日金曜日