ELK Stack – this was a new term to me before I undertook this process, it seems overwhelming the first time you take on a new task.
ELK stands for Elasticsearch, Logstash and Kibana. Elasticsearch is a NoSQL database that allows NRT (near real time) queries. Kibana offers a nice interactive interface for analyzing data contained in the Elasticsearch data. Logstash is the intermediary between Elasticsearch and Kibana.
ELK has a large open source community, making this set of utilities quite popular. There are plenty of guides out there and the documentation is helpful. This article will not cover using an ELK stack in a production evironment, we will be setting up a test stack and getting familiar with the process. However, to set up an ELK stack for a production environment would not need too much changing of this process.
Getting Started:
Every component of our ELK stack requires Java. Let’s get busy and start setting up java on an Ubuntu AWS instance via SSH and shell commands. Make sure you have root access: sudo su
Installing Java:
- apt-get update
- apt-get upgrade
- apt-get install openjdk-7-jre-headless
Installing Elasticsearch:
- wget –qO – https://packages.elastic.co/GPG–KEY–elasticsearch | sudo apt–key add –
- echo “deb http://packages.elastic.co/elasticsearch/1.7/debian stable main” | sudo tee –a /etc/apt/sources.list.d/elasticsearch–1.7.list
- apt-get update
- apt-get install elasticsearch
- service elasticsearch restart
Installing Logstash:
- echo “deb http://packages.elasticsearch.org/logstash/1.5/debian stable main” | sudo tee –a /etc/apt/sources.list
- apt-get update
- apt-get install logstash
- service logstash start
Create config file for logstash:
vi /etc/logstash/conf.d/10-syslog.conf
- input {
- file {
- type => “syslog”
- path => [ “/var/log/messages”, “/var/log/*.log” ]
- }
- }
- output {
- stdout {
- codec => rubydebug
- }
- elasticsearch {
- host => “localhost” # Use the internal IP of your Elasticsearch server
- # for production
- }
- }
- :wq
service logstash restart
Kibana Installation:
- wget https://download.elastic.co/kibana/kibana/kibana–4.1.1–linux–x64.tar.gz
- tar -xzf kibana-4.1.1-linux-x64.tar.gz
- cd /kibana-4.1.1-linux-x64/
- mkdir -p /opt/kibana
- mv kibana-4.1.1-linux-x64/* /opt/kibana
- cd /etc/init.d && sudo wget https://raw.githubusercontent.com/akabdog/scripts/master/kibana4_init –O kibana4
- chmod +x /etc/init.d/kabana4
- service kibana4 start
Testing our installs:
Point your browser to ‘http://YOUR_ELASTIC_IP:5601’ after Kibana is started