Skip to content

keuss/springboot-log-elastic

Repository files navigation

springboot-log-elastic

POC with SpringBoot (2.5.0) simple API App with Elastic stack (7.13.0) / logstash -> elasticsearch -> kibana (everything in docker)

Run

  • git clone https://github.com/keuss/springboot-log-elastic
  • mvn clean package
  • docker-compose build (from docker-elk folder with the docker-compose.yml file)
  • docker-compose up (from docker-elk folder with the docker-compose.yml file)
  • To shutdown the stack and remove all persisted data docker-compose down -v (from docker-elk folder with the docker-compose.yml file)

Stack

  • Logback with LogstashEncoder
  • Elastic with docker with xpack.license basic
  • Logstash with GELF log driver (UDP protocol and port 5000 to send messages from Docker services)
  • Add Index Pattern (from Home/Manage) : Index "logback-*" and time filter field name @timestamp (must have some data first for this index !)

alt tag

  • Filter by tag (bookapi_app_1 or bookapi_app_2)

alt tag

  • Dashboard example with custom tag

alt tag

Search Query examples

  • tag : bookapi_app_2 AND logcontent.level : ERROR

URLs

  • API Swagger to add data (create some books) : app1 / app2
  • Kibana : http://localhost:5601/ (elastic/changeme), add sample data first, then create logback-* index

Links

Logback

Send the Logs of a Java App to the Elastic Stack

Gelf

Other Docker logging driver

Docker Port Binding

Disable compose v2