際際滷

際際滷Share a Scribd company logo
fluentdのO協が
よくわからない
@harukasan
Sunday, June 2, 13
harukasan
?互カンファレンス
?消藻致互/湘垢寄/廏襖寄
?pixivのインフラ14ヶ埖朕
Sunday, June 2, 13
Sunday, June 2, 13
Sunday, June 2, 13
Ruby on Rails
Sunday, June 2, 13
Ruby on Rails
Capistrano
Sunday, June 2, 13
Ruby on Rails
Capistrano
Fluentd
Sunday, June 2, 13
fluentd
Sunday, June 2, 13
Front Access
App. Access
Activity - Sign-up, Sign-in, bookmark, ...
PHP/Rails error
JS(client-side) error
MySQL slow queries
Solr slow requests
IRC
Sunday, June 2, 13
capped
mongodb
?
APP/DB
?
in_tail
extended in_tail
out_mongo
?
out_file_alternative
JSON
Admin view
?
?
minutely/daily
batch
IRC
Google
Docs
?
MySQL
Sunday, June 2, 13
fluentd
Sunday, June 2, 13
fluentd
がよくわからなかった
Sunday, June 2, 13
Input Plugin
Bu?er Plugin
Output Plugin
Input data
(tag, data)
Output data
Fluentd Basic architecture
Sunday, June 2, 13
Configure
Sunday, June 2, 13
<source>
type tail
path /tmp/test.log
tag test.log
format json
</source>
<match test.log>
type mongo
host localhost
database test
collection log
bu?er_chunk_limit 2m
bu?er_queue_limit 256
flush_interval 1s
</match>
Sunday, June 2, 13
なんか咾
Sunday, June 2, 13
<source>
type tail
path /tmp/test.log
tag test.log
format json
</source>
<match test.log>
type mongo
host localhost
database test
collection log
bu?er_chunk_limit 2m
bu?er_queue_limit 256
flush_interval 1s
</match>
Sunday, June 2, 13
<source>
type tail
path /tmp/test.log
tag test.log
format json
</source>
<match test.log>
type mongo
host localhost
database test
collection log
bu?er_chunk_limit 2m
bu?er_queue_limit 256
flush_interval 1s
</match>
Sunday, June 2, 13
ようわからん
Sunday, June 2, 13
Sunday, June 2, 13
ようわからん
Sunday, June 2, 13
|
Sunday, June 2, 13
y叟業
哂Z < Ruby
Sunday, June 2, 13
y叟業
Ruby < 哂Z
Sunday, June 2, 13
git clone
git@github.com:fluent/fluentd.git
Sunday, June 2, 13
Fluent::Bu?eredOutput
emit(tag,data)
emit(tag,data)
Bu?eredOutput
write(data)
Bu?erInput
someting(data)
push
pop
Sunday, June 2, 13
Fluent::Bu?eredOutput
emit(tag,data)
emit(tag,data)
Bu?eredOutput
write(data)
Bu?erInput
someting(data)
push
pop
Sunday, June 2, 13
Fluent::BasicBu?er#emit
def	
 ?emit(key,	
 ?data,	
 ?chain)
	
 ?	
 ?key	
 ?=	
 ?key.to_s
	
 ?	
 ?top	
 ?=	
 ?(@map[key]	
 ?||=	
 ?new_chunk(key))
	
 ?	
 ?if	
 ?top.size	
 ?+	
 ?data.bytesize	
 ?<=	
 ?@buffer_chunk_limit
	
 ?	
 ?	
 ?	
 ?chain.next
	
 ?	
 ?	
 ?	
 ?top	
 ?<<	
 ?data
	
 ?	
 ?	
 ?	
 ?return	
 ?false
	
 ?	
 ?elsif	
 ?@queue.size	
 ?>=	
 ?@buffer_queue_limit
	
 ?	
 ?	
 ?	
 ?raise	
 ?BufferQueueLimitError,
	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?"queue	
 ?size	
 ?exceeds	
 ?limit"
	
 ?	
 ?end
	
 ?	
 ?nc	
 ?=	
 ?new_chunk(key)
Sunday, June 2, 13
Fluent::BasicBu?er#emit
def	
 ?emit(key,	
 ?data,	
 ?chain)
	
 ?	
 ?...
	
 ?	
 ?top	
 ?=	
 ?(@map[key]	
 ?||=	
 ?new_chunk(key))
	
 ?	
 ?if	
 ?top.size	
 ?+	
 ?data.bytesize	
 ?<=	
 ?@buffer_chunk_limit
