Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Log Everything with Fluentd
Search
Kentaro Kuribayashi
February 15, 2013
Technology
4.2k
4
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Log Everything with Fluentd
Kentaro Kuribayashi
February 15, 2013
More Decks by Kentaro Kuribayashi
See All by Kentaro Kuribayashi
あとはAIに任せて人間は自由に生きる
kentaro
5
2.2k
社会人力と研究力ー博士号をキャリアの武器にするー
kentaro
3
320
IoTシステム開発の複雑さを低減するための統合的アーキテクチャ
kentaro
2
2.4k
Bidirectional Quadratic Voting Leveraging Issue-Based Matching
kentaro
2
770
大高生へのメッセージ(令和6年度「大高未来塾」) / Messages to Current Students
kentaro
0
350
「始め方」の始め方 / How to Start Starting Things
kentaro
5
1k
Dynamic IoT Applications and Isomorphic IoT Systems Using WebAssembly
kentaro
1
1.7k
わたしがこのところハマっている「ライセンスフリー無線」のご紹介 / An Invitation to License-Free Radio
kentaro
1
770
先行きの見えなさを楽しさに変える ーVUCA時代のキャリア論と絶対他力主義ー / How to develop your career in the VUCA era
kentaro
8
6.9k
Other Decks in Technology
See All in Technology
AI Agentをシステムに組み込む前にゆるく向き合ってみる
hayama17
0
170
Agentic AI 時代のテスト手法: Kiro とはじめるプロパティベーステスト (AWS Summit Japan 2026 | DEV212)
ymhiroki
0
100
AIをフル活用してオンコール機能のプロトタイプを2日で作った話 / Building an AI-Powered On-Call Prototype in Just Two Days
nari_ex
0
150
AI時代における最適なQA組織の作り方
ymty
3
190
デジタル・デザイン:次の50年を描く「進化する青写真」
y150saya
0
290
秘密度ラベル初心者が第1歩でつまづかないための「設計・運用」ポイント
seafay
PRO
1
520
打造你的 AI 工作流:Agent Skill + MCP 實戰工作坊
appleboy
0
190
Why is RC4 still being used?
tamaiyutaro
0
200
AI時代のコスト管理を考えよう〜明日から使える実践AWSノウハウ~
yoshimi0227
0
970
「勝手に広まる」人気 AI エージェントを爆速で作ろう!(AWS Summit Japan 2026講演資料)
minorun365
PRO
10
2.7k
なぜ人は自分のプロジェクトを 「なんちゃってアジャイル」と 自嘲するのか
kozotaira
0
170
10年間のブログ発信を振り返って見えたWebアプリケーションエンジニアとしての軌跡
stefafafan
0
190
Featured
See All Featured
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
620
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.5k
For a Future-Friendly Web
brad_frost
183
10k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
25k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
210
SEO for Brand Visibility & Recognition
aleyda
0
4.6k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
1
3.6k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.5k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
870
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
How to make the Groovebox
asonas
2
2.2k
Transcript
Log Everything @kentaro
@kentaro Software engineer Rubyist / Perl Monger Kentaro Kuribayashi paperboy&co.
PHPer
None
Contributions to Fluentd World
out_flatten https://github.com/kentaro/fluent-plugin-flatten out_extract_query_params https://github.com/kentaro/fluent-plugin-extract_query_params out_rewrite https://github.com/kentaro/fluent-plugin-rewrite
None
Log Format
None
• Easy to extend • Easy to parse
Key Description Apache Nginx time Time request is received %t
$time_local vhost Host name %v $host host Remote host %h $remote_addr method Request method %m $method path Request path %U%q $request_uri version HTTP version %H $server_protocol status Response status %>s $status size Response size %b $body_bytes_sent referer Referer %{Referer}i $http_referer ua User-agent %{User-Agent}i $http_user_agent restime Time elapsed for response %D $request_time ustime Time elapsed for upstream response - $upstream_response_time
LogFormat "vhost:%V\ttime:%t\thost:%h\tmethod:%m\tpath:%U%q \tversion:%H\tstatus:%>s\tsize:%b\treferer:%{Referer}i\tua: %{User-Agent}i\trestime:%D" ltsv log_format ltsv "vhost:$host\ttime:$time_local\thost: $remote_addr\tmethod:$request_method\tpath:$request_uri \tversion:$server_protocol\tstatus:$status\tsize:
$body_bytes_sent\treferer:$http_referer\tua: $http_user_agent\trestime:$request_time\tustime: $upstream_response_time"; Apache Nginx
Log Everything to Access Log File
with Log Everything to Access Log File
fluent-plugin-php
None
apache_note()
%{foo}n #=> bar apache_note(‘foo’, ‘bar’) PHP Code Apache Log Format
Flags
• URL Groups • User/Guest • Device • Bot Access
• etc.
Structuralize URLs • Visualization • Analysis • Rough grouping is
enough
Group Path read ^/book buy ^/cart ^/book/\d+/purchase find ^/special ^/label
^/users ^/books ^/authors write ^/admin ^/users/{account}/draft set ^/users/{account}/manage ^/users/{account}/profile ^/users/{account}/account communicate ^/users/{account}/contact ^/users/{account}/reaction top ^/$ ^$
out_rewrite
<match apache.log.**> type rewrite remove_prefix apache.log add_prefix filtered # url
group <rule> key uriGroup pattern ^(.+)$ append_to_tag true fallback other </rule> ...
... # pc/smartphone <rule> key device pattern ^(pc|sp)$ append_to_tag true
</rule> ...
... # user/guest <rule> key loggedIn pattern ^(user|guest)$ append_to_tag true
</rule> </match>
filtered.book.pc.user => { ... } filtered.book.sp.guest => { ... }
filtered.read.pc.guest => { ... } ... uriGroup:book device:pc loggedIn:user ... ... uriGroup:book device:sp loggedIn:guest ... ... uriGroup:read device:pc loggedIn:guest ... Raw Log Lines Filtered Key/Values
None
Profiling
Problem Hard to track results continuously
class Foo { function hoge () { $this->profiler->start(‘method-hoge’); // ...
do something ... $this->profiler->end(‘method-hoge’); } function fuga () { $this->profiler->start(‘method-fuga-foo’); // ... do something ... $this->profiler->end(‘method-fuga-foo’); $this->profiler->start(‘method-fuga-bar’); // ... do something ... $this->profiler->end(‘method-fuga-bar’); } }
public function dispatchLoopShutdown() { $profile_result = Model_Measure::dump(); if (APPLICATION_ENV !==
'production') { Pb_Logger::debug($profile_result); } Pb_Util::httpd_note('profile', json_encode($profile_result)); }
static public function httpd_note($name, $value = '') { if (function_exists('apache_note'))
{ if ($value) { return apache_note($name, $value); } else { // do nothing... } } }
... profile:%{profile}n" ... profile:{\"book.index.get_book\":0.1010639667511, \"book.index.get_author\":0.2032630443573, \"book.index.get_chapters\":0.23988509178162, \"book.index.get_version\":0.039833068847656, \"book.index.check\":0.00014090538024902, \"book.index.get_pager\":0.00022792816162109} Log
Format Raw Log Line
out_flatten
<match test.**> type flatten key foo add_tag_prefix flattened. remove_tag_prefix test.
inner_key value_for_flat_key </match> "test" => { "foo" => '{"bar" : {"qux" : "quux", "hoe" : "poe" }, "baz" : "bazz" }', "hoge" => "fuga" } "flattened.foo.bar.qux" => { "value_for_flat_key" => "quux" } "flattened.foo.bar.hoe" => { "value_for_flat_key" => "poe" } "flattened.foo.baz" => { "value_for_flat_key" => "bazz" } flattened
<match app.httpd.access> type flatten key profile inner_key response_time add_tag_prefix flattened.
remove_tag_prefix app.httpd.access. </store>
None
None
Bonus
out_extract_query_params
<match test.**> type extract_query_params key url add_tag_prefix extracted. only foo,
baz </match> "test" => { "url" => "http://example.com/?foo=bar&baz=qux&hoge=fuga" } "extracted.test" => { "url" => "http://example.com/?foo=bar&baz=qux&hoge=fuga" "foo" => "bar", "baz" => "qux" } Extract Params
<match access_log> type extract_query_params key path add_tag_prefix extracted. only hoge
</match> method:%m path:%U%q version:%H #=> method:GET path:/foo/bar?campaign_id=1 version:HTTP1.1 extracted.access_log => { "method" : "GET", "path" : "/foo/bar?campaign_id=1", "version" : "HTTP1.1", "campaign_id" : "1" } Extract Params Works fine with LTSV
Recap
• Adopt LTSV asap • Log things as much as
possible • My plugins help you