Skip to content

Instantly share code, notes, and snippets.

@nojima
Last active January 4, 2016 21:49
Show Gist options
  • Save nojima/8684042 to your computer and use it in GitHub Desktop.
Save nojima/8684042 to your computer and use it in GitHub Desktop.

Heka メモ

ビルド

$ sudo apt-get install cmake git mercurial build-essential

# Install Go
$ wget https://go.googlecode.com/files/go1.2.linux-amd64.tar.gz
$ tar xf go1.2.linux-amd64.tar.gz
$ sudo mv go /usr/local/go
$ sudo chown -R root:root /usr/local/go
$ sudoedit /etc/environment
PATH="/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
(restart shell)
$ which go
/usr/local/go/bin/go

# Install protocol buffer
$ sudo apt-get install protobuf-compiler libprotobuf-dev

# Build heka
$ git clone https://github.com/mozilla-services/heka
$ cd heka
$ source build.sh
$ ctest

実行

所定のファイルを監視して行が追加されたら標準エラー出力に書き出すようにしてみる。 以下の設定ファイル(hoge.toml)を用意する。

[hekad]
base_dir = "/home/nojima/heka-cache"

[LogfileInput]
logfile = "/home/nojima/hoge.log"

[debug]
type = "LogOutput"
message_matcher = "TRUE"

実行する。

# base_dir の作成
$ mkdir /home/nojima/heka-cache
# 上でビルドした hekad を実行する
$ ./build/heka/bin/hekad -config hoge.toml

次に別の端末から以下を実行する。

$ echo "Hello, World" >> /home/nojima/hoge.log
$ echo "New Log" >> /home/nojima/hoge.log

すると hekad が標準エラー出力にいろいろ出力してくれる。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment