SlideShare une entreprise Scribd logo
1  sur  73
Télécharger pour lire hors ligne
Dive into Fluent P
                         lugin



2012   2   4
Site:
       repeatedly.github.com



       Company:
       Preferred Infrastructure, Inc.



       Love plugins:
       input: tail
       buffer: memory
       output: mongo
2012   2   4
What's Fluentd?
               The missing log collector
                                      See keynote

                       developed by




2012   2   4
Fluentd is a
   buffer
   router
   collector
   converter
   aggregator
   etc...
2012   2   4
... but,
   Fluentd doesn’t have such features as a built-in.




2012   2   4
Instead,
   Fluentd has flexible plugin architecture
   which consists of Input, Output and Buffer.




2012   2   4
We can customize Fluentd using plugins :)




2012   2   4
Agenda
               Yes, I talk about
               - an example of Fluentd plugins
               - Fluentd and libraries
               - how to develop a Fluentd plugins


               No, I don’t talk about
               - the details of each plugin
               - the experience of production

2012   2   4
Example
               based on bit.ly/fluentd-with-mongo




2012   2   4
Install

               Plugin name is fluent-plugin-xxx ,
               and fluent-gem is included in Fluentd gem.




2012   2   4
Let’s type!


               $ fluent-gem install fluent-plugin-mongo




2012   2   4
Me!


              Many
              Many
              Many
           Plugins!
2012   2   4
fluentd.conf

                Input           Output
       <source>             <match mongo.**>
        type tail            type mongo
        format apache        database apache
        path /path/to/log    collection access
        tag mongo.apache     host otherhost
       </source>            </match>

2012   2   4
Start!


               $ fluentd -c fluentd.conf
               2012-02-04 00:00:14 +0900: starting fluentd-0.10.8
               2012-02-04 00:00:14 +0900: reading config file path="fluentd.conf"
               2012-02-04 00:00:14 +0900: adding source type="tail"
               2012-02-04 00:00:14 +0900: adding match pattern="mongo.**" type="mongo"




2012   2   4
Attack!


               $ ab -n 100 -c 10 http://localhost/




2012   2   4
$ mongo --host otherhost
           > use apache
           > db.access.find()
            {
              "type": "127.0.0.1",
              "method": "GET",
              "path": "/",
              "code": "200",
              "size": "44",
              "time": ISODate("2011-11-27T07:56:27Z")
              ...
             }
           has more...
2012   2   4
Apache              I’m a log!

                                    tail

               write

                                                insert
                                   Fluentd
                       event
                       buffering           Mongo
2012   2   4
Warming up

2012   2   4
Fluentd Stack
                       Output
               Input
                       Buffer
                                Ruby
               MessagePack
                 Cool.io
                        OS
2012   2   4
Ruby
               ruby-lang.org




2012   2   4
Fluentd and plugins are written in Ruby.




2012   2   4
... but note that
               Fluentd works on Ruby 1.9, goodbye 1.8!




2012   2   4
MessagePack
                  msgpack.org




2012   2   4
Serialization:
       JSON like fast and compact format.



       RPC:
       Async and parallelism for high performance.



       IDL:
       Easy to integrate and maintain the service.


2012   2   4
Binary format,
               Header + Body,
               and
               Variable length.




2012   2   4
Note that
               Ruby version can’t handle a Time object.




2012   2   4
So,
               we use an Integer object instead of a Time.




2012   2   4
Source:
       github.com/msgpack



       Wiki:
       wiki.msgpack.org/display/MSGPACK



       Mailing List:
       groups.google.com/group/msgpack


2012   2   4
Cool.io
               coolio.github.com




2012   2   4
Event driven framework built on top of   libev.




2012   2   4
Cool.io has Loop and Watchers with
               Transport wrappers.




2012   2   4
Fluentd has a default event loop.
               We can use @default_loop in the plugin.




2012   2   4
Configuration

2012   2   4
Fluentd loads plugins from $LOAD_PATH.




2012   2   4
Input:
       $LOAD_PATH/fluent/plugin/in_<type>.rb



       Buffer:
       $LOAD_PATH/fluent/plugin/buf_<type>.rb



       Output:
       $LOAD_PATH/fluent/plugin/out_<type>.rb


2012   2   4
We use ‘register_input’, ‘register_buffer’
               and ‘register_output’ to register a plugin.




2012   2   4
We can load the plugin configuration using
               config_param and configure method.
               config_param set config value to
               @<config name> automatically.




2012   2   4
<source>
                type tail
                path /path/to/log
                ...
               </source>                   fluentd.conf



           class TailInput < Input
            Plugin.register_input(’tail’, self)
            config_param :path, :string
            ...
           end                                  in_tail.rb
