본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

프로세스 익스포터 메트릭 (Process exporter metrics)

원문 보기 위키 갱신

Process Exporter를 기반으로 한 플러그인으로, 시스템 메트릭 중 프로세스 수준의 메트릭을 수집해요.

출처: 문서

본문

지원 이벤트 유형: metrics

Prometheus Node exporter는 CPU, 디스크, 네트워크, 프로세스 통계 같은 운영체제의 시스템 수준 메트릭을 수집하는 인기 있는 방법이에요.

Fluent Bit 2.2 이상에는 Prometheus 설계를 기반으로 한 프로세스 익스포터 플러그인이 포함되어 있어요. 두 개의 별도 프로세스나 에이전트를 관리하지 않아도 프로세스 수준 메트릭을 수집할 수 있어요.

Process Exporter Metrics 플러그인은 Prometheus Process Exporter의 서드파티 구현에서 제공하는 다양한 메트릭을 수집하도록 구현되어 있고, 필요에 따라 앞으로 계속 확장될 거예요.

참고: 이 플러그인으로 수집한 메트릭을 포함해 모든 메트릭은 로그와는 별도의 파이프라인을 통해 흐르고, 현재 필터는 메트릭 위에서 동작하지 않아요. 이 플러그인은 관련 메트릭에 접근하기 위해 proc 파일시스템을 사용하므로 Linux 기반 운영체제에서만 지원돼요. MacOS는 proc 파일시스템이 없어서 이 플러그인이 동작하지 않아요.

Configuration (설정)

Key Description Default
metrics Specify which process level of metrics are collected from the host operating system. Actual values of metrics will be read from /proc when needed. context_switches, cpu, fd, io, memory, start_time, state, thread, and thread_wchan metrics depend on procfs. cpu,io,memory,state,context_switches,fd,start_time,thread_wchan,thread
path.procfs The mount point used to collect process information and metrics. Read-only permissions are enough. /proc
process_exclude_pattern Regular expression to determine which names of processes are excluded in the metrics produced by this plugin. It's not applied unless explicitly set. NULL
process_include_pattern Regular expression to determine which names of processes are included in the metrics produced by this plugin. It's applied for all process unless explicitly set. .+
scrape_interval The rate, in seconds, at which metrics are collected. 5

Available metrics (사용 가능한 메트릭)

Name Description
context_switches Exposes context_switches statistics from /proc.
cpu Exposes CPU statistics from /proc.
fd Exposes file descriptors statistics from /proc.
io Exposes I/O statistics from /proc.
memory Exposes memory statistics from /proc.
start_time Exposes start_time statistics from /proc.
state Exposes process state statistics from /proc.
thread Exposes thread statistics from /proc.
thread_wchan Exposes thread_wchan from /proc.

Prometheus metric names (Prometheus 메트릭 이름)

다음 표는 각 수집기(collector)가 노출하는 Prometheus 메트릭을 설명해요.

Process-level metrics (프로세스 수준 메트릭)

Prometheus Metric Enabled by Type Description
process_context_switches_total context_switches counter Context switches (voluntary and non-voluntary).
process_cpu_seconds_total cpu counter CPU usage in seconds (user and system).
process_fd_ratio fd gauge Ratio between open file descriptors and max limit.
process_major_page_faults_total memory counter Major page faults.
process_memory_bytes memory gauge Memory in use (virtual memory and RSS).
process_minor_page_faults_total memory counter Minor page faults.
process_num_threads thread gauge Number of threads.
process_open_filedesc fd gauge Number of open file descriptors.
process_read_bytes_total io counter Number of bytes read.
process_start_time_seconds start_time gauge Start time in seconds since 1970/01/01.
process_states state gauge Process state (R, S, D, Z, T, or I).
process_write_bytes_total io counter Number of bytes written.

Thread-level metrics (스레드 수준 메트릭)

Prometheus Metric Enabled by Type Description
process_thread_context_switches_total thread counter Thread context switches (voluntary and non-voluntary).
process_thread_cpu_seconds_total thread counter Thread CPU usage in seconds (user and system).
process_thread_io_bytes_total thread counter Thread I/O bytes (read and write).
process_thread_major_page_faults_total thread counter Thread major page faults.
process_thread_minor_page_faults_total thread counter Thread minor page faults.
process_thread_wchan thread_wchan gauge Number of threads waiting on each wchan.

Threading (스레딩)

이 입력은 항상 자체 스레드에서 실행돼요.

Getting started (시작하기)

Configuration file (설정 파일)

다음 설정 파일에서 입력 플러그인 process_exporter_metrics는 2초마다 메트릭을 수집하고, Prometheus Exporter 출력 플러그인을 통해 HTTP/TCP 포트 2021에서 노출해요.

{% tabs %} {% tab title="fluent-bit.yaml" %}

# Process Exporter Metrics + Prometheus Exporter
# -------------------------------------------
# The following example collect host metrics on Linux and expose
# them through a Prometheus HTTP endpoint.
#
# After starting the service try it with:
#
# $ curl http://127.0.0.1:2021/metrics
#
service:
  flush: 1
  log_level: info

pipeline:
  inputs:
    - name: process_exporter_metrics
      tag:  process_metrics
      scrape_interval: 2

  outputs:
    - name: prometheus_exporter
      match: process_metrics
      host: 0.0.0.0
      port: 2021

{% endtab %}

{% tab title="fluent-bit.conf" %}

# Process Exporter Metrics + Prometheus Exporter
# -------------------------------------------
# The following example collect host metrics on Linux and expose
# them through a Prometheus HTTP endpoint.
#
# After starting the service try it with:
#
# $ curl http://127.0.0.1:2021/metrics
#
[SERVICE]
  Flush           1
  Log_Level       info

[INPUT]
  Name            process_exporter_metrics
  Tag             process_metrics
  Scrape_Interval 2

[OUTPUT]
  Name            prometheus_exporter
  Match           process_metrics
  Host            0.0.0.0
  Port            2021

{% endtab %} {% endtabs %}

curl을 사용해서 메트릭을 확인할 수 있어요:

curl http://127.0.0.1:2021/metrics

Container to collect host metrics (호스트 메트릭 수집용 컨테이너)

컨테이너에 Fluent Bit를 배포할 때는 Fluent Bit가 프로세스 세부 정보에 접근할 수 있도록 추가 설정을 지정해야 해요.

다음 docker 명령은 procfs에 특정 마운트 경로를 사용하고, Fluent Bit가 호스트에서 수집할 수 있도록 설정을 활성화한 채 Fluent Bit를 배포해요. 이 메트릭들은 포트 2021을 통해 노출돼요.

docker run -ti -v /proc:/host/proc:ro \
            -p 2021:2021        \
            fluent/fluent-bit:2.2 \
            /fluent-bit/bin/fluent-bit \
            -i process_exporter_metrics \
            -p path.procfs=/host/proc  \
            -o prometheus_exporter \
            -f 1

Enhancement requests (개선 요청)

개발은 Prometheus Process Exporter의 서드파티 구현에서 사용 가능한 수집기 중 일부 하위 집합을 우선으로 해요. 다른 수집기를 요청하려면 다음 템플릿을 사용해서 GitHub 이슈를 열어주세요:

더 알아보기 (Learn more)