Showing posts with label Centralized Logging. Show all posts
Showing posts with label Centralized Logging. Show all posts

Friday, June 13, 2014

I have mentioned about centralized logging system with an example of Logstash in previous post:
centralized logging with Logstash.

It's greate if you do not want to do any programming work since Logstash provides you lots of flexibility. However, there are quite some limitations if you use logstash for a long time:

  • System log for logstash is not sufficient if error happens
  • Too complicated system, any error in any part could result in data failure
  • With large input of stream say 2000 per input, logstash could crash without any notifications.
While I explore through the streaming solutions across the internet, Flume becomes a potential better solutions.The idea of Flume is more or less the same as Logstash, except itself provides a reliable queue system. Supported by Apache, Flume seems to be more reliable, and it dose not have to be very complicated system. The following tutorial is an introduction to use flume as centralized logging system, based on ubuntu system.

Flume Installation


Install flume-1.5.0 latest version under /opt/flume:
cd ~
sudo apt-get update
sudo apt-get install openjdk-7-jre-headless -y
sudo wget http://mirror.nus.edu.sg/apache/flume/1.5.0/apache-flume-1.5.0-bin.tar.gz
tar -zvxf apache-flume-1.5.0-bin.tar.gz
sudo mv apache-flume-1.5.0-bin /opt/flume
If you want to use elasticsearch sink, you will have to install lucence library. Suppose you are using elasticsearch 1.2.1 with lucence 4.8
sudo wget https://dl.dropboxusercontent.com/s/h491nkeajc67pk7/lucene%204.8.zip
unzip lucene\ 4.8.zip
cd lucene\ 4.8/
sudo mv * /opt/flume/lib
If you want to try out flume, please follow the tutorial: http://flume.apache.org/FlumeUserGuide.html#a-simple-example usually in order to run flume in a normal environment, you will have to configure flume-env.sh:
cd /opt/flume/conf
cp flume-env.sh.template flume-env.sh
#edit flume-env.sh to put your JAVA_HOME and a reasonable JAVA_OPTS(this is important, if you have a large streaming data per sec)

Elasticsearch Installation

Please follow my blog:http://jakege.blogspot.sg/2014/03/how-to-install-elasticsearch.html

Kibana Installation

Kibana you will just have to download from official site:http://www.elasticsearch.org/overview/kibana/, because it's simply a local website. All you have to do is to edit config.js to connect to the right elasticsearch servers and open index.html.

Centralized Logging System with Flume

Usually for centralized logging we use the consolidate flume standard setup:
Here we need two kinds of flume agent: shipping agent and collecting agent.

Shipping agent

For shipping agent, the agent will listen on log file and ship to arvo port of collection agent, the set-up is like:
################################################
# Name the components on this agent
################################################
 
agent1.sources = source1
agent1.sinks = sink1 sink2
agent1.channels = channel1
 
################################################
# Describe Source
################################################
 
# Source Tail
agent1.sources.source1.type = exec
agent1.sources.source1.command = tail -F /var/log/nginx/nginx_access.log
 
################################################
# Describe Interceptors
################################################
 
agent1.sources.source1.interceptors = interceptor1 interceptor2
#add from host
agent1.sources.source1.interceptors.interceptor1.type = host
agent1.sources.source1.interceptors.interceptor1.hostHeader = host
#add timestamp
agent1.sources.source1.interceptors.interceptor2.type = timestamp
 
################################################
# Describe Sink
################################################
 
#Avro Sink, usually will have two collection point for load_balance and HA
agent1.sinks.sink1.type = avro 
agent1.sinks.sink1.hostname = 192.168.0.1
agent1.sinks.sink1.port = 5000
 
agent1.sinks.sink2.type = avro
agent1.sinks.sink2.hostname = 192.168.0.1
agent1.sinks.sink2.port = 5000
 
 
################################################
# Describe Sink Group
################################################
 
# Sink Group
agent1.sinkgroups = load_group1
agent1.sinkgroups.load_group1.sinks = sink1 sink2
agent1.sinkgroups.load_group1.processor.type = load_balance
agent1.sinkgroups.load_group1.processor.backoff = true
agent1.sinkgroups.load_group1.processor.selector = round_robin
 
################################################
# Describe Channel
################################################
 
