node-exporter를 설치하였으니 이제 Prometheus를 설치할 차례이다. 역시 프로그램 파일을 받아서 이용해도 되고 Docker container를 이용해도 된다. Docker를 이용한 방법을 설명한다. 9090번 포트를 이용해서 환경 설정 화면에 들어갈 수 있다.
sudo docker run \
-itd \
-p 9090:9090 \
--restart always \
--name prometheus \
prom/prometheus
Docker를 이용한다면 promethus.yml 파일을 수정해서 정보를 수집한 시스템을 입력해 주어야 한다. 컨테이너에 접근해도 수정할 수 없으므로 해당 파일을 컨테이너가 설치된 컴퓨터로 복사해서 수정한다. 수정한 후에 다시 컨테이너로 복사해 준다.
sudo docker cp prometheus:/etc/prometheus/prometheus.yml .
...
nano prometheus.yml
...
sudo docker cp prometheus.yml prometheus:/etc/prometheus/prometheus.yml
다음과 같이 추가하면 된다. job_name은 적절한 것을 선택하면 된다.
scrape_configs:
- job_name: "server"
static_configs:
- targets: ["10.10.10.170:9100", "10.10.10.184:9100", "10.10.10.171:9100", "10.10.10.178:9100"]
1분 정도 시간이 경과한 후 Status – Targets 에서 정보를 수집하고 있는 것을 확인할 수 있다.

이제 Grafana에서 Prometheus를 등록시켜서 시각화시키면 되는데 이게 처음에는 매우 어렵다.

Monitoring Linux host metrics with the Node Exporter | Prometheus
An open-source monitoring system with a dimensional data model, flexible query language, efficient time series database and modern alerting approach.
여기 하단에 보면 예시가 있는데 이를 이용하면 기본은 할 수 있다.

