1. Node Exporter 설치

서버 리소스 metric이 모니터링 되는 대상 서버를 이제부터 클라이언트라고 칭하겠다.

클라이언트에 Node Exporter 를 설치해야만, 프로메테우스가 Node Exporter로부터 metric을 수집해 올 수 있다.

Node Exporter 설치 방법을 살펴보자!

 

프로메테우스의 Node Exporter는 아래 github 에서 설치할 수 있다.

https://github.com/prometheus/node_exporter/releases/tag/v1.5.0

 

Release 1.5.0 / 2022-11-29 · prometheus/node_exporter

NOTE: This changes the Go runtime "GOMAXPROCS" to 1. This is done to limit the concurrency of the exporter to 1 CPU thread at a time in order to avoid a race condition problem in the Linux kernel (...

github.com

 

리눅스 서버에서 명령어를 통한 설치는 아래와 같다.

# Node_Exporter를 설치하려는 디렉토리로 이동
# 나는 나중에 어디에 설치되어 있는지 확인하기 쉽게, /usr/share/에 'node_exporter' 라는 디렉토리를 따로 만들었다.
$ cd /usr/share/node_exporter

# 설치하려는 클라이언트의 Linux 버전에 따라 설치 파일이 다르다. 유의하자.
$ wget https://github.com/prometheus/node_exporter/releases/download/v1.5.0/node_exporter-1.5.0.linux-amd64.tar.gz

# 다운로드 받은 파일 압축 해제
$ tar -xzvf ./node_exporter-1.5.0.linux-amd64.tar.gz

2. Node Exporter 를 서버 부팅과 함께 실행하도록 service 파일 만든 후, 실행하기

# 서비스 파일 생성
# vi /usr/lib/systemd/system/node_exporter.service
# /usr/lib/systemd/system/node_exporter.service 파일

[Unit]
Descripion=Node Exporter
After=network.target

[Service]
User=root
Group=root
Type=simple
ExecStart=/usr/share/node_exporter/node_exporter

[Install]
WantedBy=multi-user.target
# 작성한 서비스 파일 systemctl로 불러오기
# systemctl daemon-reload

# 부팅 시 자동실행 되도록 enable 설정하기
# systemctl enable node_exporter.service

# Node_Exporter 실행하기
# systemctl start node_exporter.service

 

위 과정을 거쳐 node_exporter 를 실행한 후, 브라우저에서 아래 URL로 접속하면 클라이언트의 metric이 프로메테우스가 가져올 수 있는 형태로 수집되는 것을 확인할 수 있다. 디폴트 포트가 9100 으로 설정되어 있다는 것을 알아두자!

 

{node_exporter가 설치된 서버의 IP}:9100/

or

{node_exporter가 설치된 서버의 IP}:9100/metrics


3. 프로메테우스 서버에 모니터링 할 클라이언트(Node_exporter가 설치된 서버) 등록하기

# 프로메테우스가 설치된 서버

# 프로메테우스로 유저 전환
# su - prometheus

# 프로메테우스 서버의 설정파일 변경
$ vi $PROMETHEUS_HOME/prometheus.yml
# 'scrape_configs' 에 아래 내용 추가 또는 변경

  - job_name: "프로메테우스에서 인식할 job name으로 설정"
    
    static_confgis:
      - target: ["{Node_Exporter가 설치된 서버 IP}:9100"]

참고

https://sanggi-jayg.tistory.com/104

 

Prometheus + Node Exporter + Grafana 연동

프로메테우스 설치 https://prometheus.io/ # 유저 추가 useradd -m -s /bin/bash prometheus su - prometheus # 다운로드 cd /home/prometheus wget https://github.com/prometheus/prometheus/releases/download/v2.28.0/prometheus-2.28.0.linux-amd64.tar

sanggi-jayg.tistory.com

 

  • 네이버 블러그 공유하기
  • 네이버 밴드에 공유하기
  • 페이스북 공유하기
  • 카카오스토리 공유하기