나의 잡다한 노트 및 메모

Promtail의 주요 설정 요소 본문

DevOps/Promtail

Promtail의 주요 설정 요소

peanutwalnut 2025. 3. 22. 15:08

promtail.yaml에 작성되는 내용을 의미하는 것이다. 

 

주요 설정 요소

a. scrape_configs

  • 어떤 로그 파일(혹은 소스)들을 어떻게 수집할지 정의하는 핵심 섹션입니다.
  • 예시:
scrape_configs:
  - job_name: system_logs
    static_configs:
      - targets: ['localhost']
        labels:
          job: system_logs
          __path__: /var/log/syslog

 

b. pipeline_stages

  • 수집한 로그 한 줄(Line)에 대해 추가 파이프라인 처리를 수행합니다.
  • regex로 라벨 추출, json 파싱, timestamp 추출, replace/drop 등 다양한 스테이지를 통해 로그를 가공할 수 있습니다.
pipeline_stages:
  - regex:
      expression: '^(?P<ts>[^ ]+) (?P<level>[^ ]+) (?P<msg>.*)'
  - labels:
      ts: timestamp
      level: severity
      msg: message
  - timestamp:
      source: ts
      format: RFC3339
  - drop:
      expression: '.*DEBUG.*'

 

c. relabel_configs

  • Prometheus의 relabeling과 같은 로직으로, 라벨들을 다시 가공(이름 변경, 값 치환, 제거 등)하는 스테이지입니다.
relabel_configs:
  - source_labels: ['__path__']
    target_label: 'source_file'
  - action: drop
    regex: '.*healthcheck.*'
    source_labels: ['line']

 

d. positions

  • Promtail이 마지막으로 읽은 위치를 저장하는 파일(기본 /tmp/positions.yaml).
  • 만약 Promtail이 재시작되면, 이 파일에서 위치를 읽어 이어서 로그를 수집합니다.

 

 

 

 

'DevOps > Promtail' 카테고리의 다른 글

Promtail의 중요한 디테일  (0) 2025.03.22
Promtail 이란?  (0) 2025.03.22