...
	
 ?	
 ?	
 ?	
 ?top	
 ?<<	
 ?data
	
 ?	
 ?	
 ?	
 ?return	
 ?false
top=@map[key]
Sunday, June 2, 13
Fluent::BasicBu?er#emit
def	
 ?emit(key,	
 ?data,	
 ?chain)
	
 ?	
 ?...
	
 ?	
 ?top	
 ?=	
 ?(@map[key]	
 ?||=	
 ?new_chunk(key))
	
 ?	
 ?if	
 ?top.size	
 ?+	
 ?data.bytesize	
 ?<=	
 ?@buffer_chunk_limit
...
	
 ?	
 ?	
 ?	
 ?top	
 ?<<	
 ?data
	
 ?	
 ?	
 ?	
 ?return	
 ?false
top=@map[key]
emit(key,data)
Sunday, June 2, 13
Fluent::BasicBu?er#emit
def	
 ?emit(key,	
 ?data,	
 ?chain)
	
 ?	
 ?...
	
 ?	
 ?top	
 ?=	
 ?(@map[key]	
 ?||=	
 ?new_chunk(key))
	
 ?	
 ?if	
 ?top.size	
 ?+	
 ?data.bytesize	
 ?<=	
 ?@buffer_chunk_limit
...
	
 ?	
 ?	
 ?	
 ?top	
 ?<<	
 ?data
	
 ?	
 ?	
 ?	
 ?return	
 ?false
top=@map[key]
emit(key,data)
○chunk
Sunday, June 2, 13
Fluent::BasicBu?er#emit
def	
 ?emit(key,	
 ?data,	
 ?chain)
	
 ?	
 ?...
	
 ?	
 ?top	
 ?=	
 ?(@map[key]	
 ?||=	
 ?new_chunk(key))
	
 ?	
 ?if	
 ?top.size	
 ?+	
 ?data.bytesize	
 ?<=	
 ?@buffer_chunk_limit
...
	
 ?	
 ?	
 ?	
 ?top	
 ?<<	
 ?data
	
 ?	
 ?	
 ?	
 ?return	
 ?false
top=@map[key]
emit(key,data)
data
○chunk
Sunday, June 2, 13
Fluent::BasicBu?er#emit
def	
 ?emit(key,	
 ?data,	
 ?chain)
	
 ?	
 ?...
	
 ?	
 ?top	
 ?=	
 ?(@map[key]	
 ?||=	
 ?new_chunk(key))
	
 ?	
 ?if	
 ?top.size	
 ?+	
 ?data.bytesize	
 ?<=	
 ?@buffer_chunk_limit
...
	
 ?	
 ?	
 ?	
 ?top	
 ?<<	
 ?data
	
 ?	
 ?	
 ?	
 ?return	
 ?false
top=@map[key]
emit(key,data)
data
emit(key,data)
○chunk
Sunday, June 2, 13
Fluent::BasicBu?er#emit
def	
 ?emit(key,	
 ?data,	
 ?chain)
	
 ?	
 ?...
	
 ?	
 ?top	
 ?=	
 ?(@map[key]	
 ?||=	
 ?new_chunk(key))
	
 ?	
 ?if	
 ?top.size	
 ?+	
 ?data.bytesize	
 ?<=	
 ?@buffer_chunk_limit
...
	
 ?	
 ?	
 ?	
 ?top	
 ?<<	
 ?data
	
 ?	
 ?	
 ?	
 ?return	
 ?false
top=@map[key]
emit(key,data)
data
data
emit(key,data)
○chunk
Sunday, June 2, 13
Fluent::BasicBu?er#emit
def	
 ?emit(key,	
 ?data,	
 ?chain)
	
 ?	
 ?...
	
 ?	
 ?top	
 ?=	
 ?(@map[key]	
 ?||=	
 ?new_chunk(key))
	
 ?	
 ?if	
 ?top.size	
 ?+	
 ?data.bytesize	
 ?<=	
 ?@buffer_chunk_limit
...
	
 ?	
 ?	
 ?	
 ?top	
 ?<<	
 ?data
	
 ?	
 ?	
 ?	
 ?return	
 ?false
top=@map[key]
emit(key,data)
data
data
emit(key,data)
emit(key,data)
○chunk
Sunday, June 2, 13
Fluent::BasicBu?er#emit
	
 ?	
 ?end
	
 ?	
 ?nc	
 ?=	
 ?new_chunk(key)
	
 ?	
 ?ok	
 ?=	
 ?false
	
 ?	
 ?begin
	
 ?	
 ?	
 ?	
 ?nc	
 ?<<	
 ?data
	
 ?	
 ?	
 ?	
 ?chain.next
	
 ?	
 ?	
 ?	
 ?flush_trigger	
 ?=	
 ?false
