Skip to content

How to setup ELK Stack with Spring Boot?

Pavan K Jadda edited this page Feb 6, 2019 · 5 revisions
  1. Download Elastic Search and unzip it
  2. Start Elastic search with the following command and go to URL http://localhost:9200
$ bin/elasticsearch
  1. Download LogStash and unzip it
  2. Create logstash-elk.conf file on logstash home directory with the following content and change the log file location and index name based on your settings
input {
    file {
        path => "/Users/pjadda/ELK-Stack/logback/*.log"
        codec => "json"
        type => "logback"
    }
}
 
output {
    if [type]=="logback" {
         elasticsearch {
             hosts => [ "localhost:9200" ]
             index => "logstash"
        }
    }
}

  1. Start the logstash with the command
$ bin/logstash -f logstash-elk.conf
  1. Download Kibana then unzip it, run it with the following command
bin/kibana
  1. Go to http://localhost:5601 to see Kibana UI
  2. Go to Spring Boot application.yml file and add logging file location oproperties
# Logging
logging:
  file: /Users/pjadda/ELK-Stack/logback/springsecuritydata.log
  1. Restart the Spring Boot application to capture logs in the newly created file springsecuritydata.log
  2. Go to Kibana UI -> Management -> Create Index pattern -> Type index name (You should see the index name below)
  3. Go to Kibana UI -> Dashboard to see Spring Boot log data, modify the filter to see data from past
Clone this wiki locally