Fluentd: a high performance unified logging layer
linux.com
linux.com
We (OVH) recently tried Heka to push syslog data into Kafka, but it eventually kept crashing under load. Other alternatives were way to slow for our needs.
So we ended up writing a simple tool, not as flexible as Heka but about 10 times faster https://github.com/jedisct1/flowgger
...and I'm out.
step2: mention mongo
step3: enjoy having the room to yourself
:-P
Also, I am giving MongoDB the benefit of the doubt per Curt Monash's law of databases:
Rule 1. It takes at least 7 years to build a database
Rule 2. You are not an exception to Rule 1.
I would still use mariadb or postgresql before mysql.
just because the big boys use it, doesn't mean it's good.
I honestly don't know if that mitigates against a lot of the MongoDB hate you see around here (including my post above). If I was at a place like Stripe and that money to pay Aphyr to battle-test all my database systems and an ops staff the handle all the issues that he found, then I could maybe deploy MongoDB successfully. I'd also have the sort of really, really hard problems that require me to spend that kind of resources on the problem. MongoDB is a much, much worse choice for those of us who DON'T have those needs and resources, though.
It's this funny situation where some engineer starts off using it because it's very convenient to run, and maybe the data model is convenient. You scale it up a bit, debug it, tune it, stuff you'd have to do with any system. At the point when you're sure mongo really sucks, it's too late. The business and even technical management side always prioritizes some other project over replacing it, even though you spend a surprising amount of time each month maintaining the mongodb cluster (performance degredation that compaction doesn't completely fix, and other stuff...).
I get the sense that with 3.0.3 or so, mongodb is a real database now. But it's been years of pain and false advertising. I'd still always vote against it. (Even though at my current place some people started using it for a service... :(
None of the above (HTTP, MongoDB, etc...) is needed at all, you can just as well setup a logfile watcher as input, which sends the log messages over to a logfile writer on another machine, all within 5..10 minutes on 2 VMs.
Or you can directly write messages (JSON or MessagePack) to a TCP socket (MessagePack-formatted messages to TCP socket is basically the lowest level you get).
Messages have a tag for filtering and routing.
It's basically just input plugins connected to output plugins, and you build a message distribution network from that. And it is extremely easy to get into.
e.g.
https://github.com/fluent/fluent-logger-php https://github.com/fluent/fluent-logger-python
and a bit of drama
There is nothing to be scared:
- Fluentd is an enterprise solution already adopted by thousands of users.
- Fluentd is sponsored and made by Treasure Data[0] where we collect around 800k events per second.
- You have to make a difference between what is official and what is third party. Fluentd have more than 300 plugins and is likely that you will find some differences on how each extension is used, but at the end everything is compatible. We make sure to maintain a clean list[1] of functional and maintained extensions.
- We lead the project and we invite you to reach us anytime through our mailing list or other communication channel[2]
reach us anytime :)
[0] http://www.teasuredata.com
I wonder if we can expect "Call me maybe - fluentd" from Aphyr soon. ;)
I _wish_ rsyslog and their friends were really that easy to extend, and I say this as a maintainer of Fluentd. Fluentd came about precisely because syslog family of data collectors fall short in certain ways:
1. tag-based data routing: as you get more and more data sources, it becomes very important to keep track of what goes where. In my view, this is one of the key reasons Fluentd is used at many companies, and why Kafka has become popular on the message queue side (topic-based stream modeling)
2. Extensibility: afaik, it's not all that intuitive for most programmers and sysadmins to extend and add new inputs, outputs, filters, etc. for rsyslog and/or syslog-ng. Admittedly, this is a subjective point, but looking at both Logstash and Fluentd's vast lists of plugins [1][2], I feel justified to make this claim.
3. Configurable transport logic: I've never met anyone who is happy with syslog's buffering and/or failovers. Because we've heard so much about this particular problem, when we were building Fluentd (...4 years ago), we took extra care to make buffering and failover easy to configure and extensible.
Happy to answer more questions =D
Fluentd, on the other hand, does very little to handle logs. It receives, processes and forwards structured messages. Those can be logs, of course, once you apply liblognorm or grok, but it's far from be the only thing. I wouldn't use, for example, syslog to transport monitoring data or inventory, but Fluentd matches the task very well.
I haven't really taken the time to look for a logger with such a feature, it would be nice to know if fluentd has something like this.
I turn it off on my stand-alone systems, it's a waste of processing on them IMHO (particularly if you don't backup the sealing key)
It initially had some memory leaks that prevented us to use it in production, but it's now very stable. Writing new input/output plugins is extremely simple. And yes, it's written in Ruby, but give it a spin before judging; it's fast enough for most needs.
Interesting that graylog (an endpoint for fluentd) are providing their own log collector now.
- no data loss
- performance
[0] Heka: https://hekad.readthedocs.org/
[1] Chainsd: https://github.com/mikeszltd/chainsd
[2] Flogger: https://github.com/jedisct1/flowgger
It's fast enough for most applications while providing a lot of flexibility.
Sure, it has the features and reliability. But does that really justify having to maintain a completely new environment? Maybe it does, maybe it doesn't; it depends.
No you may not be embedding it in your app, but it's now a part of your stack. You'll need to keep an eye on updates, etc for a completely different environment.
Plus there are other factors, like approved languages. Certain companies only allow using languages X and Y. Don't even think about language Z. I had to re-write an 80loc Python script to a much larger Perl one because I just didn't grok Perl all too well at the time. It didn't matter that Python was installed on the system. All that mattered was that Perl was approved and Python was not.
I'd like to address the "completely new environment" issue though. That should only be considered if you're thinking of owning and modifying the component. There are many software packages that you're going to use as-is, and interact with only via an API or CLI. In those cases the depth of the API/CLI, the quality of its documentation and the strength of its community matter way more than implementation language. (For example - who cares if nginx is written in C although your entire stack is Python or Java?)
If you're thinking of continually making changes in a package however - that's a different matter.
The way it was described in the docs gave me the impression there is no acknowledgement of network writes - if that's true won't even clean shutdowns lose data sometimes?
Where does it say this? I don't think this was ever the case for Fluentd.
>The way it was described in the docs gave me the impression there is no acknowledgement of network writes - if that's true won't even clean shutdowns lose data sometimes?
This is not true. All writes are acknowledged over TCP, at least between Fluentd and Fluentd.
It's in http://docs.fluentd.org/articles/high-availability#forwarder..., which says:
However, possible message loss scenarios do exist:
The process [log forwarder’s fluentd from the paragraph above] dies immediately after receiving the events, but before writing them into the buffer.
Is this document out of date?
No, in the described case, the message can get lost. This is a really unlikely scenario though. The only real-world case that I know of first-hand is using file buffer and somehow being unable to write to disk, possibly because the disk is full. Something like that can be prevented by a fairly routine set of server monitoring alerts.
Fuentd provides "buffer_type file" to buffer records on disk. Shutting down won't loose data. If you need to choose memory buffer for performance reasons, fluentd enables "flush_at_shutdown" option by default.
You would also want to use <secondary> feature. This lets you to write a buffer chunk to another storage if the primary destination is not available "retry_limit" times.
Those concerns would be solved by the document: http://docs.fluentd.org/articles/out_forward#buffered-output...
I am still interested in forwarder failure cases - I have replied to kiyoto's comment talking about the HA docs, which still talk about some other cases that can lose messages.
In this case:
* The process dies immediately after receiving the events, but before writing them into the buffer.
Is it possible to require acknowledgement that the log event has been written to the buffer? Is that separate to what require_ack_response does?
Fluentd is extremely easy to install. They provide packages with everything you need; you don't even have to install Ruby beforehand.