# Channel Memory
agent1.channels.channel1.type = memory
agent1.channels.channel1.capacity = 100000
agent1.channels.channel1.transactionCapacity = 300
 
################################################
# Bind the source and sink to the channel
################################################
 
agent1.sources.source1.channels = channel1
agent1.sinks.sink1.channel = channel1
agent1.sinks.sink2.channel = channel1

Collecting agent

For collection agent, the agent will take the input from arvo port and put it into elasticsearch, the set-up is like:
################################################
# Name the components on this agent
################################################
 
agent2.sources = source1
agent2.sinks = sink1
agent2.channels = channel1
 
################################################
# Describe Source
################################################
 
# Source Avro
agent2.sources.source1.type = avro
agent2.sources.source1.bind = 0.0.0.0 
agent2.sources.source1.port = 5000
 
################################################
# Describe Interceptors
################################################
# an example of nginx access log regex match
agent2.sources.source1.interceptors = interceptor1
agent2.sources.source1.interceptors.interceptor1.type = regex_extractor
agent2.sources.source1.interceptors.interceptor1.regex = ^(.*) ([a-zA-Z\\.\\@\\-\\+_%]+) ([a-zA-Z\\.\\@\\-\\+_%]+) \\[(.*)\\] \\"(POST|GET) ([A-Za-z0-9\\$\\.\\+\\@#%_\\/\\-]*)\\??(.*) (.*)\\" ([a-zA-Z0-9\\.\\/\\s\-]*) (.*) ([0-9]+) ([0-9]+) ([0-9\\.]+)
agent2.sources.source1.interceptors.interceptor1.serializers = s1 s2 s3 s4 s5 s6 s7 s8 s9 s10 s11 s12 s13
agent2.sources.source1.interceptors.interceptor1.serializers.s1.name = clientip
agent2.sources.source1.interceptors.interceptor1.serializers.s2.name = ident
agent2.sources.source1.interceptors.interceptor1.serializers.s3.name = auth
agent2.sources.source1.interceptors.interceptor1.serializers.s4.name = logtime
agent2.sources.source1.interceptors.interceptor1.serializers.s5.name = method
agent2.sources.source1.interceptors.interceptor1.serializers.s6.name = request
agent2.sources.source1.interceptors.interceptor1.serializers.s7.name = param
agent2.sources.source1.interceptors.interceptor1.serializers.s8.name = httpversion
agent2.sources.source1.interceptors.interceptor1.serializers.s9.name = referrer
agent2.sources.source1.interceptors.interceptor1.serializers.s10.name = agent
agent2.sources.source1.interceptors.interceptor1.serializers.s11.name = response
agent2.sources.source1.interceptors.interceptor1.serializers.s12.name = bytes
agent2.sources.source1.interceptors.interceptor1.serializers.s13.name = requesttime
 
 
################################################
# Describe Sink
################################################
 
# Sink ElasticSearch
# Elasticsearch lib ---> flume/lib
# elasticsearch/config/elasticsearch.yml cluster.name clusterName. data/clustername data.
agent2.sinks.sink1.type = org.apache.flume.sink.elasticsearch.ElasticSearchSink
agent2.sinks.sink1.hostNames = 192.168.1.1:9300,192.168.1.2:9300
agent2.sinks.sink1.indexName = nginx
agent2.sinks.sink1.indexType = nginx_access
agent2.sinks.sink1.clusterName = elasticsearch
agent2.sinks.sink1.batchSize = 1000
agent2.sinks.sink1.ttl = 2
#this serializer is crucial in order to use kibana
agent2.sinks.sink1.serializer = org.apache.flume.sink.elasticsearch.ElasticSearchLogStashEventSerializer
 
 
 
################################################
# Describe Channel
################################################
 
# Channel Memory
agent2.channels.channel1.type = memory
agent2.channels.channel1.capacity = 10000000
agent2.channels.channel1.transactionCapacity = 1000
 
################################################
# Bind the source and sink to the channel
################################################
 
agent2.sources.source1.channels = channel1
agent2.sinks.sink1.channel = channel1

Start-up script

