Slide 1

Slide 1 text

fluentd 101 @threetreeslight on shinjuku.rb #64 1 / 27

Slide 2

Slide 2 text

とは? ⼀元的なロギングレイヤー( Unified Logging Layer ) を提供する middleware log aggregator, log shipper fluentd 2 / 27

Slide 3

Slide 3 text

ユースケース 1. アプリのログ集約 2. サービスログの監視 3. データ分析 4. データストアへの接続 5. ストリーム処理 3 / 27

Slide 4

Slide 4 text

なぜUnified する必要があるのか? ログデータを利⽤できるようにするためにバックエンド側のシステムで は多⼤な努⼒を⽀払ってきた so much effort is wasted trying to make various backend systems understand log data. 4 / 27

Slide 5

Slide 5 text

write complex regular expressions skill is a heroic skill 5 / 27

Slide 6

Slide 6 text

欲しいもの 1. log producers と consumers で 共通なインターフェース 2. ⽔平⽅向にスケールし、リトライ・レジュームも可能 3. 新しいデータ⼊出⼒系統への対応がplugin でお⼿軽にできる 6 / 27

Slide 7

Slide 7 text

fluentd 全てを満たす 7 / 27

Slide 8

Slide 8 text

イベントの加⼯も簡単 8 / 27

Slide 9

Slide 9 text

Filters いらないデータすてたり、データのマスキング( アプリケーションでや ったほうが良い) とか容易 A Filter aims to behave like a rule to pass or reject an event. The Filter basically will accept or reject the Event based on its type and rule defined 9 / 27

Slide 10

Slide 10 text

01 02 @type grep 03 04 key action 05 pattern ^logout$ 06 07 10 / 27

Slide 11

Slide 11 text

Labels label 使って特定環境のログデータの処理とか容易 to define new Routing sections that do not follow the top to bottom order 11 / 27

Slide 12

Slide 12 text

01 02 03 @type grep 04 05 key action 06 pattern ^logout$ 07 08 09 10 11 @type stdout 12 13 12 / 27

Slide 13

Slide 13 text

Buffers buffering したりretry してくれるのでアウトプット先への負荷コントロ ールなども容易 Output plugin in buffered mode stores received events into buffers first and write out buffers to a destination by meeting flush conditions. 13 / 27

Slide 14

Slide 14 text

Plugins 新しいデータ⼊出⼒への対応を容易にする 14 / 27

Slide 15

Slide 15 text

1. Input Plugin 2. Output Plugin 3. Filter Plugin 4. Parser Plugin 5. Formatter Plugin 6. Buffer Plugin 7. Storage Plugin 15 / 27

Slide 16

Slide 16 text

Input Plugin データソース⽤、ファイルを呼んだりlogger からforwarding されてきた りできる An input plugin typically creates a thread socket and a listen socket. It can also be written to periodically pull data from data sources. 16 / 27

Slide 17

Slide 17 text

Parser Plugin インプットソースのデータ処理するやつ。filter との使い分けが重要。 cannot parse the user’s custom data format (for example, a context- dependent grammar that can’t be parsed with a regular expression). 17 / 27

Slide 18

Slide 18 text

Filter Plugin label やtag に基づいてデータ整形するやついろいろできる 1. 削ったり 2. イベントの追加したり 3. マスキングしたり 18 / 27

Slide 19

Slide 19 text

Output Plugin いろんな出⼒先に接続するやつ 19 / 27

Slide 20

Slide 20 text

Formatter Plugin Sometimes, the output format for an output plugin does not meet one’s needs. 出⼒フォーマットを決定するやつ 20 / 27

Slide 21

Slide 21 text

Buffer Plugin memory やfile によるbuffering storage 21 / 27

Slide 22

Slide 22 text

Storage Plugin plugin による状態(接続先への転送量など)の統計情報を蓄積できたり 22 / 27

Slide 23

Slide 23 text

いろいろできる 23 / 27

Slide 24

Slide 24 text

もう少し内部を⾒ てみる 24 / 27

Slide 25

Slide 25 text

25 / 27

Slide 26

Slide 26 text

ここからは! abicky さんのblog で内部構造やdata lost について⾒ていく! https://abicky.net/2017/10/23/110103/ 26 / 27

Slide 27

Slide 27 text

ref Fluentd Blog - Unified Logging Layer: Turning Data into Action fluentd - Buffer Plugin Overview あらびき⽇記 - fluentd の基礎知識 sonots:blog - fluentd でログが⽋損する可能性を考える 27 / 27