我试图在Fluent-bit config中找到一种方法来告诉/强制ES存储纯JSON格式的日志(下面的log位来自docker stdout/stderror*)-请参阅底部的图像以获得更好的解释。例如,除了(或者沿着)将日志存储为log
字段下的普通JSON条目,我想单独存储每个属性,如red所示。
过滤器和解析器的文档真的很差,不清楚。最重要的是,forward
输入没有“解析器”选项。我尝试了json/docker/regex
解析器,但没有运气。如果我必须使用正则表达式,我的正则表达式是here。目前使用ES(7.1),Fluent-bit(1.1.3)和Kibana(7.1)-而不是Kubernetes。
如果有人能给我一个例子或给予一个,我将不胜感激。
谢谢
{
"_index": "hello",
"_type": "logs",
"_id": "T631e2sBChSKEuJw-HO4",
"_version": 1,
"_score": null,
"_source": {
"@timestamp": "2019-06-21T21:34:02.000Z",
"tag": "php",
"container_id": "53154cf4d4e8d7ecf31bdb6bc4a25fdf2f37156edc6b859ba0ddfa9c0ab1715b",
"container_name": "/hello_php_1",
"source": "stderr",
"log": "{\"time_local\":\"2019-06-21T21:34:02+0000\",\"client_ip\":\"-\",\"remote_addr\":\"192.168.192.3\",\"remote_user\":\"\",\"request\":\"GET / HTTP/1.1\",\"status\":\"200\",\"body_bytes_sent\":\"0\",\"request_time\":\"0.001\",\"http_referrer\":\"-\",\"http_user_agent\":\"curl/7.38.0\",\"request_id\":\"91835d61520d289952b7e9b8f658e64f\"}"
},
"fields": {
"@timestamp": [
"2019-06-21T21:34:02.000Z"
]
},
"sort": [
1561152842000
]
}
字符串
谢谢
联系我们
[SERVICE]
Flush 5
Daemon Off
Log_Level debug
Parsers_File parsers.conf
[INPUT]
Name forward
Listen 0.0.0.0
Port 24224
[OUTPUT]
Name es
Match hello_*
Host elasticsearch
Port 9200
Index hello
Type logs
Include_Tag_Key On
Tag_Key tag
型
x1c 0d1x的数据
3条答案
按热度按时间bvjxkvbb1#
解决方案如下。
个字符
myzjeezk2#
当Firelens与
aws-for-fluent-bit
图像一起使用时,请考虑更一般的用例,其中消息最终作为顶级密钥log
,如下所示:字符串
在this official AWS example之后,请注意JSON parser already exists in the image,可以这样使用:
型
或者可以通过环境变量调用:
型
测试结果:
型
voj3qocg3#
您可以使用Fluent Bit Nest过滤器来实现此目的,请参阅以下文档:
https://docs.fluentbit.io/manual/filter/nest