Skip to content

Commit 9f400e0

Browse files
authored
[DDING-000] Trace 매트릭 수집위한 Tempo 세팅 및 RDS, mysql 매트릭 수집 (#327)
1 parent 0d5b209 commit 9f400e0

File tree

4 files changed

+137
-3
lines changed

4 files changed

+137
-3
lines changed

Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ RUN ./gradlew clean build -x test --no-daemon
66

77
# Package stage
88
FROM openjdk:17
9+
COPY otel/opentelemetry-javaagent.jar /otel/opentelemetry-javaagent.jar
910
COPY --from=build /home/gradle/src/build/libs/*.jar /app.jar
1011
EXPOSE 8080
11-
ENTRYPOINT ["java","-jar","/app.jar"]
12+
ENTRYPOINT ["java", \
13+
"-javaagent:/otel/opentelemetry-javaagent.jar", \
14+
"-jar", "/app.jar"]

alloy/alloy-docker-compose.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@ services:
88
volumes:
99
- /var/app/current/alloy/config.alloy:/etc/alloy/config.alloy:ro
1010
environment:
11-
- ALLOY_ENV=prod
12-
- SERVER_NAME=prod-server
11+
- ALLOY_ENV=${SPRING_PROFILES_ACTIVE}
12+
- SERVER_NAME=${SERVER_NAME}
13+
- DB_USER=${DB_USERNAME}
14+
- DB_PASSWORD=${DB_PASSWORD}

alloy/config.alloy

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,117 @@ prometheus.relabel "system_labels" {
5050
}
5151
}
5252

53+
// ========== MySQL Exporter (DB 내부 지표) ==========
54+
prometheus.exporter.mysql "rds_mysql" {
55+
data_source_name = sys.env("DB_USER") + ":" + sys.env("DB_PASSWORD") + "@tcp(ddingdong-dev.c8bj0rlp6aer.ap-northeast-2.rds.amazonaws.com:3306)/"
56+
}
57+
58+
// ========== CloudWatch Exporter (RDS 리소스 지표) ==========
59+
prometheus.exporter.cloudwatch "rds_cw" {
60+
sts_region = "ap-northeast-2"
61+
62+
static "rds"{
63+
namespace = "AWS/RDS"
64+
regions = ["ap-northeast-2"]
65+
66+
dimensions = {
67+
DBInstanceIdentifier = "ddingdong-dev",
68+
}
69+
70+
metric {
71+
name = "CPUUtilization"
72+
statistics = ["Average"]
73+
period = "30s"
74+
length = "5m"
75+
}
76+
77+
metric {
78+
name = "FreeableMemory"
79+
statistics = ["Average"]
80+
period = "30s"
81+
length = "5m"
82+
}
83+
84+
metric {
85+
name = "FreeStorageSpace"
86+
statistics = ["Average"]
87+
period = "30s"
88+
length = "5m"
89+
}
90+
91+
metric {
92+
name = "DatabaseConnections"
93+
statistics = ["Average"]
94+
period = "30s"
95+
length = "5m"
96+
}
97+
98+
metric {
99+
name = "ReadIOPS"
100+
statistics = ["Average"]
101+
period = "30s"
102+
length = "5m"
103+
}
104+
105+
metric {
106+
name = "WriteIOPS"
107+
statistics = ["Average"]
108+
period = "30s"
109+
length = "5m"
110+
}
111+
112+
metric {
113+
name = "ReadLatency"
114+
statistics = ["Average"]
115+
period = "30s"
116+
length = "5m"
117+
}
118+
119+
metric {
120+
name = "WriteLatency"
121+
statistics = ["Average"]
122+
period = "30s"
123+
length = "5m"
124+
}
125+
126+
metric {
127+
name = "ReplicaLag"
128+
statistics = ["Average"]
129+
period = "30s"
130+
length = "5m"
131+
}
132+
133+
// ===== 추가된 Throughput 메트릭 =====
134+
metric {
135+
name = "ReadThroughput"
136+
statistics = ["Average"]
137+
period = "30s"
138+
length = "5m"
139+
}
140+
141+
metric {
142+
name = "WriteThroughput"
143+
statistics = ["Average"]
144+
period = "30s"
145+
length = "5m"
146+
}
147+
}
148+
}
149+
150+
prometheus.scrape "mysql_scrape" {
151+
targets = prometheus.exporter.mysql.rds_mysql.targets
152+
scrape_interval = "30s"
153+
scrape_timeout = "10s"
154+
forward_to = [prometheus.remote_write.central.receiver]
155+
}
156+
157+
// CloudWatch 스크래핑
158+
prometheus.scrape "cloudwatch_scrape" {
159+
targets = prometheus.exporter.cloudwatch.rds_cw.targets
160+
scrape_interval = "60s"
161+
scrape_timeout = "30s"
162+
forward_to = [prometheus.remote_write.central.receiver]
163+
}
53164

54165
prometheus.remote_write "central" {
55166
endpoint {
@@ -69,3 +180,21 @@ prometheus.remote_write "central" {
69180
max_keepalive_time = "8h"
70181
}
71182
}
183+
184+
otelcol.receiver.otlp "default" {
185+
grpc {
186+
endpoint = "0.0.0.0:4317"
187+
}
188+
output {
189+
traces = [otelcol.exporter.otlphttp.tempo.input]
190+
}
191+
}
192+
193+
otelcol.exporter.otlphttp "tempo" {
194+
client {
195+
endpoint = "http://3.39.151.102:4317/tempo/otlp"
196+
tls {
197+
insecure = true
198+
}
199+
}
200+
}

otel/opentelemetry-javaagent.jar

20.2 MB
Binary file not shown.

0 commit comments

Comments
 (0)