wang-qijia / Spring-Boot-Demo-Observability-with-Open-Telemetry

A minimum setup demo for activating the Observability using Open-Telemetry/Grafana and Spring Boot.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

  1. clone https://github.com/Johnny850807/Spring-Boot-Demo-Observability-with-Open-Telemetry.git cd Spring-Boot-Demo-Observability-with-Open-Telemetry

  2. Install docker's loki plugin docker plugin install grafana/loki-docker-driver:latest --alias loki --grant-all-permissions

  3. Build

./mvnw package -DskipTests docker-compose build

  1. Run:

docker-compose -f infra.yml up -d docker-compose up -d

  1. Navigate Grafana

Then go to the Grafana's dashboard: http://localhost:3000/

Go to the Explore page and select the loki data source, type in the query label {compose_service="user-service"} then click the "Run Query" button, and then you will see the live messages produced by the spring boot application. (Repeat on clicking the "Run Query" button to refresh the messages.)

  1. Issue a sign-up request:

After the spring boot application has been started, issue a sign-up request by curl -X POST -H 'Content-Type: application/json' -d '{"name": "test", "email":"johnny@gmail.com", "password":"password"}' http://localhost:8080/api/users/signUp

  1. Log -> Trace:

After the request has succeeded, you should see a log message produced by the sign-up request. Something like: 2021-05-05 14:47:43 2021-05-05 06:47:43 - com.example.demo.UserController - SignUp: User{id=null, name='test', email='johnny@gmail.com', password='********'} traceID=81c01158ca964468a4c0b5817863d672

After you found the message, click on the message, grafana will expand it and show the fields of the message. You can find a blue Tempo button on the TraceID field. Click it, and then the distributed tracing panel will show up at the right-hand side.

About

A minimum setup demo for activating the Observability using Open-Telemetry/Grafana and Spring Boot.


Languages

Language:Java 95.4%Language:Dockerfile 4.6%