728x90
구성 요소 | 역할 설명 |
Node Exporter | 시스템(CPU, 메모리, 디스크, 네트워크 등)의 로컬 리소스 사용량을 메트릭으로 수집하여 노출함 (기본 포트: 9100) |
Prometheus | 다양한 Exporter(Node Exporter 포함)의 메트릭 데이터를 **정기적으로 수집(scraping)**하고 저장하는 시간 시계열 DB 역할 수행 (기본 포트: 9090) |
Grafana | Prometheus에 저장된 메트릭 데이터를 시각화 대시보드로 표시함 (기본 포트: 3000) |
프로메테우스 설치
# 설치
cd /tmp
wget https://github.com/prometheus/prometheus/releases/download/v2.52.0/prometheus-2.52.0.linux-amd64.tar.gz
tar xvf prometheus-2.52.0.linux-amd64.tar.gz
# 설치
sudo mv prometheus-2.52.0.linux-amd64 /opt/prometheus
cd /opt/prometheus
# 편집기 생성
sudo nano /opt/prometheus/prometheus.yml
# 파일 설정
cd /opt/prometheus
./prometheus --config.file=prometheus.yml
sudo nano /etc/systemd/system/prometheus.service
# 파일 구성
[Unit]
Description=Prometheus
After=network.target
[Service]
User=ubuntu
ExecStart=/opt/prometheus/prometheus --config.file=/opt/prometheus/prometheus.yml
Restart=always
[Install]
WantedBy=multi-user.target
# 재시작
sudo systemctl daemon-reexec
sudo systemctl daemon-reload
sudo systemctl enable prometheus
sudo systemctl start prometheus
#권한 부여
sudo chown -R ubuntu:ubuntu /opt/prometheus
chmod +x /opt/prometheus/prometheus
sudo systemctl daemon-reload
sudo systemctl restart prometheus
sudo systemctl status prometheus
노드 export 설치
cd /tmp
wget https://github.com/prometheus/node_exporter/releases/download/v1.7.0/node_exporter-1.7.0.linux-amd64.tar.gz
tar -xzf node_exporter-1.7.0.linux-amd64.tar.gz
sudo mv node_exporter-1.7.0.linux-amd64 /opt/node_exporter
sudo nano /etc/systemd/system/node_exporter.service
# 설정 파일
[Unit]
Description=Node Exporter
After=network.target
[Service]
User=ubuntu
ExecStart=/opt/node_exporter/node_exporter
[Install]
WantedBy=default.target
#재시작
sudo systemctl daemon-reload
sudo systemctl enable node_exporter
sudo systemctl start node_exporter
시스템 메트릭 확인
curl http://localhost:9100/metrics
잘 나오고 있다.
/opt/prometheus/prometheus.yml 설정 파일에 다음 블록 추가:
scrape_configs:
- job_name: 'node'
static_configs:
- targets: ['localhost:9100']
프로메테우스에 node_export 잘 연결된 모습
그라파나 웹 브라우저 접속 (설치 필요)
- 주소: http://<EC2 Public IP>:3000
- 기본 포트: 3000
- 기본 계정:
- 사용자: admin
- 비밀번호: admin → 최초 로그인 시 비밀번호 변경 필요
Prometheus 연동 (초기 설정)
Grafana 접속 후:
- 왼쪽 메뉴 → Configuration → Data Sources
- Add data source 클릭
- Prometheus 선택
- URL에 http://localhost:9090 입력
- 저장 후 연결 확인 (Save & Test)
대시보드 추가
Node Exporter 대시보드 예시:
잘 뜨는 모습이다
728x90
'카카오테크 부트캠프 > 프로젝트' 카테고리의 다른 글
웹서비스 부하 테스트 (0) | 2025.05.16 |
---|---|
백엔드 서버에 오류가 떴을 때 디스코드로 알람 연동 자동화 기능 연결 (0) | 2025.05.15 |
데이터 베이스 백업 파일 작성 (0) | 2025.05.15 |
수동 SQL 삽입시 발생한 트러블 슈팅 (0) | 2025.05.14 |
React 프로젝트에 Google Analytics 4 연동하기 (0) | 2025.05.13 |