if you need an start-up service script: assume your agent is agent1 and config file is flume.conf in /opt/flume. please change it respectively
#!/bin/sh

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Starts a Flume agent
#
# chkconfig: 345 90 10
# description: Flume agent
#
### BEGIN INIT INFO
# Provides:          flume-ng-agent
# Required-Start:    $remote_fs
# Should-Start:
# Required-Stop:     $remote_fs
# Should-Stop:
# Default-Start:     3 4 5
# Default-Stop:      0 1 2 6
# Short-Description: Flume agent
### END INIT INFO
 
. /lib/lsb/init-functions
 
# Name of the agnet
FLUME_AGENT_NAME=agent1

# Setting up a few defaults that can be later overrideen in /etc/default/flume-ng-agent
FLUME_LOG_DIR=/opt/flume/logs
FLUME_CONF_DIR=/opt/flume/conf
FLUME_RUN_DIR=/var/run/flume
FLUME_HOME=./bin/flume-ng
FLUME_USER=mozat
 
# Autodetect JAVA_HOME if not defined
if [ -e /usr/libexec/bigtop-detect-javahome ]; then
  . /usr/libexec/bigtop-detect-javahome
elif [ -e /usr/lib/bigtop-utils/bigtop-detect-javahome ]; then
  . /usr/lib/bigtop-utils/bigtop-detect-javahome
fi
 
STATUS_RUNNING=0
STATUS_DEAD=1
STATUS_DEAD_AND_LOCK=2
STATUS_NOT_RUNNING=3
 
ERROR_PROGRAM_NOT_INSTALLED=5
 
FLUME_LOCK_DIR="/var/lock/subsys/"
LOCKFILE="${FLUME_LOCK_DIR}/flume-ng-agent"
desc="Flume agent daemon"
 
FLUME_CONF_FILE=${FLUME_CONF_FILE:-${FLUME_CONF_DIR}/flume.conf}
EXEC_PATH=/opt/flume/bin/flume-ng
FLUME_PID_FILE=${FLUME_RUN_DIR}/flume.pid
 
# These directories may be tmpfs and may or may not exist
# depending on the OS (ex: /var/lock/subsys does not exist on debian/ubuntu)
for dir in "$FLUME_RUN_DIR" "$FLUME_LOCK_DIR"; do
  [ -d "${dir}" ] || install -d -m 0755 -o $FLUME_USER -g $FLUME_USER ${dir}
done
 
FLUME_SHUTDOWN_TIMEOUT=${FLUME_SHUTDOWN_TIMEOUT:-60}
 
start() {
  [ -x $exec ] || exit $ERROR_PROGRAM_NOT_INSTALLED
 
  checkstatus
  status=$?
  if [ "$status" -eq "$STATUS_RUNNING" ]; then
    exit 0
  fi
 
  log_success_msg "Starting $desc (flume-ng-agent): "
  /bin/su -s /bin/bash -c "cd /opt/flume;/bin/bash -c 'echo \$\$ > ${FLUME_PID_FILE} && exec ${EXEC_PATH} agent -n $FLUME_AGENT_NAME -c conf -f $FLUME_CONF_FILE -Dflume.monitoring.type=http -Dflume.monitoring.port=30001 >>${FLUME_LOG_DIR}/flume.${FLUME_AGENT_NAME}.init.log 2>&1 ' &" $FLUME_USER
  RETVAL=$?
  [ $RETVAL -eq 0 ] && touch $LOCKFILE
  return $RETVAL
}
 
stop() {
  if [ ! -e $FLUME_PID_FILE ]; then
    log_failure_msg "Flume agent is not running"
    exit 0
  fi
 
  log_success_msg "Stopping $desc (flume-ng-agent): "
 
  FLUME_PID=`cat $FLUME_PID_FILE`
  if [ -n $FLUME_PID ]; then
    log_success_msg "kill process ${FLUME_PID}"
    kill -TERM ${FLUME_PID} &>/dev/null
#    for i in `seq 1 ${FLUME_SHUTDOWN_TIMEOUT}` ; do
#      kill -0 ${FLUME_PID} &>/dev/null || break
#      sleep 1
#    done
    kill -KILL ${FLUME_PID} &>/dev/null
  fi
  rm -f $LOCKFILE $FLUME_PID_FILE
  return 0
}
 
restart() {
  stop
  start
}
 
