【问题标题】:JSON Extractor stops messages from showing up in graylog inputJSON Extractor 阻止消息显示在 graylog 输入中
【发布时间】:2022-08-17 01:19:32
【问题描述】:

我有一个 nginx access_log 输入,它接收 json 格式的日志。我一直试图让 JSON 提取器工作,但无济于事。

首先,我正在关注这个官方的 Graylog 教程:https://www.graylog.org/videos/json-extractor

这是一个样本满的进来的消息:

MyHost nginx: { “timestamp”: “1658474614.043”, “remote_addr”: “x.x.x.x.x”, “body_bytes_sent”: 229221, “request_time”: 0.005, “response_status”: 200, “request”: “GET /foo/bar/1999/09/sth.jpeg HTTP/2.0”, “request_method”: “GET”, “host”: “www…somesite.com”,“upstream_cache_status”: “”,“upstream_addr”: “x.x.x.x.x:xxx”,“http_x_forwarded_for”: “”,“http_referrer”: “https:////www.somesite.com/foo/bar/woo/boo/moo”, “http_user_agent”: “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36”, “http_version”: “HTTP/2.0”, “nginx_access”: true }

然后使用以下正则表达式将其提取到 json 字段中:nginx:\\s+(.*)

然后 json 字段如下所示:

{ “timestamp”: “1658474614.043”, “remote_addr”: “x.x.x.x.x”, “body_bytes_sent”: 229221, “request_time”: 0.005, “response_status”: 200, “request”: “GET /foo/bar/1999/09/sth.jpeg HTTP/2.0”, “request_method”: “GET”, “host”: “www…somesite.com”,“upstream_cache_status”: “”,“upstream_addr”: “x.x.x.x.x:xxx”,“http_x_forwarded_for”: “”,“http_referrer”: “https://www.somesite.com/foo/bar/woo/boo/moo”, “http_user_agent”: “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36”, “http_version”: “HTTP/2.0”, “nginx_access”: true }

然而,从现在开始,事情只会走下坡路。我已经设置了一个基本的默认 JSON 提取器,而没有更改任何选项,当我单击“尝试”时,它会显示正确的输出:

可悲的是,在我实现了这个提取器之后,我的输入中不再显示消息。一定有某种错误,但我在位于/var/log/graylog-server/server.logserver.log 中找不到任何东西。

希望有人能帮我解决这个问题!

    标签: json graylog2 graylog


    【解决方案1】:

    我有同样的问题。 Graylog 有它自己的时间戳字段。您应该尝试将密钥前缀 _ 添加到您的提取器中,这样您的 nginx tmiestamp 就不会与 graylog 时间戳字段冲突

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多