upload test 1

41
Sadayuki Furuhashi Fluentd @frsyuki e Event Collector Service Treasure Data, Inc. Structured logging Pluggable architecture Reliable forwarding

Upload: sadayuki-furuhashi

Post on 08-May-2015

1.945 views

Category:

Technology


7 download

TRANSCRIPT

Page 1: upload test 1

Sadayuki Furuhashi

Fluentd

@frsyuki

!e Event Collector Service

Treasure Data, Inc.

Structured logging

Pluggable architecture

Reliable forwarding

Page 2: upload test 1

• Sadayuki Furuhashi> twitter: @frsyuki

• Treasure Data, Inc.> Software Engineer; founder

• Author of MessagePack

• Author of Fluentd

Page 3: upload test 1

What’s Fluentd?

It's like syslogd, but uses JSON for log messages

Page 4: upload test 1

What’s Fluentd?

Application

Fluentd

Storage

2012-02-04 01:33:51myapp.buylog { “user”: ”me”, “path”: “/buyItem”, “price”: 150, “referer”: “/landing”}

Page 5: upload test 1

What’s Fluentd?

Application

Fluentd

Storage

2012-02-04 01:33:51myapp.buylog { “user”: ”me”, “path”: “/buyItem”, “price”: 150, “referer”: “/landing”}

timetag

record

Page 6: upload test 1

What’s Fluentd?

Application

Fluentd

Storage

!lter / bu"er / routing

Page 7: upload test 1

What’s Fluentd?

Application

Fluentd

FluentdStorageSaaS

!lter / bu"er / routing

Plug-in Plug-in Plug-in

Page 8: upload test 1

What’s Fluentd?

Application

Fluentd

FluentdStorageSaaS

!lter / bu"er / routing

File

tail

Scribesyslogd

Plug-in Plug-in

Plug-in

Plug-in Plug-in Plug-in

Page 9: upload test 1

What’s Fluentd?• Client libraries

> Ruby> Perl> PHP> Python> Java> ...

Fluent.open(“myapp”)

Fluent.event(“login”, {“user”=>38})

#=> 2012-02-04 04:56:01 myapp.login {“user”:38}

Application

Fluentd

Page 10: upload test 1

Fluentd & Event logsBefore:

Application

File File File ...

App server

Application

File File File ...

App server

File

Application

File File File ...

App server

Log server

Burst of tra!c

High latencymust wait for a day

Hard to analyzecomplex text parsers

Page 11: upload test 1

Fluentd & Event logsAfter:

Application

App server

Fluentd

Application

App server

Fluentd

Application

App server

Fluentd

Fluentd Fluentd

Realtime!

Page 12: upload test 1

Fluentd & Event logs

Fluentd Fluentd Fluentd

Fluentd Fluentd

Hadoop/ Hive MongoDB Amazon

S3 / EMRReady toAnalyze!

Realtime!

Page 13: upload test 1

# receive events via HTTP<source> type http port 8888</source>

# read logs from a file<source> type tail path /var/log/httpd.log format apache tag apache.access</source>

# save access logs to MongoDB<match apache.access> type mongo host 127.0.0.1</match>

# save alerts to a file<match alert.**> type file path /var/log/fluent/alerts</match>

# forward other logs to servers# (load-balancing + fail-over)<match **> type forward <server> host 192.168.0.11 weight 20 </server> <server> host 192.168.0.12 weight 60 </server></match>

Page 14: upload test 1

Fluentd vs Scribe

• Deals with structured logs

• Easy to install> “gem install fluentd”> apt-get and yum http://packages.treasure-data.com/

• Easy to customize

• add/modify plugins without re-compiling> “gem search -rd fluent-plugin”

Page 15: upload test 1

Fluentd vs Flume

• Easy to setup> “sudo fluentd --setup && fluentd”

• Very small footprint> small engine (3,000 lines) + plugins

• JVM-free

• Easy to configure

Page 16: upload test 1

Architecture of Fluentd

Input Buffer Output

HTTP+JSONFile tailSyslog...

MemoryFile

FileAmazon S3Fluent...

Pluggable Pluggable Pluggable

Page 17: upload test 1

Architecture :: Input

Input

HTTP+JSONFile tailSyslog...

Pluggable

✓ Receive logs✓ Or pull logs from data sources✓ Non-blocking

Input plugins:

Page 18: upload test 1

Architecture :: Bu"er