checkstatus(){
  pidofproc -p $FLUME_PID_FILE java > /dev/null
  status=$?
 
  case "$status" in
    $STATUS_RUNNING)
      log_success_msg "Flume agent is running"
      ;;
    $STATUS_DEAD)
      log_failure_msg "Flume agent is dead and pid file exists"
      ;;
    $STATUS_DEAD_AND_LOCK)
      log_failure_msg "Flume agent is dead and lock file exists"
      ;;
    $STATUS_NOT_RUNNING)
      log_failure_msg "Flume agent is not running"
      ;;
    *)
      log_failure_msg "Flume agent status is unknown"
      ;;
  esac
  return $status
}
 
condrestart(){
  [ -e ${LOCKFILE} ] && restart || :
}
 
case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
  status)
    checkstatus
    ;;
  restart)
    restart
    ;;
  condrestart|try-restart)
    condrestart
    ;;
  *)
    echo $"Usage: $0 {start|stop|status|restart|try-restart|condrestart}"
    exit 1
esac
 
exit $RETVAL

Index template

For logs, in order to manage it better and fits better in Kibana, we better define a index template, for example for our nginx log:
{
    "template": "nginx-*",
    "settings" : {
        "number_of_shards" : 5,
        "number_of_replicas" : 1,
        "index.cache.field.type" : "soft",
        "index.refresh_interval" : "5s",
        "index" : {
            "query" : { "default_field" : "@message" },
            "store" : { "compress" : { "stored" : true, "tv": true } }
        }
    },
    "mappings": {
        "_default_": {
            "_all": { "enabled": false },
            "_source": { "compress": true },
            "_ttl": { "enabled": true, "default": "2d" },
             "properties" : {
                "@timestamp": { "type": "date", "index": "not_analyzed" },
                "@message": { "type" : "string", "index" : "analyzed" },
  "@source_host": { "type": "string", "index": "not_analyzed" },
  "@fields" : {
   "type": "object",
         "properties": {
           "agent" : { "type" : "string", "index" : "analyzed" },
                  "request" : { "type" : "string", "index" : "not_analyzed" },
                  "host" : { "type" : "string", "index" : "not_analyzed" },
                  "clientip" : { "type" : "string", "index" : "not_analyzed" },
                  "file" : { "type" : "string", "index" : "not_analyzed" },
                  "bytes": { "type": "integer"},
                  "offset": {"type": "integer"},
                  "requesttime": {"type": "float"},
    "logtime": { "type" : "string", "index" : "not_analyzed" }
         }
  }
     }
        }
    }
}

Elasticsearch Curator

To manage our index, delete and close outdated index and optimize it. We use elasticsearch curator, installation for 1.0:
pip install elasticsearch-curator
To close index older than 1 day and delete 4 days with "-" as separator(flume uses - as index date separator like: nginx-2014-06-13), we put this in cron job:
20 12 * * * /usr/local/bin/curator --host 192.168.1.1 -s - --prefix nginx- -d 4 -c 1 -s -

Cloudera management tool for flume

To manage flume, you can use cloudera management tool. Finally, you will be able to see the results with customized kibana setting:

Friday, April 25, 2014

Why you need centralised logging system

When you encountered a large system serving millions of users, things can not be done using only one single server. It could be a distributed system which can scale up vertically, or it could be a no-state service like PHP websites or Apis using a list of servers. The problem is how are you going to store the logs. A centralised logging system comes handy as it can solve the following constants your system might be encountered:
  1. Out of disk space to save logs
  2. Too many servers to trace a single log
  3. To analyse the logs
  4. Provide a way for many other service or group of people to check their invoking of your service.

A list of Centralised logging system

You may want to keep your logging system separated from the online service, because anything happens in the offline centralised logging system, you don't really want any influence on the online service. Searching through the available complete solution, you might be able to find the following potential good solutions:
  • Logstash+Elasticsearch+Kibana
  • Flume+Elasticsearch+Kibana or Flume+HDFS+HIVE+PIG
  • Greylog2
  • Fluentd+MongoDB
I'm not here to compare the pros and cons. Here I am going to give a introduction of Logstash+Elasticsearch+Kibana solution.

Official Site:


Simple configuration

The simplest configuration is as below, directly dumping the log files to Elasticsearch(ES), and you can use kibana to check the service.


