본문 바로가기

Back

Prometheus Node Exporter 설치 방법

 

본 포스팅은 Node Exporter 설치 방법에 대한 글입니다.

 

Prometheus Node Exporter란?

 

하드웨어와 UNIX 계열의 커널 관련 metrics를 수집하여 HTTP 엔드포인트로 내보내는 오픈소스 소프트웨어

 

 

설치 방법

 

  • 압축 파일을 다운 받아 바이너리 파일로 실행
  • 도커 이미지로 컨테이너 생성하여 실행
  • 도커 컴포즈로 실행

 

바이너리 파일로 실행 

 

Prometheus Download 페이지 접속

https://prometheus.io/download/

 

Download | Prometheus

An open-source monitoring system with a dimensional data model, flexible query language, efficient time series database and modern alerting approach.

prometheus.io

 

OS에 맞는 파일 - 우클릭 - 링크 주소 복사

 

1. wget 명령어로 압축 파일 다운로드 

2. tar xzvf 명령어로 압축 파일 압축 해제

3. 압축 해제된 파일이 있는 경로로 이동 후 바이너리 파일 실행

$ ./node_exporter

 

 

컨테이너로 실행

 

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

 

 

Node Exporter를 컨테이너로 실행할 경우, 

몇 가지 옵션을 설정해줘야 Node Exporter 컨테이너 자체가 아닌 호스트를 모니터링 할 수 있습니다. 

 

$ docker run -d --name node-exporter \

Docker를 사용하여 컨테이너를 'node-exporter'라는 이름으로 백그라운드(-d 옵션)에서 실행합니다.

 

--net="host" \

컨테이너가 호스트 네트워크를 사용하도록 설정합니다.

이렇게 하면 컨테이너는 호스트의 네트워크 스택을 그대로 사용할 수 있습니다.

 

--pid="host" \

호스트의 PID 네임스페이스를 공유하여 컨테이너 내부에서 호스트의 프로세스 ID를 볼 수 있습니다.

 

-v "/:/host:ro,rslave" \ 

호스트의 루트 디렉토리("/")를 컨테이너의 "/host" 디렉토리에 읽기 전용(ro)으로 마운트합니다.

'rslave' 옵션은 호스트에서 마운트 된 변경 사항이 컨테이너에 전파되도록 설정합니다.

 

quay.io/prometheus/node-exporter:latest \

컨테이너가 실행할 이미지와 이미지 버전을 명시합니다. 

 

--path.rootfs=/host

Node Exporter에게 시스템의 루트 파일 시스템이 '/host'에 마운트되어 있다는 것을 알려주는 옵션입니다.
이 옵션을 통해 Node Exporter는 호스트 시스템의 메트릭을 수집할 수 있습니다.

 

 

도커 컴포즈로 실행

 

docker-compose.yaml 

version: '3.8'

services: 

  node_exporter: 
    image: quay.io/prometheus/node-exporter:latest 
    container_name: node_exporter 
    command:
      - '--path.rootfs=/host' 
    network_mode: host
    pid: host
    restart: unless-stopped 
    volumes: 
      - '/:/host:ro,rslave'

 

 

포트 

 

Node Exporter는 기본적으로 9100 포트에서 실행됩니다.

 

 

메트릭 정보 확인

Node Exporter 실행 후 엔드포인트로 접속하면 아래와 같은 metrics 정보를 확인할 수 있습니다.

 

호스트 주소:9100/metrics

 

<<<<< 메트릭 페이지 이미지 추가 >>>>>>>

 

 

 

 

참고

 

https://github.com/prometheus/node_exporter

 

GitHub - prometheus/node_exporter: Exporter for machine metrics

Exporter for machine metrics. Contribute to prometheus/node_exporter development by creating an account on GitHub.

github.com

 

https://yoo11052.tistory.com/204

 

[Prometheus] Node Exporter란?

Node Exporter Prometheus Node Exporter는 하드웨어의 상태와 커널 관련 메트릭을 수집하는 메트릭 수집기입니다. Prometheus는 Node Exporter의 metrics HTTP endpoint에 접근하여 해당 메트릭을 수집할 수 있습니다. N

yoo11052.tistory.com

 

'Back' 카테고리의 다른 글

swagger 사용법  (2) 2024.10.21
Observer Pattern과 알림 시스템  (0) 2024.07.05
Trie 구조  (0) 2024.03.25
시스템 명령어로 도커 컨테이너의 리소스 사용 정보 구하기  (0) 2024.02.28
[Java] 시스템 명령어 실행하기  (0) 2024.02.01