node_exporter로 리눅스 호스트 메트릭 모니터링
node_exporter로 리눅스 호스트 메트릭 모니터링 (Monitoring Linux host metrics with the Node Exporter)
Prometheus Node Exporter는 다양한 하드웨어·커널 관련 메트릭을 노출해요. 이 가이드에서는 다음을 진행합니다:
localhost에서 Node Exporter 시작- 실행 중인 Node Exporter의 메트릭을 스크레이프하도록 구성된 Prometheus 인스턴스를
localhost에서 시작
참고: Prometheus Node Exporter는 *nix 시스템용이지만, Windows에는 비슷한 목적의 Windows exporter가 있습니다.
출처: 문서
본문
Prometheus Node Exporter는 다양한 하드웨어·커널 관련 메트릭을 노출합니다. 이 가이드에서는:
localhost에서 Node Exporter를 시작하고,- 실행 중인 Node Exporter의 메트릭을 스크레이프하도록 구성된 Prometheus 인스턴스를
localhost에서 시작합니다.
참고: Prometheus Node Exporter는 *nix 시스템용이지만, Windows에는 비슷한 목적을 제공하는 Windows exporter가 있습니다.
Node Exporter 설치 및 실행
Prometheus Node Exporter는 tarball로 설치할 수 있는 단일 정적 바이너리입니다. Prometheus 다운로드 페이지에서 받아 압축을 풀고 실행합니다:
# 참고: URL을 위에 언급한 "downloads" 페이지의 것으로 교체하세요.
# Node Exporter는 여러 OS 대상과 아키텍처에서 사용할 수 있습니다.
# 다운로드는 다음에서 가능합니다:
# https://github.com/prometheus/node_exporter/releases/download/v<version>/node_exporter-<version>.<os>-<arch>.tar.gz
#
# <version>, <os>, <arch>는 플레이스홀더입니다:
# - <version>: 릴리즈 버전 (예: 1.10.2)
# - <os>: 운영체제 (예: linux, darwin, freebsd)
# - <arch>: 아키텍처 (예: amd64, arm64, 386)
#
# 이 예시에서는 amd64 아키텍처의 리눅스 시스템용 Node Exporter 버전 1.10.2를 사용합니다.
wget https://github.com/prometheus/node_exporter/releases/download/v1.10.2/node_exporter-1.10.2.linux-amd64.tar.gz
tar xvfz node_exporter-1.10.2.linux-amd64.tar.gz
cd node_exporter-1.10.2.linux-amd64
./node_exporter
다음과 같은 출력이 보이면 Node Exporter가 실행 중이며 포트 9100에서 메트릭을 노출하고 있다는 뜻입니다:
INFO[0000] Starting node_exporter (version=0.16.0, branch=HEAD, revision=d42bd70f4363dced6b77d8fc311ea57b63387e4f) source="node_exporter.go:82"
INFO[0000] Build context (go=go1.9.6, user=root@a67a9bc13a69, date=20180515-15:53:28) source="node_exporter.go:83"
INFO[0000] Enabled collectors: source="node_exporter.go:90"
INFO[0000] - boottime source="node_exporter.go:97"
...
INFO[0000] Listening on :9100 source="node_exporter.go:111"
Node Exporter 메트릭
Node Exporter가 설치·실행되면 /metrics 엔드포인트를 cURL로 호출해 메트릭이 노출되는지 확인할 수 있습니다:
curl http://localhost:9100/metrics
다음과 같은 출력이 보일 것입니다:
# HELP go_gc_duration_seconds A summary of the GC invocation durations.
# TYPE go_gc_duration_seconds summary
go_gc_duration_seconds{quantile="0"} 3.8996e-05
go_gc_duration_seconds{quantile="0.25"} 4.5926e-05
go_gc_duration_seconds{quantile="0.5"} 5.846e-05
# etc.
성공입니다! Node Exporter가 이제 Prometheus가 스크레이프할 수 있는 메트릭을 노출하며, 출력을 더 내려가면 광범위한 시스템 메트릭(node_ 접두사)이 포함됩니다. 그 메트릭들(도움말과 타입 정보와 함께)을 보려면:
curl http://localhost:9100/metrics | grep "node_"
Prometheus 인스턴스 구성
로컬에서 실행 중인 Prometheus 인스턴스가 Node Exporter 메트릭에 접근하려면 제대로 구성되어야 합니다. 다음 prometheus.yml 예제 구성 파일은 Prometheus 인스턴스에 localhost:9100을 통해 Node Exporter를 스크레이프하라고, 그리고 얼마나 자주 할지를 알려줍니다:
global:
scrape_interval: 15s
scrape_configs:
- job_name: node
static_configs:
- targets: ['localhost:9100']
Prometheus를 설치하려면 플랫폼용 최신 릴리즈를 받아 압축을 풉니다:
wget https://github.com/prometheus/prometheus/releases/download/v*/prometheus-*.*-amd64.tar.gz
tar xvf prometheus-*.*-amd64.tar.gz
cd prometheus-*.*
Prometheus가 설치되면 --config.file 플래그로 위에서 만든 Prometheus 구성을 가리켜 시작합니다:
./prometheus --config.file=./prometheus.yml
표현식 브라우저로 Node Exporter 메트릭 탐색
이제 Prometheus가 실행 중인 Node Exporter 인스턴스에서 메트릭을 스크레이프하므로, Prometheus UI(일명 표현식 브라우저)로 그 메트릭을 탐색할 수 있습니다. 브라우저에서 localhost:9090/graph로 이동해 페이지 상단의 표현식 입력란에 표현식을 입력하세요.
Node Exporter 고유의 메트릭은 node_로 시작하며 node_cpu_seconds_total, node_exporter_build_info 같은 메트릭을 포함합니다.
아래 링크를 클릭하면 예시 메트릭을 볼 수 있습니다:
| 메트릭 | 의미 |
|---|---|
rate(node_cpu_seconds_total{mode="system"}[1m]) |
지난 1분 동안 초당 시스템 모드에서 보낸 평균 CPU 시간(초 단위) |
node_filesystem_avail_bytes |
비루트 사용자가 사용할 수 있는 파일시스템 공간(바이트 단위) |
rate(node_network_receive_bytes_total[1m]) |
지난 1분 동안 초당 수신된 평균 네트워크 트래픽(바이트 단위) |
더 알아보기 (Learn more)
- node_exporter GitHub — 수집기와 플래그 전체 문서
- 다중 대상 엑스포터 패턴 — 엑스포터 확장 패턴
- 표현식 브라우저 — Prometheus UI 사용법
- 쿼리 기본 — PromQL 시작하기