前回、以下のような記事を書いた。

cowrieの不正侵入ログをelasticsearchにデータを入れる

すると、Masahiro Nakagawaさんから以下のようなコメントいただいた(ありがとうございます!!)

最新版のtd-agent 2を使っているのであれば,stdout filterが入っているので,今ではcopyとstdoutを組み合わせる必要はなくて,type stdoutで簡単にログに吐けるようになっています.今後はこちらもお試しください :)” — Masahiro Nakagawa
ref: http://disq.us/8o5gpu

そこで、td-agent.conf を以下のように書き換えてみた。

修正前

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<match replicator.**>
type copy
<store>
type stdout
</store>
<store>
type mysql_replicator_elasticsearch

# Elasticsearchサーバの接続情報を指定
host localhost
port 9200

# Elasticsearchへレコードを登録する際の index(Database)、type(テーブル)、そしてunique id (primary_key)をどのようにタグから分解するか指定
tag_format (?<index_name>[^\.]+)\.(?<type_name>[^\.]+).(?<event>[^\.]+)\.(?<primary_key>[^\.]+)$

# どの程度バッファに溜めてElasticsearchサーバへ転送するかを指定
flush_interval 5s

# リトライ間隔の最大秒数 (fluentd >= 0.10.41)
max_retry_wait 1800
</store>
</match>

修正後

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<filter replicator.**>
type stdout
</filter>

<match replicator.**>
type mysql_replicator_elasticsearch

# Elasticsearchサーバの接続情報を指定
host localhost
port 9200

# Elasticsearchへレコードを登録する際の index(Database)、type(テーブル)、そしてunique id (primary_key)をどのようにタグから分解するか指定
tag_format (?<index_name>[^\.]+)\.(?<type_name>[^\.]+).(?<event>[^\.]+)\.(?<primary_key>[^\.]+)$

# どの程度バッファに溜めてElasticsearchサーバへ転送するかを指定
flush_interval 5s

# リトライ間隔の最大秒数 (fluentd >= 0.10.41)
max_retry_wait 1800
</match>

修正後は、td-agentを再起動し、問題なくElasticsearchにデータがinsertされるのを確認できた!