前回の「fluentd検証12~Windowsのイベントログを転送する」からの続きです。
WindowsイベントログをLinuxのFluentdへ転送する手順を確認しましたが、日本語のメッセージが文字化けしてしまいました。
Windowsの扱う文字コード(JIS)とLinuxの扱う文字コード(UTF-8)が違うためです。
Linuxに転送する前にnxlog側でUTF-8に変換する必要があります。
2015-11-26 00:48:26 +0900 windowslog.user.info: {"host":"tadashi-PC.bc.local","ident":"Cmd","message":": 2015-11-26 00:48:26 tadashi-PC.bc.local INFO 100 BC\\Administrator eXgbZ[W "}
ホントは日本語ですが、上記のように文字化けます。
<Extension charconv>
Module xm_charconv
AutodetectCharsets shift_jis, utf-8
</Extension>
<Extension syslog>
Module xm_syslog
</Extension>
<Extension json>
Module xm_json
</Extension>
<Input in>
Module im_mseventlog
SavePos TRUE
Exec convert_fields("AUTO", "utf-8");
</Input>
<Processor t>
Module pm_transformer
OutputFormat syslog_bsd
Exec $Message=(": "+$raw_event);
</Processor>
<Output out>
Module om_udp
Host 172.17.9.100
Port 5140
</Output>
<Route r>
Path in => t => out
</Route>
windows側のnxlog.confを上記のように修正します。
<Input>~</Input>のところで、utf-8への変換を行なっています。
2015-11-26 00:49:52 +0900 windowslog.user.info: {"host":"tadashi-PC.bc.local","ident":"Cmd","message":": 2015-11-26 00:49:52 tadashi-PC.bc.local INFO 100 BC\\Administrator テストメッセージ "}
今度はちゃんと日本語を表示してくれました。
WindowsイベントログをLinuxのFluentdへ転送する手順を確認しましたが、日本語のメッセージが文字化けしてしまいました。
Windowsの扱う文字コード(JIS)とLinuxの扱う文字コード(UTF-8)が違うためです。
Linuxに転送する前にnxlog側でUTF-8に変換する必要があります。
2015-11-26 00:48:26 +0900 windowslog.user.info: {"host":"tadashi-PC.bc.local","ident":"Cmd","message":": 2015-11-26 00:48:26 tadashi-PC.bc.local INFO 100 BC\\Administrator eXgbZ[W "}
ホントは日本語ですが、上記のように文字化けます。
<Extension charconv>
Module xm_charconv
AutodetectCharsets shift_jis, utf-8
</Extension>
<Extension syslog>
Module xm_syslog
</Extension>
<Extension json>
Module xm_json
</Extension>
<Input in>
Module im_mseventlog
SavePos TRUE
Exec convert_fields("AUTO", "utf-8");
</Input>
<Processor t>
Module pm_transformer
OutputFormat syslog_bsd
Exec $Message=(": "+$raw_event);
</Processor>
<Output out>
Module om_udp
Host 172.17.9.100
Port 5140
</Output>
<Route r>
Path in => t => out
</Route>
windows側のnxlog.confを上記のように修正します。
<Input>~</Input>のところで、utf-8への変換を行なっています。
2015-11-26 00:49:52 +0900 windowslog.user.info: {"host":"tadashi-PC.bc.local","ident":"Cmd","message":": 2015-11-26 00:49:52 tadashi-PC.bc.local INFO 100 BC\\Administrator テストメッセージ "}
今度はちゃんと日本語を表示してくれました。

コメント