2025-04-08T19:56:24

This commit is contained in:
2025-04-08 19:56:24 +09:00
parent a75a1dbd0f
commit eef061c1c9
100 changed files with 18639 additions and 0 deletions

View File

@@ -0,0 +1,157 @@
좋아, 이제 **4부. 운영 환경 통합**을 작성해볼게. 이 파트에서는 액추에이터를 실무에서 자주 사용하는 외부 도구들과 연동하는 방법을 다룰게. 특히 Prometheus, Grafana, Spring Boot Admin, 클라우드 환경 중심으로 구성할게.
---
## **4부. 운영 환경 통합**
---
### **16장. Prometheus & Grafana 연동**
#### Micrometer + Prometheus 설정
```kotlin
dependencies {
implementation 'io.micrometer:micrometer-registry-prometheus'
}
```
```yaml
management:
endpoints:
web:
exposure:
include: prometheus
metrics:
export:
prometheus:
enabled: true
```
> 결과: `/actuator/prometheus` 엔드포인트에서 Prometheus 포맷의 메트릭 제공
#### Prometheus 설정 예시 (`prometheus.yml`)
```yaml
scrape_configs:
- job_name: 'spring-app'
metrics_path: '/actuator/prometheus'
static_configs:
- targets: ['localhost:8080']
```
#### Grafana 대시보드 구성
- 데이터 소스: Prometheus
- 대시보드: Micrometer for JVM preset 사용 가능
- JVM 메모리, GC, HTTP 요청 등 실시간 그래프 시각화
---
### **17장. Spring Boot Admin 연동**
#### 의존성 추가
```kotlin
implementation 'de.codecentric:spring-boot-admin-starter-client'
```
#### 클라이언트 애플리케이션 설정
```yaml
spring:
boot:
admin:
client:
url: http://localhost:8081 # Spring Boot Admin 서버 주소
```
> 액추에이터 엔드포인트가 자동 등록되어 UI로 상태, 메트릭, 로그 등 확인 가능
#### 서버 애플리케이션 설정 (별도 프로젝트)
```kotlin
dependencies {
implementation 'de.codecentric:spring-boot-admin-starter-server'
implementation 'spring-boot-starter-security'
}
```
```java
@EnableAdminServer
@SpringBootApplication
public class AdminServerApp {
public static void main(String[] args) {
SpringApplication.run(AdminServerApp.class, args);
}
}
```
---
### **18장. 클라우드 환경에서의 액추에이터 활용**
#### Kubernetes 헬스체크에 활용
```yaml
livenessProbe:
httpGet:
path: /actuator/health/liveness
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
readinessProbe:
httpGet:
path: /actuator/health/readiness
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
```
> `liveness`/`readiness` 구성은 아래처럼 사용자 정의 가능
```java
@Component("readiness")
public class ReadinessHealthIndicator implements HealthIndicator {
@Override
public Health health() {
// DB 연결 확인, 외부 API 체크 등
return Health.up().build();
}
}
```
#### AWS CloudWatch 또는 Azure Monitor 연동
- Micrometer에서 제공하는 별도 레지스트리 사용
- AWS 예시: `micrometer-registry-cloudwatch2` 사용
- Azure 예시: `micrometer-registry-azure-monitor`
---
### **19장. Docker + 액추에이터**
#### Dockerfile 예시
```dockerfile
FROM openjdk:17
COPY build/libs/app.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "app.jar"]
```
#### Docker + Prometheus 연동
- 동일 네트워크에서 Prometheus가 액추에이터 엔드포인트를 스크래핑하도록 구성
- 컨테이너 내에서 보안 설정이나 포트 노출 주의
---
### **요약**
- 액추에이터는 Prometheus, Grafana, Spring Boot Admin 등 외부 도구와 쉽게 통합됨
- Kubernetes 등 클라우드 환경에서 liveness/readiness probe로 활용 가능
- 실시간 모니터링, 장애 탐지, 자원 사용량 분석에 필수적인 구성 요소임
---
이제 마지막 **5부. 실전 활용과 사례 연구**로 이어지면 완성형 실무서 느낌이 날 거야. 계속 써줄까?