2012   2   4
One trick is here:

               Fluentd’s configuration module does not
               verify a default value. So,
               we can use the nil like Tribool :)

                config_param :tag, :string, :default => nil

                      Fluentd does not check the type

2012   2   4
Fluentd provides some useful mixins for
               input and output plugins.




2012   2   4
SetTagKeyMixin:
       Provide ‘tag_key’ and ‘include_tag_key’.



       SetTimeKeyMixin:
       Provide ‘time_key’ and ‘include_time_key’.



       DetachMultiProcessMixin:
       Provide ‘detach_process’ and
       execute an action in the multi-process.

2012   2   4
Mixin usage
                Code                   Flow
                                           super
       class MongoOutput <
                BufferedOutput      BufferedOutput
        ...                                super
        include SetTagKeyMixin
        config_set_default          SetTagKeyMixin
          :include_tag_key, false
                                           super
        ...
       end                           MongoOutput
2012   2   4
Input

2012   2   4
Available plugins

               Default     3rd party
               exec         mongo_tail
               forward      scribe
               http         msgpack
               stream       dstat
               syslog       zmq
               tail         amqp
               etc...       etc...
2012   2   4
class NewInput < Input
                ...
                def configure(conf)
                  # parse a configuration manually
                end

                def start
                 # invoke action
                end

                def shutdown
                 # cleanup resources
                end
               end
2012   2   4
In action method,
               we use Engine.emit to input data.

                       tag = "app.tag"
                       time = Engine.now
               Sample:
                       record = {"key" => "value", ...}
                       Engine.emit(tag, time, record)

2012   2   4
How to read an input in an efficient way?
               We use a thread and an event loop.




2012   2   4
Thread
               class ForwardInput < Fluent::Input
                ...
                def start
                  ...
                  @thread = Thread.new(&method(:run))
                end

                def run
                 ...
                end
               end
2012   2   4
Event loop
               class ForwardInput < Fluent::Input
                ...
                def start
                  @loop = Coolio::Loop.new
                  @lsock = listen
                  @loop.attach(@lsock)
                  ...
                end
                ...
               end

2012   2   4
Note that
       We must use Engine.now instead of Time.now




2012   2   4
Buffer

2012   2   4
Available plugins

               Default     3rd party

               memory
               file
               zfile (?)



2012   2   4
In most cases,
               Memory and File are enough.




2012   2   4
Memory type is default.
               It’s fast but can’t resume data.




2012   2   4
File type is persistent type.
               It can resume data from file.




2012   2   4
Output

2012   2   4
Available plugins

               Default     3rd party
               copy          mongo
               exec          s3
               file          scribe
               forward       couch
               null          hoop
               stdout        splunk
               etc...        etc...
2012   2   4
class NewOutput < BufferedOutput
                # configure, start and shutdown
                # are same as input plugin

                def format(tag, time, record)
                 # convert event to raw string
                end

                def write(chunk)
                 # write chunk to target
                 # chunk has multiple formatted data
                end
               end

2012   2   4
Output has 3 buffering modes.
                          None
                          Buffered
                          Time sliced




2012   2   4
Buffering type

               Buffered           Time sliced
  from in
                                 Buffer has an internal
                chunk            map to manage a chunk.
                                 A key is tag in Buffered,
 chunk                  queue    but a key is time slice in
 limit          chunk   limit    TimeSliced buffer.

                        go out   def write(chunk)
                chunk             # chunk.key is time slice
                                 end
2012   2   4
How to write an output in an efficient way?
               We can use multi-process (input too).

               See: DetachMultiProcessMixin
                    with detach_multi_process



2012   2   4
Test

2012   2   4
Input:
       Fluent::Test::InputTestDriver



       Buffer:
       Fluent::Test::BufferedOutputTestDriver



       Output:
       Fluent::Test::OutputTestDriver


2012   2   4
class MongoOutputTest < Test::Unit::TestCase
                def setup
                 Fluent::Test.setup
                 require 'fluent/plugin/out_mongo'
                end
               def create_driver(conf = CONFIG)
                Fluent::Test::BufferedOutputTestDriver.new
                 (Fluent::MongoOutput) {
                 def start # prevent external access
                  super
                 end
                 ...
                }.configure(conf)
               end

2012   2   4
...
               def test_format
                 # test format using emit and expect_format
               end
               def test_write
                d = create_driver
                t = emit_documents(d)
                # return a result of write method
                collection_name, documents = d.run
                assert_equal([{...}, {...}, ...], documents)
                assert_equal('test', collection_name)
               end
               ...
               end

2012   2   4
It’s a weak point in Fluentd... right?




2012   2   4
Release

