Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] - Prometheus, Grafana, Loki 설정 추가 #603

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions backend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ dependencies {

// flyway 추가
implementation 'org.flywaydb:flyway-mysql'

// Prometheus
implementation 'io.micrometer:micrometer-registry-prometheus'

// Loki
implementation 'com.github.loki4j:loki-logback-appender:1.5.2'
}

tasks.named('test') {
Expand Down
4 changes: 3 additions & 1 deletion backend/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ management:
enabled: true
metrics:
enabled: true
prometheus:
enabled: true
endpoints:
web:
exposure:
include: info, health, metrics
include: prometheus, info, health, metrics
base-path: ENC(zc5tP1eNIEjv3uN5Kuih7wlo5zILgWxq)
enabled-by-default: false

Expand Down
25 changes: 23 additions & 2 deletions backend/src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<timestamp key="NOW" datePattern="yyyy-MM-dd"/>
<property name="LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level [%file:%line] - %msg%n" />
<property name="CONSOLE_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %green([%thread]) %highlight(%-5level) %boldWhite([%file:%yellow(%line)]) - %msg%n" />
<property name="LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level [%file:%line] - %msg%n"/>
<property name="CONSOLE_PATTERN"
value="%d{yyyy-MM-dd HH:mm:ss.SSS} %green([%thread]) %highlight(%-5level) %boldWhite([%file:%yellow(%line)]) - %msg%n"/>
<springProfile name="local">
<property name="LOKI_URL" value="http://localhost:3100/loki/api/v1/push"/>
</springProfile>
<springProfile name="dev">
<property name="LOKI_URL" value="http://loki:3100/loki/api/v1/push"/>
</springProfile>

Comment on lines +7 to +13
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이후에 prod 만 까먹지 않으면 될 것 같슴다!
저도 기억하고 있을게요 ㅎㅎ

<appender name="LOKI" class="com.github.loki4j.logback.Loki4jAppender">
<http>
<url>${LOKI_URL}</url>
</http>
<format>
<label>
<pattern>app=touroot,host=${HOSTNAME},level=%level</pattern>
<readMarkers>true</readMarkers>
</label>
<message class="com.github.loki4j.logback.JsonLayout"/>
</format>
</appender>

<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
Expand Down Expand Up @@ -72,6 +92,7 @@

<springProfile name="local">
<root level="INFO">
<appender-ref ref="LOKI"/>
<appender-ref ref="CONSOLE"/>
</root>
</springProfile>
Expand Down