Pluggable

✓ Improve performance✓ Improve reliability✓ Provide thread-safety

Buffer plugins:

Buffer

MemoryFile

Page 19: upload test 1

Architecture :: Output

Pluggable

✓ Write or send event logsOutput plugins:

Output

FileAmazon S3Fluent...

Page 20: upload test 1

Plugins :: out_forward

Fluentd

Fluentd Fluentd

out_forward

in_forward

forward event logs

Heartbeat

✓ load balancing

Page 21: upload test 1

Plugins :: out_forward

Fluentd

Fluentd Fluentd

out_forward

in_forward

forward event logs

Heartbeat

! accrual failure detector

✓ load balancing

Page 22: upload test 1

Plugins :: out_copy

Fluentd

MongoDB Fluentd

out_copy

out_forwardout_mongo

duplicate event logs

File

out_#le

Page 23: upload test 1

Plugins :: buf_#le

Fluentd

buf_#le

reliable bu"ering

#le

#le

#le✓ Automatic retry✓ 2^N retry interval

#le#le

#le

✓ Persistent bu"er

Page 24: upload test 1

Plugins :: out_exec

Fluentd

out_exec

externalprogram

TSV → stdin

execute external programs

✓ Python✓ Perl✓ C++

Page 25: upload test 1

Plugins :: out_exec_#lter

Fluentd

out_exec_#lter

externalprogram

stdin

stdoutexternalprogram

out_execTSV → stdin

execute external programs

✓ Python✓ Perl✓ C++

Page 26: upload test 1

Plugins :: in_exec

Fluentd

out_exec_#lter

externalprogram

stdin

stdoutexternalprogram

out_execTSV → stdin

externalprogram

stdout

in_exec

execute external programs

✓ Python✓ Perl✓ C++

Page 27: upload test 1

Plugins :: in_tail

Fluentd

Application

in_tail

File /var/log/access.log

Read event logs from a #le

✓ Apache log parser✓ Syslog parser✓ Custom parser

Page 28: upload test 1

Plugins :: in_tailApache log parser

87.12.1.87 - - [04/Feb/2012:00:20:11 +0900] "GET / HTTP/1.1" 200 9887.12.1.87 - - [04/Feb/2012:00:20:11 +0900] "GET / HTTP/1.1" 200 98...

{ “host”: “87.12.1.87”, “method”: “GET”, “code”: 200, “size”: 98, “path”: “/”}...

Page 29: upload test 1

Plugins

• Bundled plugins> file writes event logs to files hourly or daily

> forward forwards event logs (+fail-over and load balancing)

> exec passes event logs to/from external commands

> tail reads event logs from a file (like `tail -f`)

Page 30: upload test 1

Plugins

• 3rd party plugins> scribe integrates Fluentd with Scribe

> s3 uploads log files to Amazon S3 hourly or daily

> mongo writes logs to MongoDB

> hoop puts log files on Hadoop HDFS via Hoop

...

Page 31: upload test 1

Plugin developer API

• Unit test framework (like “MRUnit”)> Fluent::Test::InputTestDriver> Fluent::Test::OutputTestDriver> Fluent::Test::BufferedOutputTestDriver

• Fluent::TailInput (base class of “tail” plugin)> text parser is customizable def parse_line(line)

Page 32: upload test 1

Fluentd• Documents

> http://fluentd.org

• Source code> http://github.com/fluent

• Twitter> #fluentd

• Mailing list> http://groups.google.com/group/fluentd

Page 33: upload test 1
Page 34: upload test 1

“BIG DATA ANALYTICS PLATFORM”as a Service

Page 35: upload test 1
Page 36: upload test 1
Page 37: upload test 1

Fluentd & Treasure Data

Fluentd Fluentd Fluentd

Fluentd Fluentd

Hadoop/ Hive MongoDB Amazon

S3 / EMRReady toAnalyze!

Realtime!

Page 38: upload test 1

Fluentd & Treasure Data

Fluentd Fluentd Fluentd

Fluentd Fluentd

Realtime!

Treasure DataCloud Platform

Ready toAnalyze!

Page 39: upload test 1

Fluentd & Treasure DataTreasure Data

Cloud Platform

SQL VisualizationSELECT users.age, COUNT(1)FROM logsLEFT JOIN users ON logs.user_id = users.idGROUP BY users.ageWHERE path = “/buyItem”

Page 40: upload test 1