Skip to content

Commit

Permalink
[Feature] - Prometheus, Grafana, Loki 설정 추가 (#603)
Browse files Browse the repository at this point in the history
  • Loading branch information
hangillee authored Nov 26, 2024
1 parent a0eafdb commit ff30ab1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
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>

<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

0 comments on commit ff30ab1

Please sign in to comment.