2016-05-12 13 views
0

"簡単な"ログスタート設定を試していて、チェックするファイルに出力したいとします。だから私はhttps://www.elastic.co/guide/en/logstash/current/plugins-outputs-file.htmlからのconfを取り、私のconfにそれを置く:出力ファイルとコーデックがlogstashによって解析されない設定

input {                                                         
    file { 
    exclude => ['*.gz'] 
    path => ['/var/log/*.log'] 
    type => 'system logs' 
    } 
    syslog { 
    port => 5000 
    } 
} 

output { 
    elasticsearch { 
    hosts => ['elasticsearch'] 
    } 

    file { 
    path => "/config/logstash_out.log" 
    codec => { 
     line { 
     format => "message: %{message}" 
     } 
    } 
    } 

    stdout {} 
} 

が、私はそれ(sudo docker run -it --rm --name logstash -p 514:5000 --link elasticsearch:elasticsearch -v "$PWD":/config logstash logstash -f /config/logstash.conf)を起動したとき、私はlogstashからの苦情持っている:

fetched an invalid config 
{:config=>"input { 
    file { 
    exclude => ['*.gz'] 
    path => ['/var/log/*.log'] 
    type => 'system logs' 
    } 
    syslog { 
    port => 5000 
    } 
} 
output { 
    elasticsearch { 
    hosts => ['elasticsearch'] 
    } 

    file { 
    path => \"/config/logstash_out.log\" 
    codec => { 
     line { 
     format => \"message: %{message}\" 
     } 
    } 
    } 

    stdout {} 
}" 
, :reason=>"Expected one of #, => at line 20, column 13 (byte 507) 
after output { elasticsearch {\n hosts => ['elasticsearch']\n } 
\n\n file {\n path => \"/config/logstash_out.log\"\n  
codec => { \n  line ", :level=>:error} 

(私はしましたが少々再フォーマットされて読みやすくなります)

アイデアは何ですか?私はlogstash output to file and ignores codecですが、提案されている解決策は推奨しないとマークされていますので、避けたいのですが

ありがとう!

答えて

3

チュートリアルと同じようにフォーマットが間違っています。 こちらはthe pull requestです。

それは

codec => { 
     line { 
     format => \"message: %{message}\" 
     } 
    } 

はありませんが、それはあなたが線を中心quirlyブラケットを追加する必要はありません

codec => 
     line { 
     format => "message: %{message}" 
     } 

です。

あなたの設定は正しくあります。

input {                                                         
    file { 
    exclude => ['*.gz'] 
    path => ['/var/log/*.log'] 
    type => 'system logs' 
    } 
    syslog { 
    port => 5000 
    } 
} 

output { 
    elasticsearch { 
    hosts => ['elasticsearch'] 
    } 

    file { 
    path => "/config/logstash_out.log" 
    codec => 
     line { 
     format => "message: %{message}" 
     } 

    } 

    stdout {} 
} 
関連する問題