ELK Stack Overview and Use Cases
We take a look a the ELK stack and explore why this tech stack has become a popular tool for data analysis and visualization.
Join the DZone community and get the full member experience.Join For Free
Instead of writing about what exactly ELK is, let me state the need and use cases for it.
Log Aggregation and Efficient Searching
In a very naive scenario, you have one server and lots of log messages generated by your application and system which are crucial to look at once something goes wrong. Now there are basically two problems with it:
- Manually digging through a log file is really an anachronism. We built all this software to automate things and, in the end, are going through a log file line by line? Further, what are our search criteria? We can definitely leverage some sort of ‘automation/programming’ to analyze based on larger and more complex criteria than simply grepping or vimming a file.
- The second problem is related to scale. We don’t have a single server anymore. We have probably a tens or hundreds of VMs running behind a load balancer. We don’t know which server processed the request and definitely are not going to check all the logs one by one.
Here comes ELK.
We treat all the log messages generated as some sort of event and stream it into single storage ordered by timestamp. This channeling of logs/messages/texts is done by Logstash (the L in ELK). These messages/texts are now fed into Elastic clusters (the E in ELK) which is a glorified wrapper around Apache Lucene. Prior to this, messages are preprocessed based on various conditions. Elastic Clusters mainly do something called ‘reverse indexing.’ All the messages are stored as a document and are indexed using the words and phrases. Kibana acts as the front-end UI for the whole stack, providing an interface where you can query for messages using a specified query language, generate charts/visualizations, and so on.
If you are running a Java app called ‘myJavaApp’ and want to quickly see what exceptions have occurred in the last 15 minutes, you can quickly open the Kibana dashboard and fire up a query like:
product:myJavaApp AND msg:’Exception’
This will quickly load all the documents indexed using the keyword 'Exception.' You can write more and more complex queries as you go.
Although log aggregation is the major use case for the ELK stack, it can also be used as a framework for a generic text search where you can leverage reverse indexing. This can be an activity such as searching through a web page. You can also set up a local ELK stack on your system and have your sys logs and var logs analyzed for you.
Opinions expressed by DZone contributors are their own.