使用logstash和elasticseach

我实际上使用node-bunyan通过elasticsearch和logstash来pipe理日志信息,而且我正面临一个问题。

实际上,我的日志文件有一些信息,当我需要的时候会很好。

问题是弹性search没有find任何东西

http:// localhost:9200 / logstash- * /

我有一个空的对象,所以,我不能把我的日志,以kibana。

这是我的logstash conf文件:

input { file { type => "nextgen-app" path => [ "F:\NextGen-dev\RestApi\app\logs\*.log" ] codec => "json" } } output { elasticsearch { host => "localhost" protocol => "http" } } 

和我的JS代码:

 log = bunyan.createLogger({ name: 'myapp', streams: [ { level: 'info', path: './app/logs/nextgen-info-log.log' }, { level: 'error', path: './app/logs/nextgen-error-log.log' } ] }) router.all('*', (req, res, next)=> log.info(req.url) log.info(req.method) next() ) 

注意:日志文件写在日志文件中。 问题是在logstash和elasticsearch之间: – /

编辑:查询http:// localhost:9200 / logstash- * /给我“{}”一个空的JSON对象感谢您的提前

下面是我们如何设法解决这个问题和Logstash在Windows上不正确处理文件的其他问题:

  1. 按照下面的说明安装ruby-filewatch补丁: logstash + elasticsearch:重新加载相同的数据

  2. 正确configurationLogstashinput插件:

     input { file { path => ["C:/Path/To/Logs/Directory/*.log"] codec => json { } sincedb_path => ["C:/Path/To/Config/Dir/sincedb"] start_position => "beginning" } } ... 

“sincedb”跟踪你的日志文件的长度,所以每个日志文件应该有一行; 如果没有,那么还有其他的错误。

希望这可以帮助。

您的输出范围看起来不完整。 以下是输出参数列表http://logstash.net/docs/1.4.2/outputs/elasticsearch

请尝试:

 input { file { type => "nextgen-app" path => [ "F:\NextGen-dev\RestApi\app\logs\*.log" ] codec => "json" } } output { elasticsearch { host => "localhost" port => 9200 protocol => "http" index => "logstash-%{+YYYY.MM.dd}" } } 

或者,您可以尝试传输协议:

 output { elasticsearch { host => "localhost" port => 9300 protocol => "transport" index => "logstash-%{+YYYY.MM.dd}" } } 

我也推荐使用Kibana作为数据查看器。 您可以通过https://www.elastic.co/downloads/kibana下载它

Interesting Posts