Complex configuration

When you considering the size of your system, usually it's not enough just to have such configuration above. Instead, you may need more complex version:

Extra added:
Logstash-forwarder: a light-weighted logstash log shipping module to reduce the memory consumption of logstash.
RabbitMQ: a queue service to act as a buffer in between, official suggestion is Redis, however, I believe RabbitMQ is better, as you can do a lot of other things here, like monitoring the logstash service(just by checking the status of the queue and tcp connections)

Installation and configuration:

Install logstash

#install logstash
sudo wget https://download.elasticsearch.org/logstash/logstash/logstash-1.3.3-flatjar.jar
sudo mkdir /opt/logstash
sudo mv logstash-1.3.2-flatjar.jar /opt/logstash/logstash.jar
sudo wget http://logstash.net/docs/1.3.2/tutorials/10-minute-walkthrough/hello.conf
sudo wget http://logstash.net/docs/1.3.2/tutorials/10-minute-walkthrough/hello-search.conf
sudo mv hello.conf /opt/logstash/hello.conf
sudo mv hello-search.conf /opt/logstash/hello-search.conf
cd /opt/logstash/
#example configuration
java -jar logstash.jar agent -f hello.conf
java -jar logstash.jar agent -f hello-search.conf

Install Logstash-forwarder

Logstash-forwarder can provide a faster and more secure log collection
make deb package
#Install Lumberjack
wget https://go.googlecode.com/files/go1.2.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.2.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin

apt-get install rubygems
gem install fpm
export PATH=$PATH:/var/lib/gems/1.8/bin
git clone https://github.com/jordansissel/lumberjack.git
cd lumberjack
make
make deb
I have the deb file made, you can use it to install:
#use the deb file to install
wget https://dl.dropboxusercontent.com/s/7s7fplenhx768ii/logstash-forwarder_0.3.1_amd64.deb
sudo dpkg -i logstash-forwarder_0.3.1_amd64.deb

Configure Logstash

for both logstash producer and consumer, you will have to make your own configuration, below is the example of collecting nginx access log
sudo mkdir /etc/logstash
sudo vim /etc/logstash/logstash.conf
#logstash producer conf
input {
   lumberjack {
    # The port to listen on
    port => 5000

    # The paths to your ssl cert and key
    ssl_certificate => "/etc/logstash/logstash.crt"
    ssl_key => "/etc/logstash/logstash.key"

    # Set this to whatever you want.
    type => "nginx-accesslog"
  } 
}

filter {
  grok {
    match => ["message","%{IPORHOST:clientip} - (?:%{USER:ident}|-) [%{HTTPDATE:timestamp}] \"(?:%{WORD:verb} %{NOTSPACE:request}(?: HTTP/%{NUMBER:httpversion})?|%{DATA:rawrequest})\" %{QS:referrer} %{QS:agent} %{NUMBER:response} (?:%{NUMBER:bytes}|-) (?:%{NUMBER:requesttime}|-)"]
  }
}

output {
  rabbitmq {
    exchange => "slog1"
    host => "192.168.xxx.xxx"
    exchange_type => "topic" # We use topic here to enable pub/sub with routing keys
    key => "slog1"
  }
}

#logstash consumer conf
input {
  rabbitmq {
    queue => "xx"
    host => "192.168.xxx.xxx"
    durable => true
    key => "xx"
    #ack => false
    exchange => "xx" # This matches the exchange declared above
    auto_delete => false
    exclusive => false
  }
}

output {
  # Print each event to stdout.
  stdout {
    # Enabling 'rubydebug' codec on the stdout output will make logstash
    # pretty-print the entire event as something similar to a JSON representation.
    codec => rubydebug
  }

  # You can have multiple outputs. All events generally to all outputs.
  # Output events to elasticsearch
  elasticsearch {
    # Setting 'embedded' will run  a real elasticsearch server inside logstash.
    # This option below saves you from having to run a separate process just
    # for ElasticSearch, so you can get started quicker!
    cluster => "elasticsearch"
  }
}

now you also may need a logstash service wrapper to start or stop the service
cd /etc/init.d
sudo vim logstash
#logstash service wrapper
#! /bin/sh
 
