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

커널 로그 (Kernel logs)

원문 보기 위키 갱신

리눅스 커널 로그 버퍼를 수집하고 싶을 때 쓰는 입력 플러그인입니다. 함께 살펴보겠습니다.

출처: 문서

본문

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

Kernel logs (kmsg) 입력 플러그인은 Linux 커널 로그 버퍼를 처음부터 읽습니다. 모든 레코드를 가져와 priority, sequence, seconds, useconds, message 필드로 파싱합니다.

Configuration parameters

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

Key Description Default
prio_level The log level to filter. The kernel log is dropped if its priority is more than prio_level. Allowed values are 0-8. 8 means all logs are saved. 8
threaded Indicates whether to run this input in its own thread. false

시작하기

Linux 커널 메시지 수신을 시작하려면 명령줄에서 또는 구성 파일을 통해 플러그인을 실행할 수 있어요:

명령줄

fluent-bit -i kmsg -t kernel -o stdout -m '*'

다음과 유사한 출력이 반환됩니다:

...
[0] kernel: [1463421823, {"priority"=>3, "sequence"=>1814, "sec"=>11706, "usec"=>732233, "msg"=>"ERROR @wl_cfg80211_get_station : Wrong Mac address, mac = 34:a8:4e:d3:40:ec profile =20:3a:07:9e:4a:ac"}]
[1] kernel: [1463421823, {"priority"=>3, "sequence"=>1815, "sec"=>11706, "usec"=>732300, "msg"=>"ERROR @wl_cfg80211_get_station : Wrong Mac address, mac = 34:a8:4e:d3:40:ec profile =20:3a:07:9e:4a:ac"}]
[2] kernel: [1463421829, {"priority"=>3, "sequence"=>1816, "sec"=>11712, "usec"=>729728, "msg"=>"ERROR @wl_cfg80211_get_station : Wrong Mac address, mac = 34:a8:4e:d3:40:ec profile =20:3a:07:9e:4a:ac"}]
[3] kernel: [1463421829, {"priority"=>3, "sequence"=>1817, "sec"=>11712, "usec"=>729802, "msg"=>"ERROR @wl_cfg80211_get_station : Wrong Mac address, mac = 34:a8:4e:d3:40:ec
...

앞서 설명했듯이 플러그인은 Linux 커널이 보고한 모든 메시지를 처리했습니다. 명확성을 위해 출력은 잘렸습니다.

구성 파일

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

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

pipeline:
  inputs:
    - name: kmsg
      tag: kernel

  outputs:
    - name: stdout
      match: '*'

{% endtab %}

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

[INPUT]
  Name   kmsg
  Tag    kernel

[OUTPUT]
  Name   stdout
  Match  *

{% endtab %} {% endtabs %}

더 알아보기 (Learn more)