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

메트릭 셀렉터 (Metrics selector)

원문 보기 위키 갱신

metrics selector 프로세서는 로그를 위한 grep 필터와 비슷하게, 포함하거나 제외할 메트릭을 선택할 수 있게 해줘요.

출처: 문서

본문

Configuration parameters

metrics selector 프로세서는 다음 구성 파라미터를 지원해요.

Key Description Default
action 매칭되는 메트릭을 포함할지 제외할지 지정해요. 가능한 값: INCLUDE 또는 EXCLUDE. none
context 매칭 컨텍스트를 지정해요. 가능한 값: metric_name 또는 delete_label_value. metric_name
label 라벨 키와 값 쌍을 지정해요. none
metric_name 활성 매칭 연산에 따라 이 프로세서가 영향을 주는 메트릭을 결정하는 문자열이에요. none
operation_type metric_name의 값에 적용할 매칭 연산을 지정해요. 가능한 값: PREFIX 또는 SUBSTRING. none

Matching operations

metrics selector 프로세서에는 접두사 매칭과 부분 문자열(substring) 매칭이라는 두 가지 매칭 연산이 있어요.

Prefix matching

접두사 매칭은 metric_name의 값을 들어오는 각 메트릭 이름의 시작 부분과 비교해요. 예를 들어 fluentbit_input 값은 fluentbit_input_records라는 이름의 메트릭에는 매칭되지만, total_fluentbit_input이라는 이름의 메트릭에는 매칭되지 않아요.

operation_type 값을 지정하지 않고 metric_name의 값이 표준 문자열이라면, metrics selector 프로세서는 기본적으로 접두사 매칭을 사용해요.

Substring matching

부분 문자열 매칭은 metric_name의 값을 정규 표현식 패턴으로 취급하고 그 패턴을 들어오는 각 메트릭 이름에 맞춰 비교해요. 이 패턴은 들어오는 메트릭 이름 안 어디에나 나타날 수 있어요. 예를 들어 bytes 값은 bytes_total이라는 메트릭과 input_bytes_count라는 메트릭 모두에 매칭돼요.

metric_name의 값이 슬래시로 감싼 문자열(예: metric_name: /storage..*/)이라면, operation_type 값을 지정했는지와 관계없이 metrics selector 프로세서는 기본적으로 부분 문자열 매칭을 사용해요. 즉, 슬래시로 감싼 metric_name 값은 operation_type이 PREFIX로 설정돼 있더라도 항상 부분 문자열 매칭을 사용한다는 뜻이에요.

하지만 operation_type을 명시적으로 SUBSTRING으로 설정했다면 metric_name의 값을 슬래시로 감쌀 필요가 없어요.

Configuration examples

다음 예시들은 metrics selector 프로세서의 가능한 구성들을 보여줘요.

Without context

service:
  flush: 5
  daemon: off
  log_level: info

pipeline:
  inputs:
    - name: fluentbit_metrics
      tag: fluentbit.metrics
      scrape_interval: 10

      processors:
        metrics:
          - name: metrics_selector
            metric_name: /storage/
            action: include
       
          - name: metrics_selector
            metric_name: /fs/
            action: exclude

          - name: labels
            delete: name

  outputs:
    - name: stdout
      match: '*'

With context

service:
  flush: 5
  daemon: off
  log_level: info

pipeline:
  inputs:
    - name: fluentbit_metrics
      tag: fluentbit.metrics
      scrape_interval: 10

      processors:
        metrics:
          - name: metrics_selector
            context: delete_label_value
            label: name stdout.0

          - name: labels
            delete: name

  outputs:
    - name: stdout
      match: '*'

더 알아보기 (Learn more)