2012   2   4
Gem Structure
               Plugin root
               |-- lib/
               | |-- fluent/
               |        |-- plugin/
               |              |- out_<name>.rb
               |- Gemfile
               |- fluent-plugin-<name>.gemspec
               |- Rakefile
               |- README.md(rdoc)
               |- VERSION
2012   2   4
Bundle with git
               $ edit lib/fluent/plugin/out_<name>.rb

               $ git add / commit

               $ cat VERSION
               0.1.0

               $ bunlde exec rake release
               See: rubygems.org/gems/fluent-plugin-<name>
2012   2   4
See released plugins
               for more details about each file.




2012   2   4
Lastly...

2012   2   4
Help!
2012   2   4
Question?

2012   2   4

Contenu connexe

Tendances

An introduction to Apache Thrift
An introduction to Apache ThriftAn introduction to Apache Thrift
An introduction to Apache ThriftMike Frampton
 
Fluentd v1.0 in a nutshell
Fluentd v1.0 in a nutshellFluentd v1.0 in a nutshell
Fluentd v1.0 in a nutshellN Masahiro
 
Fluentd Unified Logging Layer At Fossasia
Fluentd Unified Logging Layer At FossasiaFluentd Unified Logging Layer At Fossasia
Fluentd Unified Logging Layer At FossasiaN Masahiro
 
Modern Black Mages Fighting in the Real World
Modern Black Mages Fighting in the Real WorldModern Black Mages Fighting in the Real World
Modern Black Mages Fighting in the Real WorldSATOSHI TAGOMORI
 
Fluentd v1 and future at techtalk
Fluentd v1 and future at techtalkFluentd v1 and future at techtalk
Fluentd v1 and future at techtalkN Masahiro
 
Apache thrift-RPC service cross languages
Apache thrift-RPC service cross languagesApache thrift-RPC service cross languages
Apache thrift-RPC service cross languagesJimmy Lai
 
Stackless Python In Eve
Stackless Python In EveStackless Python In Eve
Stackless Python In Evel xf
 
Fluentd v0.14 Overview
Fluentd v0.14 OverviewFluentd v0.14 Overview
Fluentd v0.14 OverviewN Masahiro
 
The Parenscript Common Lisp to JavaScript compiler
The Parenscript Common Lisp to JavaScript compilerThe Parenscript Common Lisp to JavaScript compiler
The Parenscript Common Lisp to JavaScript compilerVladimir Sedach
 
httpd — Apache Web Server
httpd — Apache Web Serverhttpd — Apache Web Server
httpd — Apache Web Serverwebhostingguy
 
RESTLess Design with Apache Thrift: Experiences from Apache Airavata
RESTLess Design with Apache Thrift: Experiences from Apache AiravataRESTLess Design with Apache Thrift: Experiences from Apache Airavata
RESTLess Design with Apache Thrift: Experiences from Apache Airavatasmarru
 
parenscript-tutorial
parenscript-tutorialparenscript-tutorial
parenscript-tutorialtutorialsruby
 
Lesson 9. The Apache Web Server
Lesson 9. The Apache Web ServerLesson 9. The Apache Web Server
Lesson 9. The Apache Web Serverwebhostingguy
 
Firebird Security (in English): The Past and The Future
Firebird Security (in English): The Past and The FutureFirebird Security (in English): The Past and The Future
Firebird Security (in English): The Past and The FutureAlexey Kovyazin
 

Tendances (20)

An introduction to Apache Thrift
An introduction to Apache ThriftAn introduction to Apache Thrift
An introduction to Apache Thrift
 
Apache Thrift
Apache ThriftApache Thrift
Apache Thrift
 
Fluentd v1.0 in a nutshell
Fluentd v1.0 in a nutshellFluentd v1.0 in a nutshell
Fluentd v1.0 in a nutshell
 
Fluentd Unified Logging Layer At Fossasia
Fluentd Unified Logging Layer At FossasiaFluentd Unified Logging Layer At Fossasia
Fluentd Unified Logging Layer At Fossasia
 
Modern Black Mages Fighting in the Real World
Modern Black Mages Fighting in the Real WorldModern Black Mages Fighting in the Real World
Modern Black Mages Fighting in the Real World
 
Fluentd v1 and future at techtalk
Fluentd v1 and future at techtalkFluentd v1 and future at techtalk
Fluentd v1 and future at techtalk
 
Apache thrift-RPC service cross languages
Apache thrift-RPC service cross languagesApache thrift-RPC service cross languages
Apache thrift-RPC service cross languages
 
upload test 1
upload test 1upload test 1
upload test 1
 
Python at Facebook
Python at FacebookPython at Facebook
Python at Facebook
 
