fluentd and php
TRANSCRIPT
![Page 1: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/1.jpg)
PHP & Fluentd
![Page 2: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/2.jpg)
@chobi_e
![Page 3: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/3.jpg)
chobi_e is: PECL Sundown Author (will be release soon) h>ps://github.com/chobie/php-‐sundown
libgit2 PHP Binding Author h>ps://github.com/libgit2/php-‐git
phpredis contributor
h>ps://github.com/nicolasff/phpredis
![Page 4: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/4.jpg)
Scaling web servers.
![Page 5: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/5.jpg)
Scaling web servers. basically, just add web server to the array.
![Page 6: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/6.jpg)
then, how about collecLng log files?
![Page 7: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/7.jpg)
using log file
![Page 8: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/8.jpg)
using log file Are you serious?
![Page 9: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/9.jpg)
using syslog like middleware
![Page 10: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/10.jpg)
using syslog like middleware Not Bad.
![Page 11: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/11.jpg)
using reliable and distributed log collector:
Note: fluent-‐logger-‐php does not support output buffering. So local fluentd as a buffer in this case.
![Page 12: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/12.jpg)
using reliable and distributed log collector:
that’s the best soluLon IMHO
Note: fluent-‐logger-‐php does not support output buffering. So local fluentd as a buffer in this case.
![Page 13: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/13.jpg)
fluentd provides robust messaging soluLon
![Page 14: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/14.jpg)
Data Mining
for Data Mining
![Page 15: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/15.jpg)
Data Mining
Queued job
for queued job
![Page 16: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/16.jpg)
fluentd first step with PHP
![Page 17: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/17.jpg)
install by composer
![Page 18: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/18.jpg)
![Page 19: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/19.jpg)
# composer.json { "name": "my-‐project", "version": "1.0.0", "require": { "fluent/logger": "master-‐dev" } }
![Page 20: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/20.jpg)
wget h>p://getcomposer.org/composer.phar php -‐d detect_unicode=0 composer.phar install
![Page 21: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/21.jpg)
<?php require "vendor/.composer/autoload.php"; use Fluent\Logger\FluentLogger; $logger = FluentLogger::open( "debug.test", "localhost", "24224” );
![Page 22: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/22.jpg)
install by copy the tree.
![Page 23: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/23.jpg)
git clone h>ps://github.com/fluent/fluent-‐logger-‐php.git cp -‐r src/Fluent <path/to/your_project>
![Page 24: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/24.jpg)
php library which using Fluentd.
![Page 25: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/25.jpg)
Monolog\Fluent by nrk h>ps://github.com/nrk/monolog-‐fluent.git
![Page 26: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/26.jpg)
what is Monolog? Monolog by Seldaek. h>ps://github.com/Seldaek/monolog Monolog is: heavily inspired by Python's Logbook library, although most concepts have been adjusted to fit to the PHP world.
![Page 27: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/27.jpg)
install $ wget h>p://getcomposer.org/composer.phar $ php composer.phar install
![Page 28: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/28.jpg)
<?php use Nrk\Fluent\Monolog\FluentHandler; $log = new Monolog\Logger('debug.monolog'); $log-‐>pushHandler(new FluentHandler('h>p://127.0.0.1')); $log-‐>pushHandler(new FluentHandler('tcp://127.0.0.1')); $log-‐>addError("OH NOES!!11!1!");
![Page 29: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/29.jpg)
introduce my fluent plugin
![Page 30: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/30.jpg)
fluent-‐plugin-‐delayed -‐ delayed output plugin. h>ps://github.com/chobie/fluent-‐plugin-‐delayed
![Page 31: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/31.jpg)
fluent-‐plugin-‐delayed -‐ delayed output plugin. h>ps://github.com/chobie/fluent-‐plugin-‐delayed
delayed plugin
event{ Lme: 2011-‐10-‐22 10:00:05, # 5 seconds future ... }
Client
: aler 5 seconds. then delayed plugin outputs the data to other output plugin.
output
![Page 32: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/32.jpg)
other Ideas. fluent-‐plugin-‐cooldown -‐ coolodowned outputs when specified key received. fluent-‐plugin-‐sampler -‐ only outputs N % data.
![Page 33: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/33.jpg)
GitHQ / Kokuban Github / gist clone (sLll under development)
![Page 34: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/34.jpg)
updaLng ssh key is pain in ass. /home/git/.ssh/authorized_keys
![Page 35: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/35.jpg)
web server fluentd cooldown exec client
redis update authorized_keys
send public key
sending message via fluentd\Logger
only pass cooldowned message.
updaLng SSH Authorized keys
obtain ssh public keys
![Page 36: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/36.jpg)
Web developer only knows tag for queued job.
![Page 37: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/37.jpg)
Web developer only knows tag for queued job.
Server engineer only implements reliable consumer plugin for Fluentd.
![Page 38: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/38.jpg)
Sounds good?
![Page 39: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/39.jpg)
fluent-‐logger-‐php status.
![Page 40: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/40.jpg)
fluentd protocol support ✔ h>p protocol support ✔ composer support ✔ PEAR package support ✔ -‐ but I don’t provide pear channel.
message pack support buffering support -‐ does not support as there’s trouble some for using persistent variables for buffer.
![Page 41: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/41.jpg)
That’s all
![Page 42: Fluentd and PHP](https://reader033.vdocument.in/reader033/viewer/2022042512/559c98b71a28ab5f5f8b45e6/html5/thumbnails/42.jpg)
That’s all i need more developer! please feel free to pull req me. h>ps://github.com/chobie