본문 바로가기
기타

프로메테우스&그라파나 설치

by 앗사비 2024. 10. 15.
728x90

A PC (감시해야 하는 대상)

* 수집기 설치

docker run -d --name node-exporter \
  --net="host" \
  --pid="host" \
  -v "/:/host:ro,rslave" \
  quay.io/prometheus/node-exporter:latest \
  --path.rootfs=/host




B PC (모니터링 도구 설치)

* Node Exporter 실행 확인
A_PC_IP:9100 으로 접속

* prometheus.yml 작성

global:
  scrape_interval: 1m  # 기본 스크래핑 간격

scrape_configs:
  # Prometheus 서버 자체를 모니터링하기 위한 설정
  - job_name: 'prometheus'
    static_configs:
      - targets: ['localhost:9090']

  # Node Exporter를 모니터링하기 위한 설정 (EC2에 설치한 경우 등)
  - job_name: 'node'
    static_configs:
      - targets: ['A_PC_IP:9100']



* Prometheus 설치 (수집기가 보내준 것을 저장하는 도구)

docker run --name prometheus -d -p 9090:9090 -v ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus

 

localhost:9090 접속해서 설치 확인

* Grafana 설치 (시각화)

docker run --name grafana -d -p 3001:3000 -e GF_SECURITY_ADMIN_USER=admin -e GF_SECURITY_ADMIN_PASSWORD=pw1234 grafana/grafana


localhost:3001 접속해서 설치 확인

커넥션 > 데이터소스 > 프로메테우스 추가 (B_PC_IP:9090)

대시보드 추가 (ID 복사 후 대시보드 임포트) : https://grafana.com/grafana/dashboards/1860-node-exporter-full/

 

---

 

참고

https://hippogrammer.tistory.com/258

 

728x90