Free Alternative to Splunk Using Fluentd
Splunk is a great tool for searching logs, but its high cost makes it prohibitive for many teams. In this article, we present a free and open source alternative to Splunk by combining three open source projects: Elasticsearch, Kibana, and Fluentd.
By combining these three tools (Fluentd + Elasticsearch + Kibana) we get a scalable, flexible, easy to use log search engine with a great Web UI that provides an open-source Splunk alternative, all for free.
In this guide, we will go over installation, setup, and basic use of this combined log search solution. This article was tested on Mac OS X Mountain Lion. If you’re not familiar with Fluentd, please learn more about Fluentd first.
Table of Contents
Java for Elasticsearch
Please confirm that your Java version is 6 or higher.
$ java -version java version "1.6.0_45" Java(TM) SE Runtime Environment (build 1.6.0_45-b06-451-11M4406) Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01-451, mixed mode)
Now that we’ve checked for prerequisites, we’re now ready to install and set up the three open source tools.
Set Up Elasticsearch
To install Elasticsearch, please download and extract the Elasticsearch package as shown below.
$ curl -O https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.0.RC2.tar.gz $ tar zxvf elasticsearch-0.90.0.RC2.tar.gz $ cd elasticsearch-0.90.0.RC2/
Once installation is complete, start Elasticsearch.
$ ./bin/elasticsearch -f
Set Up Kibana
$ curl -O https://download.elasticsearch.org/kibana/kibana/kibana-3.0.0milestone5.tar.gz $ tar zxvf kibana-3.0.0milestone5.tar.gz $ cd kibana-3.0.0milestone5/
Once installation is complete, start Kibana and open
index.html. You can modify Kibana’s configuration via
$ open index.html
Set Up Fluentd (td-agent)
In this guide We’ll install td-agent, the stable release of Fluentd. Please refer to the guides below for detailed installation steps.
Next, we’ll install the Elasticsearch plugin for Fluentd: fluent-plugin-elasticsearch.
The latest version of fluent-plugin-elasticsearch requires
make (if your system has no
Then, install fluent-plugin-elasticsearch as follows.
- td-agent v2:
/usr/sbin/td-agent-gem install fluent-plugin-elasticsearch
- td-agent v1:
/usr/lib/fluent/ruby/bin/fluent-gem install fluent-plugin-elasticsearch
We’ll configure td-agent (Fluentd) to interface properly with Elasticsearch. Please modify
/etc/td-agent/td-agent.conf as shown below:
<source> type syslog port 42185 tag syslog </source> <source> type forward </source> <match syslog.**> type elasticsearch logstash_format true flush_interval 10s # for testing </match>
fluent-plugin-elasticsearch comes with a logstash_format option that allows Kibana to search stored event logs in Elasticsearch.
Once everything has been set up and configured, we’ll start td-agent.
$ sudo /etc/init.d/td-agent start
Set Up rsyslogd
In our final step, we’ll forward the logs from your rsyslogd to Fluentd. Please add the following line to your
/etc/rsyslog.conf, and restart rsyslog. This will forward your local syslog to Fluentd, and Fluentd in turn will forward the logs to Elasticsearch.
Please restart the rsyslog service once the modification is complete.
$ sudo /etc/init.d/rsyslog restart
Store and Search Event Logs
Once Fluentd receives some event logs from rsyslog and has flushed them to Elasticsearch, you can search the stored logs using Kibana by accessing Kibana’s index.html in your browser.
To manually send logs to Elasticsearch, please use the
$ logger -t test foobar
<match syslog.**> type copy <store> # for debug (see /var/log/td-agent.log) type stdout </store> <store> type elasticsearch logstash_format true flush_interval 10s # for testing </store> </match>
Please access the Kibana Demo Environment from the link below.
This article introduced the combination of Fluentd and Kibana (with Elasticsearch) which achieves a free alternative to Splunk: storing and searching machine logs. The examples provided in this article have not been tuned.
If you will be using these components in production, you may want to modify some of the configurations (e.g. JVM, Elasticsearch, Fluentd buffer, etc.) according to your needs.
If this article is incorrect or outdated, or omits critical information, please let us know.