问题描述
我在 Fluent-bit (https://fluentbit.io/) 中遇到了一些有关解析器配置的问题。
基本上,我有这样的日志:
[0] var.log.containers.cst-service-cloud-5b4d75f49d-sw4sc_eco-02-dev_cst-service-cloud-2101abcfc24b1d96669f4a7b9756efdd5907b592aa6f39aed93b19376be2cccf.log: [1625815024.211381079,{"log"=>"{"message":"{\"cst\": {\"date_time\": \"2021-07-06T15:30:30+01:00\",\"protocol_version\": \"v1\",\"component\": \"foo-component\",\"component_version\": \"1.2.3\",\"feature\":\"new-feature\",\"cst_name\":\"wh-cst-name\",\"event_type\": \"intern\",\"message\": {\"message_key_83\": \"message_value_83\"},\"uuid\": \"uuid\" }}","timestamp":1625815024210,"log.level":"INFO","logger.name":"com.intern.FooService","thread.name":"scheduled-executor-thread-2","class.name":"java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask","method.name":"run","line.number":305}","stream"=>"stdout","time"=>"2021-07-09T07:17:04.211291241Z"}]
还有这个解析器:
[PARSER]
Name cst-parser
Format json
Decode_Field_As json log
Decode_Field_As json message
Decode_Field_As json cst
这里的重点是 cst
关键内容似乎没有正确转换为 json,所以我想应用一些 json 过滤器(提升等),但我无法做到因为这个。
这是我应用解析器后得到的结果:
[0] var.log.containers.cst-service-cloud-5b4d75f49d-sw4sc_eco-02-dev_cst-service-cloud-2101abcfc24b1d96669f4a7b9756efdd5907b592aa6f39aed93b19376be2cccf.log: [1625816444.211342567,{"log"=>{"message"=>"{"cst": {"date_time": "2021-07-06T15:30:30+01:00","protocol_version": "v1","component": "foo-component","component_version": "1.2.3","feature":"new-feature","cst_name":"wh-cst-name","event_type": "intern","message": {"message_key_236": "message_value_236"},"uuid": "uuid" }}","timestamp"=>1625816444210,"log.level"=>"INFO","logger. name"=>"com.intern.FooService","thread.name"=>"scheduled-executor-thread-2","class.name"=>"java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask","method.name"=>"run","line.num ber"=>305},"time"=>"2021-07-09T07:40:44.211222639Z"}]
请注意,看起来消息开始是 json: log=> message =>
并且 cst
的内容(值)就像它不再有反斜杠 \
但仍然不是 json格式(解析时应显示 =>
)。我也尝试使用 escaped do_next
和 json
来处理所有 json 键(日志、消息和 cst),但得到了相同的结果。
知道为什么会发生这种情况或解决此问题的任何线索吗?谢谢!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)