Saturday, 17 February 2018

How To Setup Kibana-6 With Elasticsearch-6 On Ubuntu 16.04

Guide To Install Elasticsearch-6 And Kibana-6 


Elasticsearch and kibana are often used together in ELK or EFK setup. To have your kibana dashboard up and running with elasticsearch is very easy. Let's deep dive and setup kibana with elasticsearch. 

Prerequisites:

  • ubuntu-16.04 OS Instance
  • Security group in place

# Video Tutorial


# First Install java

To set JAVA_HOME edit file /etc/environment and add the content shown below in comments

sudo apt-get update
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
java -version
echo $JAVA_HOME
sudo vi /etc/environment
#PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
#JAVA_HOME="/usr/lib/jvm/java-8-oracle"
source /etc/environment
echo $JAVA_HOME

# Install Elasticsearch-6

curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.0.1.tar.gz
echo "deb https://artifacts.elastic.co/packages/6.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-6.x.list
sudo apt-get update && sudo apt-get install elasticsearch
ls /etc/init.d/elasticsearch
sudo service elasticsearch status

# Change bind address and JVM heap option as per requirement

Change network.host to 0.0.0.0 in elasticsearch.yml and set -Xms 4g -Xmx 4g in jvm.options

sudo vi /etc/elasticsearch/elasticsearch.yml
sudo vi /etc/elasticsearch/jvm.options

# Setting read replicas to 0 if you are creating single node cluster

curl -XPUT H 'Content-Type: application/json' 'http://localhost:9200/_all/_settings?preserve_existing=false' -d '{"index.number_of_replicas" : "0"}'

# Install Kibana

sudo apt-get update && sudo apt-get install kibana
sudo service kibana restart

# Install nginx

sudo apt-get -y install nginx

# Add nginx config file for kibana

sudo vi /etc/nginx/conf.d/kibana.conf

Replace mykibana.com with your server_name or IP. We will setup auth in next step, hence we have placed a line for auth_basic in kibana.conf

server {
    listen 80;
    server_name mykibana.com;
    auth_basic "Restricted Access";
    auth_basic_user_file /etc/nginx/htpasswd.users;

    location / {
        proxy_pass http://localhost:5601;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

# Setup auth

After installing apache2-utils when you run htpasswd, it will ask for a password, provide a password. This username and password would be useful when you try to access kibana from browser.

sudo apt-get install apache2-utils
sudo htpasswd -c /etc/nginx/htpasswd.users efkadmin
sudo service nginx restart

# Web view of Kibana

After successful Setup, hit the IP of kibana. Put username and password and you will see kibana web as shown below.


6 comments:

  1. Super awesome tutorial, what if I don't want password security on kibana??

    ReplyDelete
    Replies
    1. Apology for the delay in reply, Below comment will help you to achieve this.

      Delete
  2. Then you don't add:

    auth_basic "Restricted Access";
    auth_basic_user_file /etc/nginx/htpasswd.users;

    In the ngnix config file.

    Nor run these commands;

    sudo apt-get install apache2-utils
    sudo htpasswd -c /etc/nginx/htpasswd.users efkadmin

    ReplyDelete
    Replies
    1. Thanks for helping others. Keep Learning & Keep Sharing

      Delete
  3. Hi, I install elasticsearch as you described here,

    root@ip-172-31-45-55:~# sudo service elasticsearch start
    * Starting Elasticsearch Server [ OK ]
    root@ip-172-31-45-55:~# sudo service elasticsearch status
    * elasticsearch is not running

    Do you have any idea on this?

    ReplyDelete
    Replies
    1. check elasticsearch logs. Probably, the heap size might not be set properly so elasticsearch must be getting stopped due to that.

      Delete

 

Copyright @ 2013 Appychip.

Designed by Appychip & YouTube Channel