Prometheus & Grafana 대시보드 코드 및 문서 추가

This commit is contained in:
roy-zz
2022-05-04 00:09:32 +09:00
parent fa92cdddf9
commit 055660a779
23 changed files with 98 additions and 10 deletions

View File

@@ -0,0 +1,88 @@
[이전 장(링크)](https://imprint.tistory.com/246) 에서는 `Prometheus``Grafana`를 설치하는 방법에 대해서 알아보았다.
이번 장에서는 `Grafana``Dashboard`를 추가하여 이전보다 데이터를 더 편리하게 확인할 수 있도록 수정해본다.
모든 소스 코드는 [깃 허브 (링크)](https://github.com/roy-zz/spring-cloud) 에 올려두었다.
---
### Grafana Dashboard
우리는 `Grafana``JVM(Micrometer)`, `Prometheus`, `Spring Cloud Gateway` 세 개의 Dashboard를 추가할 것이다.
`JVM(Micrometer)` 부터 하나씩 추가해보도록 한다.
---
#### JVM(Micrometer)
1. Get this dashboard 확인
아래의 주소로 접속하여 Dashboard를 추가하기 위해 `Get this dashboard`에 나와있는 코드 번호를 확인하도록 한다.
```bash
https://grafana.com/grafana/dashboards/11892
```
![](prometheus_dashboard_image/check-jvm-dashboard-serial-number.png)
2. import
좌측 탭에서 `create` -> `import`를 선택한다.
![](prometheus_dashboard_image/create-and-import.png)
3. load
1번 단계에서 확인한 코드 번호를 입력하고 `Load`를 클릭한다.
![](prometheus_dashboard_image/enter-jvm-code-and-load.png)
이후 `Import` 버튼이 활성화되면 선택해서 `JVM Dashboard`를 추가한다.
![](prometheus_dashboard_image/select-prometheus-and-import.png)
4. 정상작동 확인
`Dashboard` -> `JVM` 을 선택하여 정상적으로 `dashboard`가 표시되는지 확인한다.
![](prometheus_dashboard_image/check-jvm-dashboard.png)
---
#### Prometheus
1. Get this dashboard 확인
아래의 주소로 접속하여 Dashboard를 추가하기 위해 `Get this dashboard`에 나와있는 코드 번호를 확인하도록 한다.
```bash
https://grafana.com/grafana/dashboards/3662
```
2. JVM(Micrometer)과 동일
이후의 단계는 `JVM(Micrometer)`를 추가하는 과정과 동일하며 아래와 같은 화면이 나온다면 정상적으로 연동이 완료된 것이다.
![](prometheus_dashboard_image/check-prometheus-dashboard.png)
---
#### Spring Cloud Gateway
1. Get this dashboard 확인
아래의 주소로 접속하여 Dashboard를 추가하기 위해 `Get this dashboard`에 나와있는 코드 번호를 확인하도록 한다.
```bash
https://grafana.com/grafana/dashboards/11506
```
2. JVM(Micrometer)과 동일
이후의 단계는 `JVM(Micrometer)`를 추가하는 과정과 동일하며 아래와 같은 화면이 나온다면 정상적으로 연동이 완료된 것이다.
![](prometheus_dashboard_image/check-spring-cloud-gateway-dashboard.png)
---
**참고한 강의:**
- https://www.inflearn.com/course/%EC%8A%A4%ED%94%84%EB%A7%81-%ED%81%B4%EB%9D%BC%EC%9A%B0%EB%93%9C-%EB%A7%88%EC%9D%B4%ED%81%AC%EB%A1%9C%EC%84%9C%EB%B9%84%EC%8A%A4

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

View File

@@ -7,12 +7,12 @@
`Turbine Server`는 마이크로서비스에 설치된 `Hystrix` 클라이언트의 스트림 메시지를 아래와 같이 통합한다.
![](micrometer_image/turbine-server-diagram.png)
![](prometheus_install_image/turbine-server-diagram.png)
`Turbine Server`는 설정 파일에 정의되어 있는 `msa-service-order`, `msa-service-member`, `msa-service-delivery`와 같은 `Hystrix` 클라이언트들의 스트림 메시지를 수집한다.
이후 `Hystrix Dashboard`를 통해 클라이언트로 부터 전달받은 스트림을 시각화한다.
![](micrometer_image/turbine-server-flow.png)
![](prometheus_install_image/turbine-server-flow.png)
하지만 `Hystrix``Turbine Server`는 스프링 클라우드 최신 버전에는 더 이상 쓰이지 않다.
최근에는 `Micrometer``Monitoring System`으로 대체되었고 우리의 마이크로서비스에도 새로운 기술을 적용시켜 본다.
@@ -86,13 +86,13 @@ public class MyUserController {
localhost:8000/user-service/actuator/metrics
```
![](micrometer_image/actuator-metrics.png)
![](prometheus_install_image/actuator-metrics.png)
```bash
localhost:8000/user-service/actuator/prometheus
```
![](micrometer_image/actuator-prometheus.png)
![](prometheus_install_image/actuator-prometheus.png)
---
@@ -121,7 +121,7 @@ localhost:8000/user-service/actuator/prometheus
https://prometheus.io/download/
```
![](micrometer_image/prometheus-download.png)
![](prometheus_install_image/prometheus-download.png)
2. prometheus.yml 수정
@@ -150,7 +150,7 @@ $ ./prometheus --config.file=prometheus.yml
아래와 같이 출력된다면 정상적으로 `prometheus`가 실행된 것이다.
![](micrometer_image/run-prometheus-success.png)
![](prometheus_install_image/run-prometheus-success.png)
4. prometheus 접속
@@ -161,10 +161,10 @@ $ localhost:9090
```
**Table**
![](micrometer_image/prometheus-table.png)
![](prometheus_install_image/prometheus-table.png)
**Graph**
![](micrometer_image/prometheus-graph.png)
![](prometheus_install_image/prometheus-graph.png)
---
@@ -178,7 +178,7 @@ $ localhost:9090
grafana.com/grafana/download?platform=mac
```
![](micrometer_image/grafana-download.png)
![](prometheus_install_image/grafana-download.png)
2. grafana 실행
@@ -199,7 +199,7 @@ localhost:3000
`configuration` -> `Data sources` -> `Prometheus` 로 접속하여 위에서 실행시킨 `prometheus`의 정보를 입력한다.
![](micrometer_image/save-prometheus-datasource.png)
![](prometheus_install_image/save-prometheus-datasource.png)
---

View File

Before

Width:  |  Height:  |  Size: 127 KiB

After

Width:  |  Height:  |  Size: 127 KiB

View File

Before

Width:  |  Height:  |  Size: 177 KiB

After

Width:  |  Height:  |  Size: 177 KiB

View File

Before

Width:  |  Height:  |  Size: 175 KiB

After

Width:  |  Height:  |  Size: 175 KiB

View File

Before

Width:  |  Height:  |  Size: 110 KiB

After

Width:  |  Height:  |  Size: 110 KiB

View File

Before

Width:  |  Height:  |  Size: 131 KiB

After

Width:  |  Height:  |  Size: 131 KiB

View File

Before

Width:  |  Height:  |  Size: 115 KiB

After

Width:  |  Height:  |  Size: 115 KiB

View File

Before

Width:  |  Height:  |  Size: 99 KiB

After

Width:  |  Height:  |  Size: 99 KiB

View File

Before

Width:  |  Height:  |  Size: 143 KiB

After

Width:  |  Height:  |  Size: 143 KiB

View File

Before

Width:  |  Height:  |  Size: 153 KiB

After

Width:  |  Height:  |  Size: 153 KiB

View File

Before

Width:  |  Height:  |  Size: 98 KiB

After

Width:  |  Height:  |  Size: 98 KiB