Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- 생산자 소비자 패턴
- 스레드
- Spring Cloud Netfilx Eureka
- 알고리즘
- 멀티스레드
- Serial GC
- spring cloud
- 디자인 패턴
- Java
- 스프링 배치
- saga pattern
- 키클락
- 타입스크립트
- JPA
- java 정렬
- spring batch
- TypeScript
- Resilinece4j
- Parallel Old GC
- 디자인패턴
- Transaction Pattern
- The law of Demeter
- 배치
- 체인 패턴
- Spring Boot Actuator
- zipkin
- Action Pattern
- MSA
- thread
- 사가 패턴
Archives
- Today
- Total
PSD( Private-Self-Development )
MSA 모니터링 본문
로그 확인용
분산된 MS 들의 로그를
하나의 WEB UI를 통하여 시각화하여 확인 가능 하다.
Micrometer
- Spring boot 2부터 내장 사용 가능
- actuator를 사용하여 metric 확인 가능
- prometheus 등 다양한 모니터링 시스템 지원
metric
시간이 지남에 따라 변화하는 데이터를 의미
메모리, CPU, 스레드 사용률 등등
시간에 따른 추이를 추적할 가치가 있는 데이터
Timer
짧은 지연 시간, 이벤트의 사용 빈토 측정
시계열로 이벤트의 시간, 호출 빈도등을 제공
@Timed 제공
사용
1. 디펜던시 추가
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
2. yml 파일 수정
endpoints:
web:
exposure:
include: info, prometheus, metrics
3. 소스 수정
@GetMapping("health_check")
@Timed(value = "users.status", longTask = true) // value = 이름
public String status() {
return "It's Working in User Service "
+ ", port(local.server.port) = " + env.getProperty("local.server.port")
+ ", port(server.port) = " + env.getProperty("server.port")
+ ", token secret = " + env.getProperty("token.secret")
+ ", token expiration time = " + env.getProperty("token.expiration_time")
;
}
Prometheus
- Metrics 를 수집하고 모니터링 및 알람에 사용
- Time Series DB 사용
- Pull 방식의 구조와 다양한 Metric Exporter 를 제공
- 기본 9090 port 사용
Grafana
- prometheus 에서 수집한 데이터를 시각화하여 대시보드로 제공
- 모니터링 및 분석을 위해 사용
- 기본 3000 port 사용
사용
1. 다운로드 및 서버 구동
./prometheus --config=prometheus.yml
./bin/grafana-server
prometheus.yml
# my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: "prometheus"
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ["localhost:9090"]
- job_name: "user-service"
scrape_interval: 15s # metircs 수집 간격
metrics_path: '/user-service/actuator/prometheus' # 요청 경로
static_configs:
- targets: ['localhost:8000'] # 대상 서버
- job_name: "order-service"
scrape_interval: 15s # metircs 수집 간격
metrics_path: '/order-service/actuator/prometheus' # 요청 경로
static_configs:
- targets: ['localhost:8000'] # 대상 서버
- job_name: "apigateway-service"
scrape_interval: 15s # metircs 수집 간격
metrics_path: '/actuator/prometheus' # 요청 경로
static_configs:
- targets: ['localhost:8000'] # 대상 서버
2. Grafana 서버에서 테마 다운로드 후 적용
3. Grafana 서버에 prometheus 서버 등록
4. prometheus 의 데이터 명과 Grafana 테마에서 사용하는 데이터명 일치 하도록 수정
'Backend > MSA' 카테고리의 다른 글
MSA 간 API 조회 최적화 (0) | 2024.05.12 |
---|---|
사가 패턴(SAGA Pattern) (0) | 2024.05.12 |
MSA 장애 처리 및 분산 추적 (0) | 2024.04.23 |
Kafka( 카프카 ) (0) | 2024.04.22 |
Feign Client (1) | 2024.04.19 |