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

프로세스 메트릭 (Process metrics)

원문 보기 위키 갱신

프로세스가 건강한지 확인하고 싶을 때 쓰는 입력 플러그인입니다. 함께 살펴보겠습니다.

출처: 문서

본문

{% hint style="info" %} Supported event types: logs {% endhint %}

Process metrics 입력 플러그인은 프로세스가 얼마나 건강한지 확인할 수 있게 해 줍니다. 지정된 간격으로 서비스 점검을 수행하는 방식으로 동작해요.

이 플러그인은 JSON 페이로드 같은 로그 기반 메트릭을 만듭니다. Prometheus 기반 메트릭이 필요하다면 Node exporter metrics 입력 플러그인을 참고하세요.

Configuration parameters

플러그인은 다음 구성 파라미터를 지원합니다:

Key Description Default
alert If enabled, the plugin will only generate messages if the target process is down. false
fd If enabled, a number of fd is appended to each record. true
interval_nsec Specifies the interval between service checks, in nanoseconds. This works in conjunction with interval_sec. 0
interval_sec Specifies the interval between service checks, in seconds. 1
mem If enabled, memory usage of the process is appended to each record. true
proc_name The name of the target process to check. none
threaded Specifies whether to run this input in its own thread. false

시작하기

점검 수행을 시작하려면 명령줄에서 또는 구성 파일을 통해 플러그인을 실행할 수 있어요:

다음 예시는 crond 프로세스의 건강 상태를 확인합니다.

fluent-bit -i proc -p proc_name=crond -o stdout

구성 파일

주 구성 파일에 다음 섹션을 추가합니다:

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

pipeline:
  inputs:
    - name: proc
      proc_name: crond
      interval_sec: 1
      interval_nsec: 0
      fd: true
      mem: true

  outputs:
    - name: stdout
      match: '*'

{% endtab %}

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

[INPUT]
  Name          proc
  Proc_Name     crond
  Interval_Sec  1
  Interval_Nsec 0
  Fd            true
  Mem           true

[OUTPUT]
  Name   stdout
  Match  *

{% endtab %} {% endtabs %}

테스트

Fluent Bit가 실행되기 시작하면 프로세스의 건강 상태를 출력합니다:

$ fluent-bit -i proc -p proc_name=fluent-bit -o stdout

...
[0] proc.0: [1485780297, {"alive"=>true, "proc_name"=>"fluent-bit", "pid"=>10964, "mem.VmPeak"=>14740000, "mem.VmSize"=>14740000, "mem.VmLck"=>0, "mem.VmHWM"=>1120000, "mem.VmRSS"=>1120000, "mem.VmData"=>2276000, "mem.VmStk"=>88000, "mem.VmExe"=>1768000, "mem.VmLib"=>2328000, "mem.VmPTE"=>68000, "mem.VmSwap"=>0, "fd"=>18}]
[1] proc.0: [1485780298, {"alive"=>true, "proc_name"=>"fluent-bit", "pid"=>10964, "mem.VmPeak"=>14740000, "mem.VmSize"=>14740000, "mem.VmLck"=>0, "mem.VmHWM"=>1148000, "mem.VmRSS"=>1148000, "mem.VmData"=>2276000, "mem.VmStk"=>88000, "mem.VmExe"=>1768000, "mem.VmLib"=>2328000, "mem.VmPTE"=>68000, "mem.VmSwap"=>0, "fd"=>18}]
[2] proc.0: [1485780299, {"alive"=>true, "proc_name"=>"fluent-bit", "pid"=>10964, "mem.VmPeak"=>14740000, "mem.VmSize"=>14740000, "mem.VmLck"=>0, "mem.VmHWM"=>1152000, "mem.VmRSS"=>1148000, "mem.VmData"=>2276000, "mem.VmStk"=>88000, "mem.VmExe"=>1768000, "mem.VmLib"=>2328000, "mem.VmPTE"=>68000, "mem.VmSwap"=>0, "fd"=>18}]
[3] proc.0: [1485780300, {"alive"=>true, "proc_name"=>"fluent-bit", "pid"=>10964, "mem.VmPeak"=>14740000, "mem.VmSize"=>14740000, "mem.VmLck"=>0, "mem.VmHWM"=>1152000, "mem.VmRSS"=>1148000, "mem.VmData"=>2276000, "mem.VmStk"=>88000, "mem.VmExe"=>1768000, "mem.VmLib"=>2328000, "mem.VmPTE"=>68000, "mem.VmSwap"=>0, "fd"=>18}]
...

더 알아보기 (Learn more)