Stackless Python In Eve
Stackless Python In EveStackless Python In Eve
Stackless Python In Eve
 
System Programming and Administration
System Programming and AdministrationSystem Programming and Administration
System Programming and Administration
 
Fluentd v0.14 Overview
Fluentd v0.14 OverviewFluentd v0.14 Overview
Fluentd v0.14 Overview
 
The Parenscript Common Lisp to JavaScript compiler
The Parenscript Common Lisp to JavaScript compilerThe Parenscript Common Lisp to JavaScript compiler
The Parenscript Common Lisp to JavaScript compiler
 
httpd — Apache Web Server
httpd — Apache Web Serverhttpd — Apache Web Server
httpd — Apache Web Server
 
How PHP works
How PHP works How PHP works
How PHP works
 
RESTLess Design with Apache Thrift: Experiences from Apache Airavata
RESTLess Design with Apache Thrift: Experiences from Apache AiravataRESTLess Design with Apache Thrift: Experiences from Apache Airavata
RESTLess Design with Apache Thrift: Experiences from Apache Airavata
 
parenscript-tutorial
parenscript-tutorialparenscript-tutorial
parenscript-tutorial
 
Snaps on open suse
Snaps on open suseSnaps on open suse
Snaps on open suse
 
Lesson 9. The Apache Web Server
Lesson 9. The Apache Web ServerLesson 9. The Apache Web Server
Lesson 9. The Apache Web Server
 
Firebird Security (in English): The Past and The Future
Firebird Security (in English): The Past and The FutureFirebird Security (in English): The Past and The Future
Firebird Security (in English): The Past and The Future
 

Similaire à Fluentd meetup dive into fluent plugin (outdated)

Dive into Fluentd plugin v0.12
Dive into Fluentd plugin v0.12Dive into Fluentd plugin v0.12
Dive into Fluentd plugin v0.12N Masahiro
 
The Beauty and the Beast
The Beauty and the BeastThe Beauty and the Beast
The Beauty and the BeastBastian Feder
 
The Beauty And The Beast Php N W09
The Beauty And The Beast Php N W09The Beauty And The Beast Php N W09
The Beauty And The Beast Php N W09Bastian Feder
 
Quanto è sicuro il tuo wordpress?
Quanto è sicuro il tuo wordpress? Quanto è sicuro il tuo wordpress?
Quanto è sicuro il tuo wordpress? GGDBologna
 
The beautyandthebeast phpbat2010
The beautyandthebeast phpbat2010The beautyandthebeast phpbat2010
The beautyandthebeast phpbat2010Bastian Feder
 
Як РНР розробник пише код на Kotlin
Як РНР розробник пише код на KotlinЯк РНР розробник пише код на Kotlin
Як РНР розробник пише код на Kotlinphpfriendsclub
 
Import golang; struct microservice
Import golang; struct microserviceImport golang; struct microservice
Import golang; struct microserviceGiulio De Donato
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy CodeRowan Merewood
 
Introduction to Dynamic Analysis of Android Application
Introduction to Dynamic Analysis of Android ApplicationIntroduction to Dynamic Analysis of Android Application
Introduction to Dynamic Analysis of Android ApplicationKelwin Yang
 
How To Start Up With PHP In IBM i
How To Start Up With PHP In IBM iHow To Start Up With PHP In IBM i
How To Start Up With PHP In IBM iSam Pinkhasov
 
How To Start Up With Php In Ibm I
How To Start Up With Php In Ibm IHow To Start Up With Php In Ibm I
How To Start Up With Php In Ibm IAlex Frenkel
 
Log4Shell - Armageddon or Opportunity.pptx
Log4Shell - Armageddon or Opportunity.pptxLog4Shell - Armageddon or Opportunity.pptx
Log4Shell - Armageddon or Opportunity.pptxSteve Poole
 
(phpconftw2012) PHP as a Middleware in Embedded Systems
(phpconftw2012) PHP as a Middleware in Embedded Systems(phpconftw2012) PHP as a Middleware in Embedded Systems
(phpconftw2012) PHP as a Middleware in Embedded Systemssosorry
 
What's New In Apache Lenya 1.4
What's New In Apache Lenya 1.4What's New In Apache Lenya 1.4
What's New In Apache Lenya 1.4nobby
 
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdfHashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdfssuser705051
 
Happy porting x86 application to android
Happy porting x86 application to androidHappy porting x86 application to android
Happy porting x86 application to androidOwen Hsu
 
Bringing-it-all-together-overview-of-rpm-packaging-in-fedora
Bringing-it-all-together-overview-of-rpm-packaging-in-fedoraBringing-it-all-together-overview-of-rpm-packaging-in-fedora
Bringing-it-all-together-overview-of-rpm-packaging-in-fedoraLalatendu Mohanty
 

