elasticsearch 日志存储日志已读取,但不会推送到elasticsearch,elasticsearch,logstash,elasticsearch,Logstash" /> elasticsearch 日志存储日志已读取,但不会推送到elasticsearch,elasticsearch,logstash,elasticsearch,Logstash" />

elasticsearch 日志存储日志已读取,但不会推送到elasticsearch

elasticsearch 日志存储日志已读取,但不会推送到elasticsearch,elasticsearch,logstash,elasticsearch,Logstash,我有以下日志存储配置: input { file { codec => "json_lines" path => ["/etc/logstash/input.log"] sincedb_path => "/etc/logstash/dbfile" start_position => "beginning" ignore_older => "0" } } output { elasticsearch {

我有以下日志存储配置:

input {
  file {
    codec => "json_lines"
    path => ["/etc/logstash/input.log"]
    sincedb_path => "/etc/logstash/dbfile"
    start_position => "beginning"
    ignore_older => "0"
  }
}
output {
   elasticsearch {
      hosts => ["192.168.169.46:9200"]
   }
   stdout {
      codec => rubydebug
   }
}
/etc/logstash/input.log文件由运行中的java应用程序的日志填充。日志采用以下json格式(它们以内联方式写入,由
\n
字符分隔):

我还使用ElasticSearchAPI更新了logstash默认模板(将请求主体放在:
http://192.168.169.46:9200/_template/logstash?pretty
):

Elasticsearch响应为
“acknowred”:true
,我可以看到模板通过API更新。 现在以
debug
log级别启动logstash,我看到输入日志正在读取,但没有发送到elasticsearch,虽然索引已创建,但始终为空(0个文档):

另外,elasticsearch日志也在调试级别,但我没有看到任何错误,也没有看到任何可以提示问题根源的信息


你们对为什么不将日志推送到elasticsearch有什么想法或建议吗?

在filebeat中,将ignore\u older设置为零意味着“不检查文件有多旧”。对于日志文件输入,它意味着“忽略超过零秒的文件”,这实际上是“忽略所有内容”。删除它。如果这没有帮助,则增加日志级别以进行跟踪,并查看filewatch模块对其监视的文件的说明。

在filebeat中,将ignore\u older设置为零表示“不检查文件的年龄”。对于日志文件输入,它意味着“忽略超过零秒的文件”,这实际上是“忽略所有内容”。删除它。如果没有帮助,则增加日志级别以进行跟踪,并查看filewatch模块对其监视的文件的说明。

通过使用
json
codec而不是
json\u行
并删除
start\u位置
忽略较旧的
sincedb\u路径

input {
  file {
    codec => "json"
    path => ["/etc/logstash/input.log"]
  }
}
output {
   elasticsearch {
      hosts => ["192.168.169.46:9200"]
   }
   stdout {
      codec => rubydebug
   }
}

另外,
json\u行
编解码器似乎与文件输入不兼容(
\n
分隔符它没有按预期工作)

通过使用
json
编解码器而不是
json\u行
并删除
开始位置
忽略旧的
sincedb\u路径

input {
  file {
    codec => "json"
    path => ["/etc/logstash/input.log"]
  }
}
output {
   elasticsearch {
      hosts => ["192.168.169.46:9200"]
   }
   stdout {
      codec => rubydebug
   }
}

另外,
json\u行
编解码器似乎与文件输入不兼容(
\n
分隔符它没有按预期工作)

好,在日志存储中打开日志的
跟踪
级别并删除
忽略
配置,仍然存在相同的问题。filewatch模块按预期读取日志(当它们增长时),但没有关于数据输出的日志(输出由logstash正确检测和配置)。好的,在logstash中打开日志的
跟踪
级别,并删除
忽略
配置,仍然存在相同的问题。filewatch模块按预期读取日志(当日志增长时),但没有关于数据输出的日志(输出由logstash正确检测和配置)。
[2019-12-03T09:30:51,655][DEBUG][logstash.inputs.file     ][custom] Received line {:path=>"/etc/logstash/input.log", :text=>"{\"@version\":1,\"source_host\":\"ubuntu\",\"message\":\"Generating some logs: 65778 - 2019-12-03T09:30:50.775\",\"thread_name\":\"parallel-1\",\"@timestamp\":\"2019-12-03T09:30:50.775+00:00\",\"level\":\"INFO\",\"logger_name\":\"nl.hnf.logs.aggregator.demo.LoggingTest\",\"aplication-name\":\"demo-log-aggregation\"}"}
[2019-12-03T09:30:51,656][DEBUG][filewatch.sincedbcollection][custom] writing sincedb (delta since last write = 1575365451)
input {
  file {
    codec => "json"
    path => ["/etc/logstash/input.log"]
  }
}
output {
   elasticsearch {
      hosts => ["192.168.169.46:9200"]
   }
   stdout {
      codec => rubydebug
   }
}