【问题标题】:Filebeat 7.3.0 not parsing multiline jsonFilebeat 7.3.0 不解析多行 json
【发布时间】:2020-01-08 03:17:35
【问题描述】:

我从 ELK 7.3.0 开始使用 SIEM 功能。我现在需要集成 JSON 格式的 Cloudflare 日志。我很确定 filebeat 可以做到这一点。

我已经在我的 CentOS 7 服务器上安装了 filebeat rpm 包

到目前为止我做了什么......

弹性端口更改为:1300 Logstash 端口更改为:2300 Kibana 端口改为:3300

filebeat.yml如下

filebeat.config.inputs:
   enabled: true
   path: configs/*.yml
   reload.enabled: true
   reload.period: 10s

setup.kibana: 
   host: "10.139.111.216:3300"

output.elasticsearch:
   hosts: ["10.139.111.216:1300"]

我已将我的配置放在 /etc/filebeat/modules.d/cloudflare-FW.conf 目录中,因为如果按照我在 filebeat.yml 中提到的任何配置更改,它将重新加载

cloudflare-FW.conf

filebeat.inputs:
- type: log
  enabled: true
  paths:
  - /var/crons/logs/*.json
  multiline.pattern: '^{'
  multiline.negate: true
  multiline.match:  after

processors:
- decode_json_fields:
 fields: ['message']
 target: json

output.elasticsearch:
  hosts: ["10.136.111.216:1300"]
  index: "cloudflare-FW-%{+yyyy.MM.dd}"
  setup.template.enabled: true
  setup.template.name: "cloudflare-FW"
  setup.template.pattern: "cloudflare-FW-*"

这是我要解析的目标 json 文件

{
  "ray_id": "501dxxxxxxxx0ce1b",
  "kind": "firewall",
  "source": "bic",
  "action": "drop",
  "rule_id": "bic",
  "ip": "161.00.6.8",
  "ip_class": "noRecord",
  "country": "GB",
  "colo": "LHR",
  "host": "site.com",
  "method": "POST",
  "proto": "HTTP/1.1",
  "scheme": "https",
  "ua": "Jakarta Commons-HttpClient/3.1",
  "uri": "/nxxxxxxx/senxxxxxxxxail.php",
  "matches": [
    {
      "rule_id": "bic",
      "source": "bic",
      "action": "drop"
    }
  ],
  "occurred_at": "2019-08-06T03:28:57Z"
},
{
  "ray_id": "501dxxxxxxxxxx6ce27",
  "kind": "firewall",
  "source": "bic",
  "action": "drop",
  "rule_id": "bic",
  "ip": "161.61.6.8",
  "ip_class": "noRecord",
  "country": "GB",
  "colo": "LHR",
  "host": "site.com",
  "method": "POST",
  "proto": "HTTP/1.1",
  "scheme": "https",
  "ua": "Jakarta Commons-HttpClient/3.1",
  "uri": "/nxxxxxxx/senxxxxxxxxail.php",
  "matches": [
    {
      "rule_id": "bic",
      "source": "bic",
      "action": "drop"
    }
  ],
  "occurred_at": "2019-08-06T03:02:52Z"
}

当我运行 filebeat -e 时,它​​应该创建一个名为 cloudflare-FW-%{+yyyy.MM.dd} 的索引,并且应该将 json 文件中的数据提取到索引中。最后 JSON key 应该是可以查询的字段。

但这并没有发生。任何帮助是极大的赞赏。请记住,这是 filebeat 7.3.0

谢谢

【问题讨论】:

  • 你的回答成功了吗?
  • 抱歉这么久没有回复。我已经注意到您在配置文件中突出显示的错误;谢谢你但是我通过从http响应而不是使用logstash http输入插件从文件中读取日志并使用split logstash过滤器来拆分json子键来解决我的问题;它工作得很好。

标签: json logging elastic-stack filebeat


【解决方案1】:

我已将我的配置放在 /etc/filebeat/modules.d/cloudflare-FW.conf 目录中

在您的 filebeat.yml 中,您指定了一个完全不同的路径:

filebeat.config.inputs:
  enabled: true
  path: "configs/*.yml" <--
  reload.enabled: true
  reload.period: 10s

在我看来,您的配置甚至没有加载,因为它位于错误的位置。

还要注意您指定的文件扩展名 (*.yml)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-02-26
    • 2017-03-20
    • 1970-01-01
    • 1970-01-01
    • 2021-11-05
    • 2021-04-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多