Similaire à Fluentd meetup dive into fluent plugin (outdated) (20)

Dive into Fluentd plugin v0.12
Dive into Fluentd plugin v0.12Dive into Fluentd plugin v0.12
Dive into Fluentd plugin v0.12
 
The Beauty and the Beast
The Beauty and the BeastThe Beauty and the Beast
The Beauty and the Beast
 
The Beauty And The Beast Php N W09
The Beauty And The Beast Php N W09The Beauty And The Beast Php N W09
The Beauty And The Beast Php N W09
 
Quanto è sicuro il tuo wordpress?
Quanto è sicuro il tuo wordpress? Quanto è sicuro il tuo wordpress?
Quanto è sicuro il tuo wordpress?
 
WordPress Hardening
WordPress HardeningWordPress Hardening
WordPress Hardening
 
The beautyandthebeast phpbat2010
The beautyandthebeast phpbat2010The beautyandthebeast phpbat2010
The beautyandthebeast phpbat2010
 
Як РНР розробник пише код на Kotlin
Як РНР розробник пише код на KotlinЯк РНР розробник пише код на Kotlin
Як РНР розробник пише код на Kotlin
 
Import golang; struct microservice
Import golang; struct microserviceImport golang; struct microservice
Import golang; struct microservice
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy Code
 
Introduction to Dynamic Analysis of Android Application
Introduction to Dynamic Analysis of Android ApplicationIntroduction to Dynamic Analysis of Android Application
Introduction to Dynamic Analysis of Android Application
 
MongoDB and Node.js
MongoDB and Node.jsMongoDB and Node.js
MongoDB and Node.js
 
How To Start Up With PHP In IBM i
How To Start Up With PHP In IBM iHow To Start Up With PHP In IBM i
How To Start Up With PHP In IBM i
 
How To Start Up With Php In Ibm I
How To Start Up With Php In Ibm IHow To Start Up With Php In Ibm I
How To Start Up With Php In Ibm I
 
Log4Shell - Armageddon or Opportunity.pptx
Log4Shell - Armageddon or Opportunity.pptxLog4Shell - Armageddon or Opportunity.pptx
Log4Shell - Armageddon or Opportunity.pptx
 
(phpconftw2012) PHP as a Middleware in Embedded Systems
(phpconftw2012) PHP as a Middleware in Embedded Systems(phpconftw2012) PHP as a Middleware in Embedded Systems
(phpconftw2012) PHP as a Middleware in Embedded Systems
 
What's New In Apache Lenya 1.4
What's New In Apache Lenya 1.4What's New In Apache Lenya 1.4
What's New In Apache Lenya 1.4
 
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdfHashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
 
Terraform-2.pdf
Terraform-2.pdfTerraform-2.pdf
Terraform-2.pdf
 
Happy porting x86 application to android
Happy porting x86 application to androidHappy porting x86 application to android
Happy porting x86 application to android
 
Bringing-it-all-together-overview-of-rpm-packaging-in-fedora
Bringing-it-all-together-overview-of-rpm-packaging-in-fedoraBringing-it-all-together-overview-of-rpm-packaging-in-fedora
Bringing-it-all-together-overview-of-rpm-packaging-in-fedora
 

Plus de N Masahiro

Fluentd Project Intro at Kubecon 2019 EU
Fluentd Project Intro at Kubecon 2019 EUFluentd Project Intro at Kubecon 2019 EU
Fluentd Project Intro at Kubecon 2019 EUN Masahiro
 
Fluentd and Distributed Logging at Kubecon
Fluentd and Distributed Logging at KubeconFluentd and Distributed Logging at Kubecon
Fluentd and Distributed Logging at KubeconN Masahiro
 
Presto changes
Presto changesPresto changes
Presto changesN Masahiro
 
Fluentd and Kafka
Fluentd and KafkaFluentd and Kafka
Fluentd and KafkaN Masahiro
 
fluent-plugin-beats at Elasticsearch meetup #14
fluent-plugin-beats at Elasticsearch meetup #14fluent-plugin-beats at Elasticsearch meetup #14
fluent-plugin-beats at Elasticsearch meetup #14N Masahiro
 
Technologies for Data Analytics Platform
Technologies for Data Analytics PlatformTechnologies for Data Analytics Platform
Technologies for Data Analytics PlatformN Masahiro
 
Docker and Fluentd
Docker and FluentdDocker and Fluentd
Docker and FluentdN Masahiro
 
How to create Treasure Data #dotsbigdata
How to create Treasure Data #dotsbigdataHow to create Treasure Data #dotsbigdata
How to create Treasure Data #dotsbigdataN Masahiro
 
