Post logstash解析日志,没有产生字段

Post log parsing by logstash, there are no fields produced

由于重复出现类似问题,我仔细查看了以前的答案,不幸的是,它并没有解决我的问题。

使用下面提到的 logstash 过滤器配置,我希望在解析日志后生成字段线程、日志级别和消息。

我在 https://grokdebug.herokuapp.com/ 上试过这个过滤器,输出生成过滤器中提到的字段。

然而,除了消息之外,输出中没有显示任何字段 JSON/Kibana。解析时没有错误。

如果有人能指出这里的错误,将会很有帮助。谢谢!

过滤器配置

filter {
  if [type] == "reporting" {
    grok {
      match => { "message" => "\[(?<timestamp>%{TIMESTAMP_ISO8601})\] - %{NOTSPACE:thread} - %{LOGLEVEL:loglevel} (?<logger>[A-Za-z0-9$_.]+) - %{GREEDYDATA:message}$"}
    }
  }
}

日志示例

[2016-08-15 09:44:36,858] - RServer - INFO transformation - [01] starting the process for day 2016-06-06

生成JSON

 {
  "_index": "filebeat-2016.08.15",
  "_type": "log",
  "_id": "xxx",
  "_score": null,
  "_source": {
    "message": "[2016-08-15 09:44:36,858] - RServer - INFO transformation - [01] starting the process for day 2016-06-06",
    "@version": "1",
    "@timestamp": "2016-08-15T09:44:37.700Z",
    "source": "/xxx/yyy/main.log",
    "count": 1,
    "fields": {
      "application": "reporting",
      "category": "main"
    },
    "beat": {
      "hostname": "xxx",
      "name": "xxx"
    },
    "offset": 5033597,
    "type": "log",
    "input_type": "log",
    "host": "xxx",
    "tags": [
      "beats_input_codec_plain_applied"
    ]
  },
  "fields": {
    "@timestamp": [
      1471254277700
    ]
  },
  "sort": [
    1471254277700
  ]
}

感谢@pandaadb 的评论,我想到了检查 FileBeat 的配置并意识到缺少一个字段 "output_type"。这意味着进来的日志没有被过滤,因为过滤器需要某种类型。

使用 "output_type",添加了一个关键字,过滤器使用该关键字根据提到的 GROK 表达式解析日志。由于 FileBeat 的同一实例正在转发不同类别的日志,因此它在转发器本身而不是在 Logstash 的输入配置中被标记。