흔자
article thumbnail
반응형

geth healthcheck나 모니터링을 할 수 있는 툴에 대해서 알아보던 중 Grafana라는 모니터링 툴에 대해 알게 되었다. CPU, Memory, 트래픽과 Latest Block Header도 실시간으로 확인할 수 있어 geth를 모니터링하려는 사람들에게 도움이 될 것이라고 생각한다.

 

설정을 완료하게 되면 다음과 같은 화면이 나온다.

설정 완료 화면 미리보기


Prometheus란?

우선 Grafana를 사용하기 위해서 Prometheus를 설치해야 한다.

Prometheus는 이벤트 모니터링 및 경고에 사용되는 무료 소프트웨어 어플리케이션이다.

 

 

Grafana와 Prometheus 설치

Prometheus, Prometheus node exporter 설치

sudo apt-get update
sudo apt-get install -y prometheus prometheus-node-exporter

 

 

prometheus.yml 설정 (geth)

prometheus를 실행하기 위하여 prometheus.yml을 설정한다.

설정 완료한 후에 /etc/prometheus 경로로 설정파일을 이동한다.

nano $HOME/prometheus.yml
sudo mv $HOME/prometheus.yml /etc/prometheus/prometheus.yml

 


prometheus.yml 설정 파일
global:
  scrape_interval:     15s # By default, scrape targets every 15 seconds.

  # Attach these labels to any time series or alerts when communicating with
  # external systems (federation, remote storage, Alertmanager).
  external_labels:
    monitor: 'codelab-monitor'

  # A scrape configuration containing exactly one endpoint to scrape:
  # Here it's Prometheus itself.
  scrape_configs:
   - job_name: 'geth'
     scrape_interval: 15s
     scrape_timeout: 10s
     metrics_path: /debug/metrics/prometheus
     scheme: http
     static_configs:
     - targets: ['localhost:6060']

 

prometheus.yml의 권한을 변경한다.

sudo chmod 644 /etc/prometheus/prometheus.yml

 

 

 

Grafana 설치

curl https://packages.grafana.com/gpg.key | sudo gpg --dearmor -o /usr/share/keyrings/grafana-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/grafana-archive-keyring.gpg] https://packages.grafana.com/oss/deb stable main" | sudo tee /etc/apt/sources.list.d/grafana.list
sudo mv grafana.list /etc/apt/sources.list.d/grafana.list
sudo apt-get update && sudo apt-get install -y grafana​

 

# Grafana 설치 완료
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
OK

 

 

자동으로 시작되도록 서비스 활성화

sudo systemctl enable grafana-server.service prometheus.service prometheus-node-exporter.service
# 활성화 완료
Synchronizing state of grafana-server.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable grafana-server
Synchronizing state of prometheus.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable prometheus
Synchronizing state of prometheus-node-exporter.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable prometheus-node-exporter
Created symlink /etc/systemd/system/multi-user.target.wants/grafana-server.service → /lib/systemd/system/grafana-server.service.

 

 

서비스 재시작 후 상태 확인

서비스를 재시작 후에 status를 확인한다.

sudo systemctl restart grafana-server.service prometheus.service prometheus-node-exporter.service
sudo systemctl status grafana-server.service prometheus.service prometheus-node-exporter.service

 

 

 

포트가 정성적으로 열려있는지 확인


다른 시스템에서 모니터링 정보를 보려면 port 3000이 firewall 및 port forwarded에서 열려있는지 확인해야 한다.

port 3000 : grafana

port 6060 : prometheus

lsof -i:3000
# lsof -i:3000
COMMAND      PID    USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
grafana-s 138217 grafana   18u  IPv6 6702635      0t0  TCP *:3000 (LISTEN)

 

lsof -i:6060
# lsof -i:6060
COMMAND      PID       USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
geth        1381       geth    3u  IPv4   36889      0t0  TCP localhost:6060 (LISTEN)
geth        1381       geth *325u  IPv4 6704177      0t0  TCP localhost:6060->localhost:54584 (ESTABLISHED)
prometheu 138220 prometheus   22u  IPv4 6702651      0t0  TCP localhost:54584->localhost:6060 (ESTABLISHED)

 

 

Reference
 

Prometheus (software) - Wikipedia

From Wikipedia, the free encyclopedia Jump to navigation Jump to search Application used for event monitoring and alerting Prometheus is a free software application used for event monitoring and alerting.[2] It records real-time metrics in a time series da

en.wikipedia.org

 

반응형
profile

흔자

@heun_n

즐겁게 개발하고 싶은 사람입니다.