Post

로컬환경에서 모니터링시스템을 구성해 보자

스프링 부트 actuator, prometheus 설정 파일 추가

1
2
3
4
5
6
7
8
9
10
dependencies {
    // Spring Boot Starter Actuator
    implementation 'org.springframework.boot:spring-boot-starter-actuator'
    
    // Spring Boot Starter Web
    implementation 'org.springframework.boot:spring-boot-starter-web'
    
    // Micrometer Prometheus Registry (Runtime Scope)
    runtimeOnly 'io.micrometer:micrometer-registry-prometheus'
}

프로메테우스 설치

  1. brew 를 통한 설치
1
brew install prometheus
  1. prometheus.yml 변경 [ /usr/local/etc/prometheus.yml ]
1
2
3
4
5
6
7
8
9
10
11
global:
  scrape_interval: 15s

rule_files:

scrape_configs:
  - job_name: "application-name"
    metrics_path: '/actuator/prometheus' // spring-boot의 url
    scrape_interval: 3s
    static_configs:
      - targets: [ "localhost:3000" ] // spring-boot
  1. 프로메테우스 접속
  2. http://localhost:9090/

그라파나 설치

  1. brew를 통한 설치
1
brew install grafana
  1. port 변경 [ /usr/local/etc/grafana/grafana.ini ]
  2. spring 프로젝트의 경로와 겹쳐서 변경함 Default : 3000
1
http_port = 4000

http://localhost:4000 접속

  1. DataSource(프로메테우스) 연결
  2. Connection : http://localhost:9090 (프로메테우스 경로)
  3. DashBoard 구성 : 여기 에서 사람들이 미리 만들어 놓은 DashBoard를 불러올 수 있다.

참고

Prometheus - Monitoring system & time series database
grafana labs
Monitoring Made Simple: Empowering Spring Boot Applications with Prometheus and Grafana

This post is licensed under CC BY 4.0 by the author.