ELK - adityaskarnik/expense_app GitHub Wiki

Elasticsearch Kibana

Creation of Kibana, Elasticsearch

Use this docker-compose file

Run command:

sudo docker swarm init

if you get any address error run:

sudo docker swarm init --advertise-addr 192.168.2.23:2377

Then run:

sudo docker-compose up -d

Once this is done your dockers containers will be running, check those with command:

sudo docker ps -a

You can check this on browser http://0.0.0.0:5601/

Pushing data to Elasticsearch:

Initialise Elasticsearch

from elasticsearch import Elasticsearch`

index= 'index_name'

doc_type = 'sample_document_one'

es= Elasticsearch('elastic:yourpassword@elasticsearch:9200/'))

Inserting data

data_dict = {} # blank dictionary to insert data`

data_dict['email'] = email

data_dict['username'] = username

es.index(index = index, doc_type = doc_type, body = data_dict)

To view the data getting inserted to Kibana go to http://0.0.0.0:5601/app/kibana#/discover