Download as rtf, pdf, or txt
Download as rtf, pdf, or txt
You are on page 1of 4

LAB- ELK Integration

Step 1 – Starting ELK

Elasticsearch
 Download latest version of Elasticsearch from this download page and unzip it any folder.
 Run bin\elasticsearch.bat from command prompt.
 By default, it would start at http://localhost:9200

Kibana
 Download the latest distribution from download page and unzip into any folder.
 Open config/kibana.yml in an editor and set elasticsearch.url to point at your
Elasticsearch instance. In our case as we will use the local instance just uncomment
elasticsearch.url: "http://localhost:9200"
 Run bin\kibana.bat from command prompt.
 Once started successfully, Kibana will start on default port 5601 and Kibana UI will be available at
http://localhost:5601
Logstash
 Download the latest distribution from download page and unzip into any folder.
 Create one file logstash.conf with following content in bin director

input

{ tcp {

port => 5000 codec => "json"

output {

elasticsearch {

hosts=> ["localhost"]

index => "micro-%{serviceName}"

Now run bin/logstash -f logstash.conf to start logstash

Step 2 – Emitting logs from our application to logstash and


visualising using elasticsearch and kibana
In this step, you will be working on projects 10-elk working set

1) In 10-01-cargo-booking-elk-solution, open pom.xml and observe that we have added


following logback dependencies :
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>4.9</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.2.3</version>
</dependency>

2) Open logback.xml and observe how we have configured


LogstashTcpSocketAppender.

Observe how we have configured destination of logstash input.

3) Now start eureka 04-01-eureka-server. Then start 10-01-cargo-booking-elk-solution

Open eureka console at http://localhost:5001 and make sure that all the services are
registered

Open swagger web ui at http://localhost:8081/swagger-ui.html

Under Cargo Booking Commands in Swagger ui, make a post request to /cargobooking
using the below json to create a booking.

{
"bookingAmount": 100,
"originLocation": "BLR",
"destLocation" : "DEL",
"destArrivalDeadline" : "2020-01-28"
}

Now Some logs might have been generated. We want to view them in kibana.

Goto http://localhost:5601 and Discover the logs.

You might also like