### BEGIN INIT INFO
# Provides:          logstash
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.
### END INIT INFO
 
. /lib/lsb/init-functions
 
name="logstash"
logstash_bin="/usr/bin/java -- -jar /opt/logstash/logstash.jar"
logstash_conf="/etc/logstash/logstash.conf"
logstash_log="/var/log/logstash.log"
pid_file="/var/run/$name.pid"
 
start () {
        command="${logstash_bin} agent -f $logstash_conf --log ${logstash_log}"
 
        log_daemon_msg "Starting $name" "$name"
        if start-stop-daemon --start --quiet --oknodo --pidfile "$pid_file" -b -m --exec $command; then
                log_end_msg 0
        else
                log_end_msg 1
        fi
}
 
stop () {
        log_daemon_msg "Stopping $name" "$name"
        start-stop-daemon --stop --quiet --oknodo --pidfile "$pid_file"
}
 
status () {
        status_of_proc -p $pid_file "" "$name"
}
 
case $1 in
        start)
                if status; then exit 0; fi
                start
                ;;
        stop)
                stop
                ;;
        reload)
                stop
                start
                ;;
        restart)
                stop
                start
                ;;
        status)
                status && exit 0 || exit $?
                ;;
        *)
                echo "Usage: $0 {start|stop|restart|reload|status}"
                exit 1
                ;;
esac
 
exit 0

sudo chmod 777 logstash

Configure logstash forwarder

sudo vim /etc/logstash-forwarder
#change the configuration file
{
  "network": {
    "servers": [ "localhost:5000"],
    "ssl ca": "/etc/logstash/logstash.crt",
    "timeout": 15
  },

  "files": [
    {
      "paths": [
        "/var/log/nginx/shabikplus.access_log"
      ],
      "fields": { "host": "192.168.xxx.xxxx" }
    }
  ]
}
#generate the openssl key and certificate for security reasons
sudo openssl req -x509 -batch -nodes -newkey rsa:2048 -keyout /etc/logstash/logstash.key -out /etc/logstash/logstash.crt

install elasticsearch

refer to my another post: http://jakege.blogspot.sg/2014/03/how-to-install-elasticsearch.html

Configure elastic search

you can use a es template to manage your index
#template:
{
    "template": "logstash-*",
    "settings" : {
        "number_of_shards" : 5,
        "number_of_replicas" : 0,
        "index.cache.field.type" : "soft",
        "index.refresh_interval" : "5s",
        "index" : {
            "query" : { "default_field" : "message" },
            "store" : { "compress" : { "stored" : true, "tv": true } }
        }
    },
    "mappings": {
        "_default_": {
            "_all": { "enabled": false },
            "_source": { "compress": true },
            "_ttl": { "enabled": true, "default": "4w" },
            "dynamic_templates": [
                {
                    "string_template" : {
                        "match" : "*",
                        "mapping": { "type": "string", "index": "not_analyzed" },
                        "match_mapping_type" : "string"
                     }
                 }
             ],
             "properties" : {
                "fields": { "type": "object", "dynamic": true, "path": "full" },
                "message": { "type" : "string", "index" : "not_analyzed" },
                "agent" : { "type" : "string", "index" : "analyzed" },
                "request" : { "type" : "string", "index" : "analyzed" },
                "host" : { "type" : "string", "index" : "not_analyzed" },
                "clientip" : { "type" : "string", "index" : "not_analyzed" },
                "file" : { "type" : "string", "index" : "not_analyzed" },
                "bytes": { "type": "integer"},
                "offset": {"type": "integer"},
                "requesttime": {"type": "float"},
                "@timestamp": { "type": "date", "index": "not_analyzed" },
                "timestamp": {"type":"string", "index": "not_analyzed"},
                "type": { "type": "string", "index": "not_analyzed" }
            }
        }
    }
}

Manage Elasticsearch Index

usually we manage our index using elastic search curator:https://github.com/elasticsearch/curator. You can schedule your optimisation, close and delete operations using the tool

Install Kibana

Kibana is just an offline website, you can extract it and open index.html in the brower
wget https://download.elasticsearch.org/kibana/kibana/kibana-3.0.0milestone4.tar.gz
tar xzvf kibana-3.0.0milestone4.tar.gz

screen shot of the final solution: