Can Fluent Bit's in_forward or a custom plugin dec...
# fluent-bit
d
Can Fluent Bit's in_forward or a custom plugin decode Filebeat's Lumberjack protocol directly (similar to how in_elasticsearch handles Bulk API payloads) to output plain logs?
@Pat, could you please help me with this? I would really appreciate your guidance on the available alternatives and any recommendations you may have.
p
I doubt it will support what is effectively an Elasticsearch proprietary protocol out of the box but it looks like Lumberjack is "just" a TCP protocol so presumably you can use a TCP input plugin with a custom parser or similar to ingest it. I'm guessing you can't just ingest the logs directly that Filebeat is for some reason?
A quick google found this which @Anurag Gupta raised a few years ago so he may have some more/better suggestions? github.com/fluent/fluent-bit/discussions/5211
Ah it looks like there is no straightforward separator for messages, instead it is a binary protocol with a "size" value you have to parse for each message: github.com/elastic/logstash-forwarder/blob/…/PROTOCOL.md The TCP input plugin will not be able to handle it therefore currently it seems.
Further googling shows another article from @Anurag Gupta: chronosphere.io/learn/fluent-bit-vs-beats This has a worked example of sending data from Beats to Fluent Bit using the
in_elasticsearch
plugin so should be doable it seems. I would have a look at that and give it a go - you can then just use a
file
output plugin to write the data out. Not sure why you need to use another plugin to do it as it's all in the Elasticsearch one but I guess there's a specific reason, however I cannot find a way you can do that directly.
You can probably write a custom plugin based off the TCP one that handles the Lumberjack protocol directly (or update the TCP one itself to support binary protocols with a size field in them). The ES plugin will be based on the HTTP one but you could also potentially adjust this to support Lumberjack as well. If it was me I'd probably tweak the TCP one as support for binary protocols with a size field would be useful for everyone so could be merged back in. @hhatake may know of another supported way to do it already or some suggestions on the TCP plugin approach.
👀 2
d
Thank you for your thoughtful insights. I genuinely appreciate you taking the time to help. It means a lot. 🙏
@Pat I'm using the Elastic input plugin receiving logs from multiple Filebeat senders. ​In in_syslog, I can easily capture the sender IP using Source_Address_Key. However, with Filebeat/Elastic inputs, the sender IP resides in an array (e.g., host.ip[0]), or I need to explicitly map the connection socket IP to a custom top-level field like siem-src-device-ip. Since array indexing like host.ip[0] isn't supported out-of-the-box by standard filters like modify, what is the best production-safe alternative to add socket remote addresses into a top-level JSON key? ​Is filter_nest or filter_rewrite_tag capable of this, or is Lua the only recommended path for array field extraction? ​Thanks!
p
People are always scared of LUA for some reason, if it's easy just go with it. You can run it as a processor instead of a filter as well, either on the input or on the output. I would not rewrite_tag unless you really have to. There are also a load of other processors that might work