

# 일반적인 프로세서 사용 사례
<a name="processor-examples"></a>

다음은 프로세서 조합에 대한 일반적인 시나리오 및 구성 예제입니다.

**로그 파이프라인 예제**

**Example 로그 형식 표준화 및 메타데이터 추가**  
JSON 로그를 구문 분석하고, 필드 이름을 표준화하고, 환경 정보를 추가합니다.  

```
processor:
  - parse_json: {}
  - rename_keys:
      entries:
        - from_key: "timestamp"
          to_key: "@timestamp"
        - from_key: "log_level"
          to_key: "level"
  - add_entries:
      entries:
        - key: "environment"
          value: "production"
        - key: "application"
          value: "payment-service"
```

**Example 필드 값 정리 및 정규화**  
상태 코드를 표준화하고 민감한 데이터를 제거합니다.  

```
processor:
  - uppercase_string:
      with_keys: ["status", "method"]
  - delete_entries:
      with_keys: ["credit_card", "password"]
  - substitute_string:
      entries:
        - source: "status"
          from: "SUCCESS"
          to: "OK"
```

**Example 특정 필드 추출 및 변환**  
분석을 위한 사용자 정보 및 형식 추출:  

```
processor:
  - extract_value:
      entries:
        - source: "user_agent"
          target: "browser"
          from: "(?<browser>Chrome|Firefox|Safari)"
          to: "${browser}"
  - lowercase_string:
      with_keys: ["browser"]
  - move_keys:
      entries:
        - from_key: "browser"
          to_key: "user_data.browser"
```

**Example 항목 수준 조건을 사용한 조건부 처리**  
항목 수준 `when` 조건을 사용하여 로그 심각도를 기반으로 다른 메타데이터 추가:  

```
processor:
  - add_entries:
      entries:
        - key: "alert_level"
          value: "critical"
          when: "log.level == 'ERROR'"
        - key: "alert_level"
          value: "info"
          when_else: "log.level == 'ERROR'"
```

**Example 원치 않는 로그 항목 삭제**  
타사 소스에서 디버그 및 트레이스 로그 항목을 필터링하여 노이즈 및 스토리지 비용 절감:  

```
processor:
  - drop_events:
      when: "log.level in {'DEBUG', 'TRACE'}"
      handle_expression_failure: "skip"
```

**Example delete\_entries 포함 프로세서 수준 조건부**  
환경이 프로덕션인 경우에만 민감한 필드 제거:  

```
processor:
  - delete_entries:
      with_keys: ["password", "api_key", "ssn"]
      when: "environment in {'prod', 'staging'}"
```

## 지표 파이프라인 예제
<a name="metrics-processor-examples"></a>

다음 예제에서는 지표 파이프라인의 프로세서 구성을 보여줍니다. 지표 프로세서는 OTTL 경로 표현식을 사용하여 다양한 범위의 속성을 대상으로 지정합니다.

**Example 지표에 비즈니스 컨텍스트 추가**  
지표 데이터 포인트에 팀 소유권 및 환경 태그를 추가합니다.  

```
processor:
  - add_attributes:
      attributes:
        - key: resource.attributes["team"]
          value: "platform-engineering"
        - key: resource.attributes["cost_center"]
          value: "CC-1234"
```

**Example 카디널리티가 높은 속성 제거**  
스토리지 비용을 높이는 속성을 제거합니다. 누적 지표 또는 판매 지표에는 적용되지 않음 - 선택 기준의 지표에 지원되지 않는 시간성이 있는 경우 파이프라인은 `AWS/Observability Admin` 네임스페이스에서 모니터링할 수 있는 `UnsupportedTemporality` 경고 지표를 내보냅니다.  

```
processor:
  - delete_attributes:
      with_keys:
        - resource.attributes["host.id"]
        - datapoint.attributes["http.request.id"]
```

**Example 이름 지정 규칙 표준화**  
OpenTelemetry 시맨틱 규칙에 맞게 지표 및 속성의 이름을 변경합니다. 누적 지표 또는 판매 지표에는 적용되지 않습니다.  

```
processor:
  - rename_metrics:
      metrics:
        - from: "cpu_usage_percent"
          to: "system.cpu.utilization"
  - rename_attributes:
      attributes:
        - from_key: resource.attributes["hostname"]
          to_key: resource.attributes["host.name"]
```