2016-05-05 7 views
0

私はELKの新しいユーザーです。私はELKスタックへのログ配送エージェントとしてhekaを使用しています。パスからログを取得するようにLogstashを設定しました。私のlogstashは次のようになりますlogstashがログを処理し、ESにフィードされたことを確認する方法

input { 
    file { 
      path => "/var/log/nds/cmdc/cmdc.audit" 
    } 
} 
output { 
    elasticsearch { 
    hosts => ["10.209.26.147:9200"] 
       } 
     } 

私がlogstashを起動すると、出力は以下のようになります。

[[email protected] logstash]# bin/logstash -f /etc/logstash/conf.d/astro_pdl.conf 
--- jar coordinate com.fasterxml.jackson.core:jackson-annotations already loaded with version 2.7.1 - omit version 2.7.0 
--- jar coordinate com.fasterxml.jackson.core:jackson-databind already loaded with version 2.7.1 - omit version 2.7.1-1 
Settings: Default pipeline workers: 2 
Pipeline main started 

ログには何も表示されません。 Logstashが正しいパスからログを処理したことを確認するにはどうすればよいですか。 ElasticSearchを開始すると、次のように表示されます。

[Morg] recovered [0] indices into cluster_state 

設定に問題がある場合は、教えてください。

答えて

0

file入力プラグインのデフォルトの動作は、tail -fコマンドのようにファイルを読み取ることです。新しい行がファイルに来るかどうか確認してください。ファイルプラグインにstart_position => beginningオプションを追加すると、ファイルの先頭から読み込みを開始できます。

stdout {}を出力plugingに追加することもできます。これはelasticsearchとともに結果をスタンドアット出力に出力します。

1
You need to up your ElasticSearch first. Because ElasticSearch is the database for storing the log and Logstash will push log data there. 
Also you need to make sure that your log is coming to the log file which is configured into the input. I am putting one sample logstash configuration which will help you. 

input { 
file { 
    path => "<filePath>" 
    } 
} 

filter { 
    grok { 
    match => { "message" => "%{COMBINEDAPACHELOG}" } 
    } 
} 

output { 
    elasticsearch { 
    hosts => ["localhost:9200"] 
    sniffing => true 
    manage_template => false 
    index => "%{index}-%{+YYYY.MM.dd}" 

    } 
    stdout { 
    codec => rubydebug 
    } 
} 

In the above configuration I am using simple file path as input. In the filter section I am also using default COMBINEDAPACHELOG. 
In out put section I am giving the elasticSearch host and port and also creating index dynamically for each day. 

After configuring this to your logstash config you need to restart elaslic search first then your logstash with the configuration[Command logstash -f logstash-simple.conf]. 

Then it will push your log to elasticsearch and you can view this log via Kibana UI by creating the index which you set in your configuration like index-2016.05.16. 

You can also check data in your elastic search by using curl command for that particular index. $ curl -XGET 'http://localhost:9200/*