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

라벨 (Labels)

원문 보기 위키 갱신

labels 프로세서는 메트릭의 라벨을 조작할 수 있게 해 줘요.

필터와 유사하게, 이 프로세서는 라벨 조작을 위한 연산을 수행하는 강화/수정 메커니즘을 제시해요. 가장 큰 차이점은 프로세서가 필터보다 성능이 좋고, 프로세서를 체이닝해도 인코딩/디코딩 성능 저하가 없다는 점이에요.

참고 — 프로세서를 지원하는 것은 YAML 설정 파일뿐이에요.

출처: 문서

본문

구성 파라미터

Key Description
delete Deletes a key from the labels of metrics. The key/value pair is required. If the specified key doesn't exist, the operation silently fails and has no effect.
hash Replaces the key value with a hash generated by the SHA-256 algorithm from the specified label name. The generated binary value is set as a hex string.
insert Inserts a new key with a value into metrics. The key/value pair is required.
update Updates an existing key with a value into metrics. The key/value pair is required. If the specified key doesn't exist, the operation silently fails and has no effect.
upsert Upserts a specific key with a value, the upsert operation will try to update the value of the key. If the specified key doesn't exist, a new key will be created. The key/value pair is required.

Update 예시

다음 예시는 name 키의 값을 fluentbit로 바꿔요.

fluent-bit.yaml:

pipeline:
  inputs:
    - name: fluentbit_metrics

      processors:
        metrics:
          - name: labels
            update: name fluentbit

  outputs:
    - name : stdout
      match: '*'

Insert 예시

다음 예시는 agent 키를 값 fluentbit로 메트릭의 라벨로 추가해요.

fluent-bit.yaml:

pipeline:
  inputs:
    - name: fluentbit_metrics

      processors:
        metrics:
          - name: labels
            insert: agent fluentbit

  outputs:
    - name : stdout
      match: '*'

Upsert 예시

다음 예시는 name의 값을 upsert하고 fluentbit를 넣어요.

fluent-bit.yaml:

pipeline:
  inputs:
    - name: fluentbit_metrics

      processors:
        metrics:
          - name: labels
            upsert: name fluentbit

  outputs:
    - name : stdout
      match: '*'

Delete 예시

다음 예시는 메트릭에서 name 키를 제거해요.

fluent-bit.yaml:

pipeline:
  inputs:
    - name: fluentbit_metrics

      processors:
        metrics:
          - name: labels
            delete: name

  outputs:
    - name : stdout
      match: '*'

Hash 예시

다음 예시는 hostname 키의 값에 SHA-256 알고리즘을 적용해요.

fluent-bit.yaml:

pipeline:
  inputs:
    - name: fluentbit_metrics

      processors:
        metrics:
          - name: labels
            hash: hostname

  outputs:
    - name : stdout
      match: '*'

더 알아보기 (Learn more)