Promtail Pipeline(로그 변환)
Pipeline
promtail 시작 시 discovery(or static) -> relabel -> pipeline 순으로 진행되며, pipeline이 무한 반복되면서 로그를 수집하게 됩니다.
pipeline에는 stage라는 단계가 있고, 선언된 순서로 실행됩니다. stage에서는 Parsing, Transform, Action, Filtering 작업을 수행합니다.
pipeline에서 사용할 수 있는 데이터는 다음과 같습니다.
- Labels
- discovery(or static) + relabel 단계에서 생성된 labels
- 앞선 stage에서 생성된 labels
- Extracted Map
- discovery(or static) + relabel 단계에서 생성된 labels
- 앞선 stage에서 생성된 key-value map
- timestamp
- log line
pipeline_stages:
- <stage>:
<option>: <value>
Parsing stage
cri
cri: {}
cri는 아래와 같은 작업을 수행합니다.
- regex:
expression: "^(?s)(?P<time>\\S+?) (?P<stream>stdout|stderr) (?P<flags>\\S+?) (?P<content>.*)$"
- labels:
stream:
- timestamp:
source: time
format: RFC3339Nano
- output:
source: content
multiline
multiline:
# https://github.com/google/re2/wiki/Syntax
firstline: <re2>
# https://pkg.go.dev/time#ParseDuration
max_wait_time: 3s
max_lines: 128