【发布时间】: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