Expect
레코드가 기대한 키와 값을 갖고 있는지 검증하고 싶을 때 쓰는 플러그인입니다. 함께 살펴볼게요.
출처: 문서
본문
예상한 키와 값을 레코드가 포함하는지 테스트하기
{% hint style="info" %}
Supported event types: logs
{% endhint %}
expect 필터 플러그인은 레코드가 구조상 특정 기준에 맞는지 검증하게 해 줍니다. 예를 들어 키가 존재하는지 또는 특정 값을 갖는지를 확인하는 거죠.
사용법과 사용 사례에 대한 자세한 설명은 Validating and your Data and Structure를 참고하세요.
Configuration parameters
플러그인은 다음 구성 파라미터를 지원합니다:
| Key | Description | Default |
|---|---|---|
action |
Action to take when a rule doesn't match. Available options are warn, exit or result_key. On warn, a warning message is sent to the logging layer for each record that fails a key* rule. Using exit makes Fluent Bit exit with status code 255. result_key adds a matching result to each record. For how each action treats a batch of records, see Batch behavior. |
warn |
key_exists |
Check if a key with a given name exists in the record. | none |
key_not_exists |
Check if a key doesn't exist in the record. | none |
key_val_eq |
Check that the value of the key equals the given value in the configuration. | none |
key_val_is_not_null |
Check that the value of the key is NOT NULL. |
none |
key_val_is_null |
Check that the value of the key is NULL. |
none |
result_key |
Specify a key name for the matching result added when action is set to result_key. |
matched |
Batch behavior
Fluent Bit는 레코드를 배치 단위로 필터에 전달합니다. expect 필터는 배치의 각 데이터 레코드를 규칙에 따라 평가하고, 구성된 action이 그다음에 무슨 일이 벌어질지 결정합니다. 배치 전체에 적용되는 두 가지 예외가 있습니다. exit는 규칙에 실패한 첫 번째 레코드에서 평가를 중지하고, result_key는 마커 레코드에 결과를 추가하지 않습니다.
warn: 규칙에 실패한 각 레코드는 자체적으로expect check failed경고를 기록합니다. 실패한 레코드가 여러 개인 배치는 여러 개의 경고를 만듭니다.exit: Fluent Bit는 규칙에 실패한 첫 번째 레코드에서 멈추고 상태 코드255로 종료합니다. 배치의 나머지 레코드는 평가되지 않습니다.result_key: 각 레코드는 자신만의 결과를 받습니다. 모든 규칙을 통과한 레코드는true로 표시되고, 어떤 규칙이라도 실패한 레코드는false로 표시됩니다. 따라서 하나의 실패 레코드가 같은 배치의 다른 레코드에 기록된 결과를 바꾸지 않아요.
OpenTelemetry 로그 같은 일부 이벤트 유형은 레코드 그룹을 구분 짓는 내부 마커 레코드를 포함합니다. expect 필터는 이런 마커를 변경 없이 통과시키고 결과 키를 추가하지 않습니다.