본문 바로가기
Framework and Tool/Prometheus

With grafana

by ocwokocw 2023. 4. 22.

- 출처: https://prometheus.io/docs/tutorials/visualizing_metrics_using_grafana/

 

Goal

- 수집한 metric을 Grafana로 시각화


Overview

Prometheus server가 수집한 metric을 Grafana로 시각화 한다. 앞서 살펴보았듯 Prometheus도 web UI를 제공하긴 하지만 일반적으로는 Grafana dashboard를 가장 많이 사용한다. prometheus 홈페이지에서도 Prometheus graph 대신 Grafana를 권장하고 있다.


Grafana 설치 및 설정

https://grafana.com/docs/grafana/latest/setup-grafana/installation/#supported-operating-systems 에서 각 OS 에 맞는 가이드를 참조하여 설치한다. 본 글에서는 standalone macos binaries를 이용하도록 하겠다.

 

curl -O https://dl.grafana.com/oss/release/grafana-7.1.5.darwin-amd64.tar.gz
./bin/grafana-server web

...

bin % ./grafana-server web
INFO [04-22|17:47:42] Starting Grafana                         logger=settings version=9.4.7 commit=4add91f03d branch=HEAD compiled=2023-03-17T08:56:52+09:00
WARN [04-22|17:47:42] "sentry" frontend logging provider is deprecated and will be removed in the next major version. Use "grafana" provider instead. logger=settings
INFO [04-22|17:47:42] Config loaded from                       logger=settings file=/Users/user/Documents/Study/prometheus/grafana-9.4.7/conf/defaults.ini
INFO [04-22|17:47:42] Path Home                                logger=settings path=/Users/user/Documents/Study/prometheus/grafana-9.4.7
INFO [04-22|17:47:42] Path Data                                logger=settings path=/Users/user/Documents/Study/prometheus/grafana-9.4.7/data
INFO [04-22|17:47:42] Path Logs                                logger=settings path=/Users/user/Documents/Study/prometheus/grafana-9.4.7/data/log
INFO [04-22|17:47:42] Path Plugins                             logger=settings path=/Users/user/Documents/Study/prometheus/grafana-9.4.7/data/plugins
INFO [04-22|17:47:42] Path Provisioning                        logger=settings path=/Users/user/Documents/Study/prometheus/grafana-9.4.7/conf/provisioning
INFO [04-22|17:47:42] App mode production                      logger=settings
INFO [04-22|17:47:42] Connecting to DB                         logger=sqlstore dbtype=sqlite3
INFO [04-22|17:47:42] Starting DB migrations                   logger=migrator
INFO [04-22|17:47:42] migrations completed                     logger=migrator performed=0 skipped=571 duration=688.375µs
INFO [04-22|17:47:42] Validated license token                  logger=licensing appURL=http://localhost:3000/ source=disk status=NotFound
INFO [04-22|17:47:42] Plugin registered                        logger=plugin.loader pluginID=input
WARN [04-22|17:47:42] Skipping finding plugins as directory does not exist logger=plugin.finder path=/Users/user/Documents/Study/prometheus/grafana-9.4.7/data/plugins
INFO [04-22|17:47:42] Envelope encryption state                logger=secrets enabled=true current provider=secretKey.v1
INFO [04-22|17:47:42] Query Service initialization             logger=query_data
INFO [04-22|17:47:42] Live Push Gateway initialization         logger=live.push_http
INFO [04-22|17:47:43] registering usage stat providers         logger=infra.usagestats.collector usageStatsProvidersLen=2
INFO [04-22|17:47:43] starting to provision alerting           logger=provisioning.alerting
INFO [04-22|17:47:43] finished to provision alerting           logger=provisioning.alerting
INFO [04-22|17:47:43] storage starting                         logger=grafanaStorageLogger
INFO [04-22|17:47:43] Warming state cache for startup          logger=ngalert.state.manager
WARN [04-22|17:47:43] Scheduling and sending of reports disabled, SMTP is not configured and enabled. Configure SMTP to enable. logger=report
INFO [04-22|17:47:43] HTTP Server Listen                       logger=http.server address=[::]:3000 protocol=http subUrl= socket=
INFO [04-22|17:47:43] State cache has been initialized         logger=ngalert.state.manager states=0 duration=18.354375ms
INFO [04-22|17:47:43] starting MultiOrg Alertmanager           logger=ngalert.multiorg.alertmanager
INFO [04-22|17:47:43] starting                                 logger=ticker first_tick=2023-04-22T17:47:50+09:00

정상실행되었을 경우 localhost:3000 에 접속하면 Grafana 화면을 볼 수 있다.


Grafana에 Datasource 추가

왼쪽 메뉴에서 Gear icon 의 Data Sources를 클릭한다.

Add new datasource를 클릭하면 다양한 데이터소스를 연동할 수 있다. Prometheus를 선택한다.

URL란에 Prometheus instance URL을 입력해준다.

Save & Test 버튼으로 저장하고 뒤로가기 버튼을 누른다. Dashboard 화면에 진입하여 연동 확인

'Framework and Tool > Prometheus' 카테고리의 다른 글

Node exporter  (0) 2023.04.22
Prometheus - 살펴보기(first steps)  (0) 2022.01.06
Prometheus - 개요  (0) 2022.01.02

댓글