Skip to content

stir084/spring-grafana-prometheus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

spring-grafana-prometheus

grafana-prometheus sample for windows 10
백엔드 서버에서 Actuator로 Metrics를 만들면 프로메테우스가 수집하고 grafana가 시각화 해주는 개념이다.

설치

https://grafana.com/grafana/download?platform=windows
https://prometheus.io/download/

Prometheus 설정

promethous.yml 파일에 아래 내용 추가

scrape_configs:
  - job_name: 'spring--app'
    metrics_path: '/actuator/prometheus'
    static_configs:
      - targets: ['host.docker.internal:8080']

Prometheus 실행

설치 폴더 prometheus-2.46.0.windows-amd64 밑에 prometheus.exe 실행
localhost:9090으로 접속 가능

grafana 실행

powershell 에서 C:\Program Files\GrafanaLabs\grafana\bin> .\grafana-server.exe
localhost:3000으로 접속 가능
초기비번은 admin admin

백엔드 설정

implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'io.micrometer:micrometer-registry-prometheus'
management.endpoints.web.exposure.include=*
server.tomcat.mbeanregistry.enabled=true
management.endpoint.health.show-details=always

management.prometheus.metrics.export.enabled=true
management.metrics.export.prometheus.path=/prometheus

3개의 서버가 잘 붙었는지 확인하기

backend <-> prometheus

http://localhost:8080/actuator/prometheus 으로 접속이 되면 prometheous 로그가 잘 보인다.
localhost:9090에 들어가서 status -> target으로 들어가서 Prometheus 서버와 백엔드 서버가 연결되어 있는지 확인한다.
연결 상태가 up인 경우에 잘 붙은 것이며 좌측 주소를 클릭하면 위에 http://localhost:8080/actuator/prometheus에 접속한 것과 동일한 로그가 보인다.

prometheus <-> grafana

grafana에서 초기 화면에서 Add you first Datasource 클릭
Prometheus 클릭 후 url에 http://host.docker.internal:9090/ 입력한다.
우측 위 상단에 import dashboard로 id가 4701인 대쉬보드를 검색 후 만들어놓은 datasource를 추가하면 완료.

image

스레드 개수 확인 가능

image

peak은 최고 스레드 개수
live는 살아있는 스레드 개수
deamon은 백그라운드에서 보조 작업을 수행하는 스레드(GC, 메모리 관리 등)
즉, live 개수에 deamon 개수를 빼면 요청자가 대충 몇명인지 알 수도 있다.

About

grafana-prometheus sample

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages