From 5fa12a24c1fe2ad5750009ca01c343366b476bfa Mon Sep 17 00:00:00 2001 From: punkryn Date: Mon, 3 Jun 2024 19:28:24 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=EA=B0=80=EC=8B=9C=EC=84=B1=20=ED=99=95?= =?UTF-8?q?=EB=B3=B4=EB=A5=BC=20=EC=9C=84=ED=95=9C=20=EC=9E=91=EC=97=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 11 +- build.gradle | 5 + docker-compose.observe.yml | 154 +++ etc/dashboards.yaml | 10 + etc/dashboards/spring-boot-observability.json | 1063 +++++++++++++++++ etc/grafana/datasource.yml | 77 ++ etc/prometheus/prometheus.yml | 46 + nginx.observe.conf | 38 + .../Tiketeer/auth/RequestMatcherHolder.java | 4 +- .../Tiketeer/configuration/AppConfig.java | 7 + 10 files changed, 1413 insertions(+), 2 deletions(-) create mode 100644 docker-compose.observe.yml create mode 100644 etc/dashboards.yaml create mode 100644 etc/dashboards/spring-boot-observability.json create mode 100644 etc/grafana/datasource.yml create mode 100644 etc/prometheus/prometheus.yml create mode 100644 nginx.observe.conf diff --git a/Dockerfile b/Dockerfile index ae6e17cb..7eace575 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,8 @@ +FROM curlimages/curl:8.2.1 AS download +ARG OTEL_AGENT_VERSION="1.33.2" +RUN curl --silent --fail -L "https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v${OTEL_AGENT_VERSION}/opentelemetry-javaagent.jar" \ + -o "$HOME/opentelemetry-javaagent.jar" + FROM eclipse-temurin:21 AS build COPY gradlew . COPY gradle gradle @@ -10,4 +15,8 @@ RUN ./gradlew bootJar FROM eclipse-temurin:21 COPY --from=build build/libs/*.jar app.jar -ENTRYPOINT ["java", "-jar", "/app.jar"] +COPY --from=download /home/curl_user/opentelemetry-javaagent.jar /opentelemetry-javaagent.jar +ENTRYPOINT ["java", \ + "-javaagent:/opentelemetry-javaagent.jar", \ + "-jar", "/app.jar" \ + ] \ No newline at end of file diff --git a/build.gradle b/build.gradle index 4a697dcd..af2eccbb 100644 --- a/build.gradle +++ b/build.gradle @@ -66,6 +66,11 @@ dependencies { // ETC implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.3.0' + // OBSERVABILITY + implementation 'io.micrometer:micrometer-registry-prometheus:1.11.3' + implementation 'io.opentelemetry:opentelemetry-api' + implementation 'org.springframework.boot:spring-boot-starter-actuator' + // MAIL implementation 'org.springframework.boot:spring-boot-starter-mail' diff --git a/docker-compose.observe.yml b/docker-compose.observe.yml new file mode 100644 index 00000000..5ca120cc --- /dev/null +++ b/docker-compose.observe.yml @@ -0,0 +1,154 @@ +x-logging: &default-logging + driver: loki + options: + loki-url: 'http://loki:3100/loki/api/v1/push' + loki-pipeline-stages: | + - multiline: + firstline: '^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.\d{3}' + max_wait_time: 3s + - regex: + expression: '^(?P\d{4}-\d{2}-\d{2}) (?P