top=@map[key]
emit(key,data)
data
data
emit(key,data)
emit(key,data) nc
Sunday, June 2, 13
Fluent::BasicBu?er#emit
	
 ?	
 ?end
	
 ?	
 ?nc	
 ?=	
 ?new_chunk(key)
	
 ?	
 ?ok	
 ?=	
 ?false
	
 ?	
 ?begin
	
 ?	
 ?	
 ?	
 ?nc	
 ?<<	
 ?data
	
 ?	
 ?	
 ?	
 ?chain.next
	
 ?	
 ?	
 ?	
 ?flush_trigger	
 ?=	
 ?false
top=@map[key]
emit(key,data)
data
data
emit(key,data)
emit(key,data) nc
data
Sunday, June 2, 13
Fluent::BasicBu?er#emit
	
 ?	
 ?	
 ?	
 ?flush_trigger	
 ?=	
 ?false
	
 ?	
 ?	
 ?	
 ?@queue.synchronize	
 ?{
	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?enqueue(top)
	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?flush_trigger	
 ?=	
 ?@queue.empty?
	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?@queue	
 ?<<	
 ?top
	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?@map[key]	
 ?=	
 ?nc
	
 ?	
 ?	
 ?	
 ?}
top=@map[key]
emit(key,data)
data
data
emit(key,data)
emit(key,data) nc
data
Sunday, June 2, 13
Fluent::BasicBu?er#emit
	
 ?	
 ?	
 ?	
 ?flush_trigger	
 ?=	
 ?false
	
 ?	
 ?	
 ?	
 ?@queue.synchronize	
 ?{
	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?enqueue(top)
	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?flush_trigger	
 ?=	
 ?@queue.empty?
	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?@queue	
 ?<<	
 ?top
	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?@map[key]	
 ?=	
 ?nc
	
 ?	
 ?	
 ?	
 ?}
top=@map[key]
emit(key,data)
data
data
emit(key,data)
emit(key,data) nc
data
@queue
Sunday, June 2, 13
Fluent::BasicBu?er#emit
	
 ?	
 ?	
 ?	
 ?flush_trigger	
 ?=	
 ?false
	
 ?	
 ?	
 ?	
 ?@queue.synchronize	
 ?{
	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?enqueue(top)
	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?flush_trigger	
 ?=	
 ?@queue.empty?
	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?@queue	
 ?<<	
 ?top
	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?@map[key]	
 ?=	
 ?nc
	
 ?	
 ?	
 ?	
 ?}
top=@map[key]
emit(key,data)
data
data
emit(key,data)
emit(key,data) nc
data
@queue
Sunday, June 2, 13
Fluent::BasicBu?er#emit
	
 ?	
 ?	
 ?	
 ?flush_trigger	
 ?=	
 ?false
	
 ?	
 ?	
 ?	
 ?@queue.synchronize	
 ?{
	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?enqueue(top)
	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?flush_trigger	
 ?=	
 ?@queue.empty?
	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?@queue	
 ?<<	
 ?top
	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?@map[key]	
 ?=	
 ?nc
	
 ?	
 ?	
 ?	
 ?}
top=@map[key]
emit(key,data)
data
data
emit(key,data)
emit(key,data)
data
@queue
Sunday, June 2, 13
Fluent::BasicBu?er#emit
	
 ?	
 ?	
 ?	
 ?flush_trigger	
 ?=	
 ?false
	
 ?	
 ?	
 ?	
 ?@queue.synchronize	
 ?{
	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?enqueue(top)
	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?flush_trigger	
 ?=	
 ?@queue.empty?
	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?@queue	
 ?<<	
 ?top
	
 ?	
 ?	
 ?	
 ?	
 ?	
 ?@map[key]	
 ?=	
 ?nc
	
 ?	
 ?	
 ?	
 ?}
