【问题标题】:Ingesting JSON Logfiles in elasticsearch with filebeats使用 filebeats 在 elasticsearch 中摄取 JSON 日志文件
【发布时间】:2017-08-12 00:14:51
【问题描述】:

我有一个 JSON 格式的自定义日志文件,我们使用的应用程序将为每个文件输出 1 个条目,如下所示

{"cuid":1,"Machine":"001","cuSize":0,"starttime":"2017-03-19T15:06:48.3402437+00:00","endtime":"2017-03-19T15:07:13.3402437+00:00","rejectcount":47,"fitcount":895,"unfitcount":58,"totalcount":1000,"processedcount":953}

我正在尝试将其引入 ElasticSearch。我相信这是可能的,因为我使用的是 ES5.X

我已经配置了我的 FileBeat 探矿者,我现在尝试至少从文件中提取 1 个字段,即 Cuid

filebeat.prospectors:

input_type: log
json.keys_under_root : true
paths:
C:\Files\output*-Account-*
tags : ["json"]
output.elasticsearch:
# The Logstash hosts
hosts: ["10.1.0.4:9200"]
template.name: "filebeat"
template.path: "filebeat.template.json"
template.overwrite: true

processors:
- decode_json_fields: 
fields: ["cuid"]

当我启动 FileBeat 时,它似乎在收集文件,因为我在 FileBeat 注册表文件中获得了一个条目

2017-03-20T13:21:08Z INFO Harvester started for file: 

C:\Files\output\001-Account-20032017105923.json
2017-03-20T13:21:27Z INFO Non-zero metrics in the last 30s: filebeat.harvester.closed=160 publish.events=320 filebeat.harvester.started=160 registrar.states.update=320 registrar.writes=2

但是,我似乎无法在 Kibana 中找到数据。我不完全确定如何找到它?

我已确保在 kibana 中加载 FileBeat 模板。

我已尝试阅读文档,我认为我理解正确,但我仍然很模糊,因为我对堆栈完全陌生。

【问题讨论】:

    标签: json elasticsearch logging filebeat


    【解决方案1】:

    我仍然不完全确定这是否是正确的答案。但是,我设法解决了我的特定问题。如上所述,我们将多个 JSON 文件写入目录,所有文件都只有一行。尽管 FileBeats 似乎可以收集文件,但我认为它没有读取它们。

    我修改了应用程序以使用 log4Net,并实现了 RollingFileAppender,然后我运行了应用程序,它开始将日志发送到目录,如果魔法,没有修改我的 Filebeat.yml,它就开始工作了。

    我只能得出结论,Filebeats,并不能处理多行 json 文件。除非有我不知道的其他配置。

    【讨论】:

      猜你喜欢
      • 2021-07-31
      • 1970-01-01
      • 2019-10-04
      • 1970-01-01
      • 1970-01-01
      • 2022-01-01
      • 2016-10-18
      • 2021-09-10
      • 2018-07-18
      相关资源
      最近更新 更多