Production Level Knowledge & Tips. Updated at every month 1st Monday 7:00 AM JST.

  1. プログラミング
  2. 30 view

fluentd をインストールして使ってみる

fluentd

Target

fluentdをインストールしてファイルにechoの結果を出力させてみる。

fluentdのインストール

$ sudo apt-add-repository 'deb http://packages.treasure-data.com/debian/ lucid contrib'
$ sudo apt-get update
$ sudo apt-get install td-agent
$/usr/lib/fluent/ruby/bin/fluentd --version
fluentd 0.10.39

コンフィグファイル設定

$ sudo mkdir /etc/td-agent/conf
$ sudo vim /etc/td-agent/conf/test.conf
# Standard Input
<source>
  type forward
</source>
# Output File
<match debug.**>
  type file
  path /var/log/td-agent/debug
</match>

起動スクリプト設定

$ sudo vim /etc/init.d/td-agent
 20 # PATH should only include /usr/* if it runs after the mountnfs.sh script
 21 PATH=/sbin:/usr/sbin:/bin:/usr/bin
 22 USER=td-agent                   # Running user
 23 GROUP=td-agent                  # Running group
 24 DESC=td-agent                   # Introduce a short description here
 25 PIDFILE=/var/run/$NAME/$NAME.pid
 26 DAEMON=/usr/lib/fluent/ruby/bin/ruby # Introduce the server's location here
 27 # Arguments to run the daemon with

< 28 DAEMON_ARGS="/usr/sbin/td-agent $DAEMON_ARGS --daemon $PIDFILE --log /var/log/td-agent/td-agent.log
-------
> 28 DAEMON_ARGS="/usr/sbin/td-agent $DAEMON_ARGS --daemon $PIDFILE --log /var/log/td-agent/test.log"

 29 SCRIPTNAME=/etc/init.d/$NAME
 30 START_STOP_DAEMON_ARGS=""
 31 

$ sudo vim /usr/sbin/td-agent
  1 #!/usr/lib/fluent/ruby/bin/ruby
  2 ENV["GEM_HOME"]="/usr/lib/fluent/ruby/lib/ruby/gems/1.9.1/"
  3 ENV["GEM_PATH"]="/usr/lib/fluent/ruby/lib/ruby/gems/1.9.1/"

<  4 ENV["FLUENT_CONF"]="/etc/td-agent/td-agent.conf"
---
>  4 ENV["FLUENT_CONF"]="/etc/td-agent/conf/test.conf"

  5 ENV["FLUENT_PLUGIN"]="/etc/td-agent/plugin"
  6 ENV["FLUENT_SOCKET"]="/var/run/td-agent/td-agent.sock"
  7 load "/usr/lib/fluent/ruby/bin/fluentd"

起動

$ sudo /etc/init.d/td-agent restart
$ echo '{"test":"message"}' | fluent-cat debug.test
$ cat /var/log/td-agent/debug.20131006.b4e80c93fc8c29d46
2013-10-06T06:23:46+00:00	debug.test	{"test":"message"}

プログラミングの最近記事

  1. How to bring columns not GROUP BY key from ne…

  2. HiveでGROUP BYを伴うサブクエリのネストからGROUP BYのキー以外のカラムを…

  3. How to drop Hive’s External Table

  4. HiveでExternal Tableを削除する方法メモ

  5. [触ってみた]Microsoft Quantum Development Kit

関連記事

PAGE TOP