If this feature is enabled, our project can be tested on both Linux and Mac OS X.
Multi OS feature has been enabled for Fluentd repository. See following build:
Cool.io was revived after I became a maintainer. This article describes the current stauts and future work of Cool.io.
Cool.io is a core of Fluentd so I am focusing Fluentd related features.
Windows support
Cool.io is the one of blocker for Fluentd Windows support. Since version 1.2, Cool.io works on Windows and I release mingw based cross-compiling gem for Windows environment.
You can now use Cool.io via gem install cool.io on Windows and we started to implement Windows support of Fluentd.
The limitation on Windows
Cool.io uses select on Windows, not IOCP. In this result, the performance isn’t better than other environments.
This limitation is of little concern in Fluentd forward use-case.
JRuby support
Fluentd works on CRuby and Rubinius. If support JRuby, Fluentd will work on almost popular Ruby environemnts.
Since May 2014, @taichi started to implement JRuby support. @taichi has experience with Java and evented IO frameworks so he is a good person for this task ;)
Remove Ruby 1.8 support
Ruby 1.8 is dead language so Cool.io removes 1.8 support since version 1.2.
Remove HttpClient
AFAIK, there is no HttpClient users including Fluentd. This class depends on Ragel to parse HTTP. It increases the maintenance cost and hard to support on cross platform.
So HttpClient will not be maintained in the future.
Conclusion
Cool.io isn’t dead and Cool.io is still improved. We are now working on more better environment support and fixing the bugs.
If you have a bug of Cool.io, then please file it on github :)
Fluentd is a flexible and robust event log collector, but Fluentd doesn’t have own data-store and Web UI.
If you want to analyze the event logs collected by Fluentd, then you can use Elasticsearch and Kibana :)
Elasticsearch is an easy to use Distributed Search Engine and Kibana is an awesome Web front-end for Elasticsearch.
Setup
I tested on Mac OS X.
Pre requirements
Java for Elasticsearch
Use Mac OS X’s Java.
1234
% java -version
java version "1.6.0_51"Java(TM) SE Runtime Environment (build 1.6.0_51-b11-457-11M4509)Java HotSpot(TM) 64-Bit Server VM (build 20.51-b01-457, mixed mode)
Ruby for Fluentd
In this article, I use my rbenv’s Ruby and Fluentd gem directly.
Treasure Agent, as known as td-agent, is a stable distribution which consists of Fluentd, popular plugins and own Ruby processor.
Many users use td-agent instead of Fluentd gem. See this FAQ.
Elasticsearch
Downlod and extract the latest package.
123
% curl -O https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.11.tar.gz
% tar zxvf elasticsearch-0.90.11.tar.gz
% cd elasticsearch-0.90.11/
# es.conf<source>type forward
</source><matches.**>type elasticsearch
logstash_format true
flush_interval5s # 5s for testing. On production environment, 60s or higher is better
</match>
fluent-plugin-elasticsearch provides logstash_format option.
It enables Kibana to analyze the event logs with day based indexes.
After Fluentd flushed received events to Elasticsearch, you can analyze the event logs via Kibana!
Following image is one panel example:
Kibana has some built-in panels, so you can create own dashboard easily. See Kibana demo
Advanced tips
If your service has a high traffic, then fluent-plugin-elasticsearch sometimes get stucked.
In this case, built-in out_roundrobin plugin is useful.
You can distribute a write request to elasticsearch nodes for load balancing.
Of course, putting Queue with multiple fluentd nodes is an another approach.
Conclusion
This article introduced Fluentd, Elasticsearch and Kibana combination to analyze the event logs.
These components are easy to setup and work fine, so you can try this framework soon!
I heard many companies have already tried / deployed this setup on production :)
In this week, Fluentd v0.10.43 has been released.
Since this version, Fluentd introduced log_level parameter in Input / Output plugin.
It enables you can set different log level separated from global log level, e.g. -v, -q command line option.
This article shows “How to support log_level option in your plugin.”
log_level option use cases
Disable in_tail warning
in_tail prints “pattern no match” warning when receives invalid log. It is useful information for almost users, but some users want to ignore this log for other important plugin warning.
In this case, you can set “log_level error” in in_tail configuration to disable “pattern no match”.
12345
<source>type tail
...
log_levelerror</source>
Debugging
Without log_level, we get many verbose logs using -vv command line option for one plugin. With log_level, you can set verbose configuration in only one plugin.
It is useful for debugging a plugin on acutual environment.
First of all, Fluentd provides $log object as heretofore. So all plugin should work without changing on Fluentd v0.10.43 or later.
To suppot log_level is very easy. Replace $log with log. Following example is fluent-plugin-td’s diff:
12
- $log.debug "checking whether table '#{key}' exists on Treasure Data"+ log.debug "checking whether table '#{key}' exists on Treasure Data"
Support older Fluentd versions
After replaced $log with log, your plugin only works on Fluentd v0.10.43 or later. If you want to support older Fluentd versions, you can use following code in your plugin.
123456789
moduleFluentmoduleFooPluginOutput<Output# Define `log` method for v0.10.42 or earlierunlessmethod_defined?(:log)define_method(:log){$log}end...endend
This code defines log method using $log when log method is not defined, so log.error is same as $log.error on older Fluentd.