이쿠의 슬기로운 개발생활

함께 성장하기 위한 보안 개발자 EverNote 내용 공유

Kubernetes/Monitoring

Kubernetes 모니터링 : node-exporter 란?

이쿠우우 2024. 9. 5. 21:03
반응형
 

Node Exporter

 

node-exporter 란?

Prometheus 재단이 공식적으로 지원하고 있는 Exporter 중 하나이며
Prometheus로 모니터링 시스템을 구축 시 System Metrics를 수집을 위해 가장 우선적으로 고려되는 Exporter이기도 함.
 

Exporter 란?

Exporter란 특정 Metrics을 수집해서 엔드포인트에 노출시키는 소프트웨어 혹은 에이전트를 의미함.
node-exporter가 UNIX 계열 서버의 cpu, memory 등의 Metrics을 수집할 수 있는 것처럼,
DB, 하드웨어, 메세지 시스템, 저장소 등 여러 시스템에 대한 Exporter가 존재하며,
CollectD 등 기존의 서버 모니터링에 사용되는 에이전트들과 통합할 수 있는 Exporter도 존재함.
 
 

수집하는 metrics 계층

=  System Metrics
Instanace의 cpu, loadAvg, memory 및 네트워크 정보 등 "system metrics"정보를 수집하여 API로 제공.
 

수집하는 metrics 정보 확인 링크

[node-export의 metrics list 정보]
 
 

수집한 metrics 정보를 전달하는 방식

=  Pull 방식
node-exporter는 HTTP 통신을 통해 Prometheus Server와 같은 metrics server가
node-exporter가 수집한 Metric Data를 가져갈 수 있도록 /metrics 라는 HTTP 엔드포인트를 제공함.
exporter가 해당 엔드포인트를 제공하고 있어서
Server가 exporter의 엔드포인트로 HTTP GET 요청을 날려 Metric Data를 Pull방식으로 수집함.
 

 

node-exporter가 수집한 metrics 정보 확인하는 방법

 

node-exporter daemonset yaml

모든 node에 배포되어 각 node의 metrics자원을 확인해야 함으로 daemonset으로 배포해야야함.
 
2023.01.30 기준 최신 version = v1.5.0
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: node-exporter
  namespace: kube-system
  labels:
    app: node-exporter
spec:
  selector:
    matchLabels:
      app: node-exporter
  template:
    metadata:
      labels:
        app: node-exporter
    spec:
      hostNetwork: true
      hostIPC: true
      hostPID: true
      containers:
        - name: node-exporter
          image: quay.io/prometheus/node-exporter:v1.5.0
          imagePullPolicy: IfNotPresent
          args:
            - --path.procfs=/host/proc
            - --path.sysfs=/host/sys
            - --path.rootfs=/host/root
            - --collector.filesystem.mount-points-exclude=^/(dev|proc|sys|var/lib/docker/.+|var/lib/kubelet/.+)($|/)
            - --collector.filesystem.fs-types-exclude=^(autofs|binfmt_misc|bpf|cgroup2?|configfs|debugfs|devpts|devtmpfs|fusectl|hugetlbfs|iso9660|mqueue|nsfs|overlay|proc|procfs|pstore|rpc_pipefs|securityfs|selinuxfs|squashfs|sysfs|tracefs)$
          resources:
            requests:
              cpu: 10m
              memory: 100Mi
            limits:
              cpu: 100m
              memory: 100Mi
          ports:
            - name: scrape
              containerPort: 9100
              hostPort: 9100
          volumeMounts:
            - mountPath: /host/proc
              name: proc
              readOnly: true
            - mountPath: /host/sys
              name: sys
              readOnly: true
            - mountPath: /host/root
              mountPropagation: HostToContainer
              name: root
              readOnly: true
      volumes:
        - name: proc
          hostPath:
            path: /proc
            type: ""
        - name: sys
          hostPath:
            path: /sys
        - name: root
          hostPath:
            path: /

 

 

node-exporter container로 실행

nerdctl run -d \
  --name=node-exporter \
  --volume=/proc:/host/proc:ro \
  --volume=/sys:/host/sys:ro \
  --volume=/:/host/root:ro \
  --network host \
  quay.io/prometheus/node-exporter:v1.5.0 \
  --path.procfs=/host/proc \
  --path.sysfs=/host/sys \
  --path.rootfs=/host/root \
  --collector.filesystem.mount-points-exclude="^/(dev|proc|sys|var/lib/docker/.+|var/lib/kubelet/.+)($|/)" \
  --collector.filesystem.fs-types-exclude="^(autofs|binfmt_misc|bpf|cgroup2?|configfs|debugfs|devpts|devtmpfs|fusectl|hugetlbfs|iso9660|mqueue|nsfs|overlay|proc|procfs|pstore|rpc_pipefs|securityfs|selinuxfs|squashfs|sysfs|tracefs)$"

 

 

node-exporter process 로 실행

wget https://github.com/prometheus/node_exporter/releases/download/v1.6.1/node_exporter-1.6.1.linux-amd64.tar.gz
tar xvf node_exporter-1.6.1.linux-amd64.tar.gz
mv node_exporter-1.6.1.linux-amd64/node_exporter /bin/node_exporter
node_exporter --version

 

 

node-exporter port

node-export 는 고정 port로 9100 을 사용하고 있음.
 

node-exporter metrics 수집 결과 확인

배포된 각 노드로 아래 명령을 해보면 노드 metrics 정보를 확인할 수 있음.
curl {노드 IP}:9100/metrics

 

 

수집이 비활성화인 항목 활성화 방법

node-exporter는 default로 수집을 하지않는 항목들이 있음.
해당 항목들 활성화 방법은 node-exporter 실행 시 아래 옵션을 추가하면됨.
  --collector."활성하고자 하는 정보"
ex) --collector.processes

 

특정 항목만 수집하는 방법

--collector.disable-defaults --collector.<name>

 

예제

nerdctl run -d \
  --name=node-exporter \
  --volume=/proc:/host/proc:ro \
  --volume=/sys:/host/sys:ro \
  --volume=/:/host/root:ro \
  --network host \
  quay.io/prometheus/node-exporter:v1.6.0 \
  --path.procfs=/host/proc \
  --path.sysfs=/host/sys \
  --path.rootfs=/host/root \
  --collector.processes \
  --collector.filesystem.fs-types-exclude="^(autofs|binfmt_misc|bpf|cgroup2?|configfs|debugfs|devpts|devtmpfs|fusectl|hugetlbfs|iso9660|mqueue|nsfs|overlay|proc|procfs|pstore|rpc_pipefs|securityfs|selinuxfs|squashfs|sysfs|tracefs|vfat|tmpfs)$"

 

[참고]
반응형