You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Fluent Bit将完整JSON负载发送至Syslog服务器

问题:Fluent Bit 内存指标完整负载无法通过Syslog输出插件发送

我尝试将Fluent Bit采集的内存指标发送至远程Syslog服务器,打印到stdout时,内存指标输出如下:

[0] memory: [1694350030.133389853, {"Mem.total"=>2006712, "Mem.used"=>1872936, "Mem.free"=>133776, "Swap.total"=>2744316, "Swap.used"=>718668, "Swap.free"=>2025648}]

使用Syslog输出插件时,必须声明syslog_message_key才能成功发送消息。当我将syslog_message_key设为Mem.total时,远程Syslog服务器可成功接收"2006712",但我希望发送{}内的完整负载。

我尝试用Nest过滤器插件将所有内容嵌套在单个Memstats键下,此时stdout输出符合预期:

[0] mem.local: [1694367396.133191260, {"Memstats"=>{"Mem.total"=>2006712, "Mem.used"=>1899256, "Mem.free"=>107456, "Swap.total"=>2744316, "Swap.used"=>737692, "Swap.free"=>2006624}}]

成功添加了Memstats键,但远程Syslog服务器上显示空白日志,在远程系统用Fluent Bit的Syslog输入接收也是如此。起初我以为是解析或接收端配置问题,但用logger命令发送嵌套JSON测试时,syslog-ng服务器能正常显示。

观测到的输出:

//将Mem.total设为syslog_message_key时:
<date> <time> <IP> 1 2023-09-10T19:14:01.132671Z - - - - - 2006712

//将Memstats(通过Nest过滤器)设为syslog_message_key或不设置任何键时:
<date> <time> <IP> 1 2023-09-10T19:14:33.133314Z - - - - - 

//用logger命令向syslog-ng服务器发送嵌套JSON测试:
<date> <time> <IP> 1 2023-09-10T14:01:33.708649-04:00 UbuntuVM vboxuser1 - - [timeQuality tzKnown="1" isSynced="0"] {"Memstats": {"test":"hi", "test2: "hello"}} 

我还尝试过record_modifier和modify,但出现后端失败;使用以下Lua脚本也无效果,甚至看不到Memstats键被添加:

[FILTER]
    Name Lua
    Match *
    call append_record
    code function append_record(tag, timestamp, record) new_record = record new_record["Memstats"] = record return 1, timestamp, new_record end

[OUTPUT]
    Name stdout
    Match *

我更希望通过Fluent Bit插件解决此问题,若有相关经验或方法能发送包含所有内存数据的完整记录而非单个键的整数值,恳请提供帮助!


内容的提问来源于stack exchange,提问作者lsahdow

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.10 15:47:46