Fluentd and Embulk Game Server 4
Fluentd and Embulk Game Server 4Fluentd and Embulk Game Server 4
Fluentd and Embulk Game Server 4N Masahiro
 
Treasure Data and AWS - Developers.io 2015
Treasure Data and AWS - Developers.io 2015Treasure Data and AWS - Developers.io 2015
Treasure Data and AWS - Developers.io 2015N Masahiro
 
Treasure Data and OSS
Treasure Data and OSSTreasure Data and OSS
Treasure Data and OSSN Masahiro
 
Fluentd - RubyKansai 65
Fluentd - RubyKansai 65Fluentd - RubyKansai 65
Fluentd - RubyKansai 65N Masahiro
 
Fluentd - road to v1 -
Fluentd - road to v1 -Fluentd - road to v1 -
Fluentd - road to v1 -N Masahiro
 
Fluentd: Unified Logging Layer at CWT2014
Fluentd: Unified Logging Layer at CWT2014Fluentd: Unified Logging Layer at CWT2014
Fluentd: Unified Logging Layer at CWT2014N Masahiro
 
SQL for Everything at CWT2014
SQL for Everything at CWT2014SQL for Everything at CWT2014
SQL for Everything at CWT2014N Masahiro
 
Can you say the same words even in oss
Can you say the same words even in ossCan you say the same words even in oss
Can you say the same words even in ossN Masahiro
 
I am learing the programming
I am learing the programmingI am learing the programming
I am learing the programmingN Masahiro
 
D vs OWKN Language at LLnagoya
D vs OWKN Language at LLnagoyaD vs OWKN Language at LLnagoya
D vs OWKN Language at LLnagoyaN Masahiro
 
Final presentation at pfintern
Final presentation at pfinternFinal presentation at pfintern
Final presentation at pfinternN Masahiro
 

Plus de N Masahiro (20)

Fluentd Project Intro at Kubecon 2019 EU
Fluentd Project Intro at Kubecon 2019 EUFluentd Project Intro at Kubecon 2019 EU
Fluentd Project Intro at Kubecon 2019 EU
 
Fluentd and Distributed Logging at Kubecon
Fluentd and Distributed Logging at KubeconFluentd and Distributed Logging at Kubecon
Fluentd and Distributed Logging at Kubecon
 
Presto changes
Presto changesPresto changes
Presto changes
 
Fluentd and Kafka
Fluentd and KafkaFluentd and Kafka
Fluentd and Kafka
 
fluent-plugin-beats at Elasticsearch meetup #14
fluent-plugin-beats at Elasticsearch meetup #14fluent-plugin-beats at Elasticsearch meetup #14
fluent-plugin-beats at Elasticsearch meetup #14
 
Technologies for Data Analytics Platform
Technologies for Data Analytics PlatformTechnologies for Data Analytics Platform
Technologies for Data Analytics Platform
 
Docker and Fluentd
Docker and FluentdDocker and Fluentd
Docker and Fluentd
 
How to create Treasure Data #dotsbigdata
How to create Treasure Data #dotsbigdataHow to create Treasure Data #dotsbigdata
How to create Treasure Data #dotsbigdata
 
Fluentd and Embulk Game Server 4
Fluentd and Embulk Game Server 4Fluentd and Embulk Game Server 4
Fluentd and Embulk Game Server 4
 
Treasure Data and AWS - Developers.io 2015
Treasure Data and AWS - Developers.io 2015Treasure Data and AWS - Developers.io 2015
Treasure Data and AWS - Developers.io 2015
 
Treasure Data and OSS
Treasure Data and OSSTreasure Data and OSS
Treasure Data and OSS
 
Fluentd - RubyKansai 65
Fluentd - RubyKansai 65Fluentd - RubyKansai 65
Fluentd - RubyKansai 65
 
Fluentd - road to v1 -
Fluentd - road to v1 -Fluentd - road to v1 -
Fluentd - road to v1 -
 
Fluentd: Unified Logging Layer at CWT2014
Fluentd: Unified Logging Layer at CWT2014Fluentd: Unified Logging Layer at CWT2014
Fluentd: Unified Logging Layer at CWT2014
 
SQL for Everything at CWT2014
SQL for Everything at CWT2014SQL for Everything at CWT2014
SQL for Everything at CWT2014
 
Can you say the same words even in oss
Can you say the same words even in ossCan you say the same words even in oss
Can you say the same words even in oss
 
I am learing the programming
I am learing the programmingI am learing the programming
I am learing the programming
 
D vs OWKN Language at LLnagoya
D vs OWKN Language at LLnagoyaD vs OWKN Language at LLnagoya
D vs OWKN Language at LLnagoya
 