top=@map[key]
emit(key,data)
data
data
emit(key,data)
emit(key,data)
data
@queue
Sunday, June 2, 13
Fluent::Bu?eredOutput
emit(tag,data)
emit(tag,data)
Bu?eredOutput
write(data)
Bu?erInput
someting(data)
push
pop
Sunday, June 2, 13
Fluent::BasicBu?er#push
def	
 ?push(key)
	
 ?	
 ?top	
 ?=	
 ?@map[key]
	
 ?	
 ?if	
 ?!top	
 ?||	
 ?top.empty?
	
 ?	
 ?	
 ?	
 ?return	
 ?false
	
 ?	
 ?end
	
 ?	
 ?@queue.synchronize	
 ?do
	
 ?	
 ?	
 ?	
 ?enqueue(top)
	
 ?	
 ?	
 ?	
 ?@queue	
 ?<<	
 ?top
	
 ?	
 ?	
 ?	
 ?@map.delete(key)
	
 ?	
 ?end
	
 ?	
 ?return	
 ?true
end
Sunday, June 2, 13
Fluent::BasicBu?er#push
	
 ?	
 ?@queue.synchronize	
 ?do
	
 ?	
 ?	
 ?	
 ?enqueue(top)
	
 ?	
 ?	
 ?	
 ?@queue	
 ?<<	
 ?top
	
 ?	
 ?	
 ?	
 ?@map.delete(key)
	
 ?	
 ?end
	
 ?	
 ?return	
 ?true
end
top=@map[key]
data
data
data
@queue
Sunday, June 2, 13
Fluent::BasicBu?er#push
	
 ?	
 ?@queue.synchronize	
 ?do
	
 ?	
 ?	
 ?	
 ?enqueue(top)
	
 ?	
 ?	
 ?	
 ?@queue	
 ?<<	
 ?top
	
 ?	
 ?	
 ?	
 ?@map.delete(key)
	
 ?	
 ?end
	
 ?	
 ?return	
 ?true
end
data
data
data
@queue
Sunday, June 2, 13
Fluent::Bu?eredOutput
emit(tag,data)
emit(tag,data)
Bu?eredOutput
write(data)
Bu?erInput
someting(data)
push
pop
Sunday, June 2, 13
Fluent::BasicBu?er#pop
def	
 ?pop(out)
	
 ?	
 ?chunk	
 ?=	
 ?@queue.first
	
 ?	
 ?if	
 ?!chunk.empty?
	
 ?	
 ?	
 ?	
 ?write_chunk(chunk,	
 ?out)
	
 ?	
 ?end
	
 ?	
 ?@queue.delete_if	
 ?{|c|
	
 ?	
 ?	
 ?	
 ?c.object_id	
 ?==	
 ?chunk.object_id
	
 ?	
 ?}
	
 ?	
 ?chunk.purge
	
 ?	
 ?return	
 ?!@queue.empty?
end
Sunday, June 2, 13
Fluent::BasicBu?er#pop
data
data
data
@queue
def	
 ?pop(out)
	
 ?	
 ?chunk	
 ?=	
 ?@queue.first
	
 ?	
 ?if	
 ?!chunk.empty?
	
 ?	
 ?	
 ?	
 ?write_chunk(chunk,	
 ?out)
	
 ?	
 ?end
	
 ?	
 ?@queue.delete_if	
 ?{|c|
	
 ?
Sunday, June 2, 13
Fluent::BasicBu?er#pop
data
data
data
@queue
def	
 ?pop(out)
	
 ?	
 ?chunk	
 ?=	
 ?@queue.first
	
 ?	
 ?if	
 ?!chunk.empty?
	
 ?	
 ?	
 ?	
 ?write_chunk(chunk,	
 ?out)
	
 ?	
 ?end
	
 ?	
 ?@queue.delete_if	
 ?{|c|
	
 ?
Sunday, June 2, 13
Fluent::Bu?eredOutput
emit(tag,data)
emit(tag,data)
Bu?eredOutput
write(chunk)
Bu?erInput
someting(chunk)
push
pop
Sunday, June 2, 13
Configure parameters
Sunday, June 2, 13
<source>
type tail
path /tmp/test.log
tag test.log
format json
</source>
<match test.log>
type mongo
host localhost
database test
collection log
bu?er_chunk_limit 2m
bu?er_queue_limit 256
flush_interval 1s
</match>
Sunday, June 2, 13
bu?er_chunk_limit
bu?er chunkのサイズ崙
Sunday, June 2, 13
bu?er_queue_limit
queueにはいるchunkの方
Sunday, June 2, 13
flush_interval
queueがpopされるg侯
Sunday, June 2, 13
まとめ
Sunday, June 2, 13
documentをくのは中宜なので
documentをiみたい繁はdocumentをこう
documentがなくてもcodeが弌さければiめる
よくわからなかったらcodeをiもう
Sunday, June 2, 13

More Related Content

酷鉛顎艶稼岳糸がよくわからなかった三