Goodbye Doost
Goodbye DoostGoodbye Doost
Goodbye Doost
 
Final presentation at pfintern
Final presentation at pfinternFinal presentation at pfintern
Final presentation at pfintern
 

Dernier

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 

Dernier (20)

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

Fluentd meetup dive into fluent plugin (outdated)

  • 1. Dive into Fluent P lugin 2012 2 4
  • 2. Site: repeatedly.github.com Company: Preferred Infrastructure, Inc. Love plugins: input: tail buffer: memory output: mongo 2012 2 4
  • 3. What's Fluentd? The missing log collector See keynote developed by 2012 2 4
  • 4. Fluentd is a buffer router collector converter aggregator etc... 2012 2 4
  • 5. ... but, Fluentd doesn’t have such features as a built-in. 2012 2 4
  • 6. Instead, Fluentd has flexible plugin architecture which consists of Input, Output and Buffer. 2012 2 4
  • 7. We can customize Fluentd using plugins :) 2012 2 4
  • 8. Agenda Yes, I talk about - an example of Fluentd plugins - Fluentd and libraries - how to develop a Fluentd plugins No, I don’t talk about - the details of each plugin - the experience of production 2012 2 4
  • 9. Example based on bit.ly/fluentd-with-mongo 2012 2 4
  • 10. Install Plugin name is fluent-plugin-xxx , and fluent-gem is included in Fluentd gem. 2012 2 4
  • 11. Let’s type! $ fluent-gem install fluent-plugin-mongo 2012 2 4
  • 12. Me! Many Many Many Plugins! 2012 2 4
  • 13. fluentd.conf Input Output <source> <match mongo.**> type tail type mongo format apache database apache path /path/to/log collection access tag mongo.apache host otherhost </source> </match> 2012 2 4
  • 14. Start! $ fluentd -c fluentd.conf 2012-02-04 00:00:14 +0900: starting fluentd-0.10.8 2012-02-04 00:00:14 +0900: reading config file path="fluentd.conf" 2012-02-04 00:00:14 +0900: adding source type="tail" 2012-02-04 00:00:14 +0900: adding match pattern="mongo.**" type="mongo" 2012 2 4
  • 15. Attack! $ ab -n 100 -c 10 http://localhost/ 2012 2 4
  • 16. $ mongo --host otherhost > use apache > db.access.find() { "type": "127.0.0.1", "method": "GET", "path": "/", "code": "200", "size": "44", "time": ISODate("2011-11-27T07:56:27Z") ... } has more... 2012 2 4
  • 17. Apache I’m a log! tail write insert Fluentd event buffering Mongo 2012 2 4
  • 19. Fluentd Stack Output Input Buffer Ruby MessagePack Cool.io OS 2012 2 4
  • 20. Ruby ruby-lang.org 2012 2 4
  • 21. Fluentd and plugins are written in Ruby. 2012 2 4
  • 22. ... but note that Fluentd works on Ruby 1.9, goodbye 1.8! 2012 2 4
  • 23. MessagePack msgpack.org 2012 2 4
  • 24. Serialization: JSON like fast and compact format. RPC: Async and parallelism for high performance. IDL: Easy to integrate and maintain the service. 2012 2 4
  • 25. Binary format, Header + Body, and Variable length. 2012 2 4
  • 26. Note that Ruby version can’t handle a Time object. 2012 2 4
  • 27. So, we use an Integer object instead of a Time. 2012 2 4
  • 28. Source: github.com/msgpack Wiki: wiki.msgpack.org/display/MSGPACK Mailing List: groups.google.com/group/msgpack 2012 2 4
  • 29. Cool.io coolio.github.com 2012 2 4
  • 30. Event driven framework built on top of libev. 2012 2 4
  • 31. Cool.io has Loop and Watchers with Transport wrappers. 2012 2 4
  • 32. Fluentd has a default event loop. We can use @default_loop in the plugin. 2012 2 4
  • 34. Fluentd loads plugins from $LOAD_PATH. 2012 2 4
  • 35. Input: $LOAD_PATH/fluent/plugin/in_<type>.rb Buffer: $LOAD_PATH/fluent/plugin/buf_<type>.rb Output: $LOAD_PATH/fluent/plugin/out_<type>.rb 2012 2 4
  • 36. We use ‘register_input’, ‘register_buffer’ and ‘register_output’ to register a plugin. 2012 2 4
  • 37. We can load the plugin configuration using config_param and configure method. config_param set config value to @<config name> automatically. 2012 2 4
  • 38. <source> type tail path /path/to/log ... </source> fluentd.conf class TailInput < Input Plugin.register_input(’tail’, self) config_param :path, :string ... end in_tail.rb 2012 2 4
  • 39. One trick is here: Fluentd’s configuration module does not verify a default value. So, we can use the nil like Tribool :) config_param :tag, :string, :default => nil Fluentd does not check the type 2012 2 4
  • 40. Fluentd provides some useful mixins for input and output plugins. 2012 2 4
  • 41. SetTagKeyMixin: Provide ‘tag_key’ and ‘include_tag_key’. SetTimeKeyMixin: Provide ‘time_key’ and ‘include_time_key’. DetachMultiProcessMixin: Provide ‘detach_process’ and execute an action in the multi-process. 2012 2 4
  • 42. Mixin usage Code Flow super class MongoOutput < BufferedOutput BufferedOutput ... super include SetTagKeyMixin config_set_default SetTagKeyMixin :include_tag_key, false super ... end MongoOutput 2012 2 4
  • 43. Input 2012 2 4
  • 44. Available plugins Default 3rd party exec mongo_tail forward scribe http msgpack stream dstat syslog zmq tail amqp etc... etc... 2012 2 4
  • 45. class NewInput < Input ... def configure(conf) # parse a configuration manually end def start # invoke action end def shutdown # cleanup resources end end 2012 2 4
  • 46. In action method, we use Engine.emit to input data. tag = "app.tag" time = Engine.now Sample: record = {"key" => "value", ...} Engine.emit(tag, time, record) 2012 2 4
  • 47. How to read an input in an efficient way? We use a thread and an event loop. 2012 2 4
  • 48. Thread class ForwardInput < Fluent::Input ... def start ... @thread = Thread.new(&method(:run)) end def run ... end end 2012 2 4
  • 49. Event loop class ForwardInput < Fluent::Input ... def start @loop = Coolio::Loop.new @lsock = listen @loop.attach(@lsock) ... end ... end 2012 2 4
  • 50. Note that We must use Engine.now instead of Time.now 2012 2 4
  • 51. Buffer 2012 2 4
  • 52. Available plugins Default 3rd party memory file zfile (?) 2012 2 4
  • 53. In most cases, Memory and File are enough. 2012 2 4
  • 54. Memory type is default. It’s fast but can’t resume data. 2012 2 4
  • 55. File type is persistent type. It can resume data from file. 2012 2 4
  • 56. Output 2012 2 4
  • 57. Available plugins Default 3rd party copy mongo exec s3 file scribe forward couch null hoop stdout splunk etc... etc... 2012 2 4
  • 58. class NewOutput < BufferedOutput # configure, start and shutdown # are same as input plugin def format(tag, time, record) # convert event to raw string end def write(chunk) # write chunk to target # chunk has multiple formatted data end end 2012 2 4
  • 59. Output has 3 buffering modes. None Buffered Time sliced 2012 2 4
  • 60. Buffering type Buffered Time sliced from in Buffer has an internal chunk map to manage a chunk. A key is tag in Buffered, chunk queue but a key is time slice in limit chunk limit TimeSliced buffer. go out def write(chunk) chunk # chunk.key is time slice end 2012 2 4
  • 61. How to write an output in an efficient way? We can use multi-process (input too). See: DetachMultiProcessMixin with detach_multi_process 2012 2 4
  • 62. Test 2012 2 4
  • 63. Input: Fluent::Test::InputTestDriver Buffer: Fluent::Test::BufferedOutputTestDriver Output: Fluent::Test::OutputTestDriver 2012 2 4
  • 64. class MongoOutputTest < Test::Unit::TestCase def setup Fluent::Test.setup require 'fluent/plugin/out_mongo' end def create_driver(conf = CONFIG) Fluent::Test::BufferedOutputTestDriver.new (Fluent::MongoOutput) { def start # prevent external access super end ... }.configure(conf) end 2012 2 4
  • 65. ... def test_format # test format using emit and expect_format end def test_write d = create_driver t = emit_documents(d) # return a result of write method collection_name, documents = d.run assert_equal([{...}, {...}, ...], documents) assert_equal('test', collection_name) end ... end 2012 2 4
  • 66. It’s a weak point in Fluentd... right? 2012 2 4
  • 68. Gem Structure Plugin root |-- lib/ | |-- fluent/ | |-- plugin/ | |- out_<name>.rb |- Gemfile |- fluent-plugin-<name>.gemspec |- Rakefile |- README.md(rdoc) |- VERSION 2012 2 4
  • 69. Bundle with git $ edit lib/fluent/plugin/out_<name>.rb $ git add / commit $ cat VERSION 0.1.0 $ bunlde exec rake release See: rubygems.org/gems/fluent-plugin-<name> 2012 2 4
  • 70. See released plugins for more details about each file. 2012 2 4
  • 72. Help! 2012 2 4