OpenTelemetry
OpenTelemetry 로그, 메트릭, 트레이스를 수집하는 입력 플러그인이에요.
지원 이벤트 유형:
logsmetricstraces
OpenTelemetry 입력 플러그인은 OpenTelemetry 명세에 기반한 데이터를 다양한 OpenTelemetry 익스포터, OpenTelemetry Collector, 또는 Fluent Bit OpenTelemetry 출력 플러그인으로부터 받을 수 있게 해 줘요.
Fluent Bit는 OTLP/HTTP와 OTLP/GRPC를 완전히 지원하는 호환 구현을 갖고 있어요. 기본값으로 설정되는 단일 port는 4318이며 두 전송 방식을 모두 지원해요.
출처: 문서
본문
구성
아래 표에는 다음이 모두 포함돼 있어요.
- OpenTelemetry 입력 플러그인에 특화된 설정
- 여러 HTTP 기반 입력에서 공유하는
http_server.*리스너 설정
공유 리스너 설정에 대한 플러그인 간 설명은 입력용 공유 HTTP 리스너 설정을 참고해요.
| Key | Description | Default |
|---|---|---|
alias |
Sets an alias for multiple instances of the same input plugin. If no alias is specified, a default name will be assigned using the plugin name followed by a dot and a sequence number. | none |
buffer_chunk_size |
Size of each buffer chunk allocated for HTTP requests (advanced users only). | 512K |
buffer_max_size |
Maximum size of the HTTP request buffer in KB, MB, or GB. |
4M |
encode_profiles_as_log |
Encode profiles received as text and ingest them in the logging pipeline. | true |
host |
The hostname. | localhost |
http2 |
Enable HTTP/2 protocol support for the OpenTelemetry receiver. | true |
http_server.max_connections |
Maximum number of concurrent active HTTP connections. 0 means unlimited. |
0 |
http_server.workers |
Number of HTTP listener worker threads. | 1 |
http_server.ingress_queue_event_limit |
Maximum number of deferred ingress queue entries. Applies only when http_server.workers is greater than 1. |
8192 |
http_server.ingress_queue_byte_limit |
Maximum size of the deferred ingress queue. Applies only when http_server.workers is greater than 1. |
256M |
listen |
The network address to listen on. | 0.0.0.0 |
log_level |
Specifies the log level for this plugin. If not set here, the plugin uses the global log level specified in the service section of your configuration file. |
info |
log_suppress_interval |
Suppresses log messages from this plugin that appear similar within a specified time interval. 0 no suppression. |
0 |
logs_body_key |
Specify a body key. | none |
logs_metadata_key |
Key name to store OpenTelemetry logs metadata in the record. | otlp |
mem_buf_limit |
Set a memory buffer limit for the input plugin. If the limit is reached, the plugin will pause until the buffer is drained. The value is in bytes. If set to 0, the buffer limit is disabled. | 0 |
net.accept_timeout |
Set maximum time allowed to establish an incoming connection. This time includes the TLS handshake. | 10s |
net.accept_timeout_log_error |
On client accept timeout, specify if it should log an error. When disabled, the timeout is logged as a debug message. | true |
net.backlog |
Set the backlog size for listening sockets. | 128 |
net.io_timeout |
Set maximum time a connection can stay idle. | 0s |
net.keepalive |
Enable or disable keepalive support. | true |
net.share_port |
Allow multiple plugins to bind to the same port. | false |
oauth2.allowed_audience |
Audience claim to enforce when validating incoming OAuth 2.0 JSON Web Token (JWT) tokens. |
none |
oauth2.allowed_clients |
Authorized client_id or azp claim values. Can be specified multiple times. |
none |
oauth2.issuer |
Expected issuer (iss) claim for OAuth 2.0 JWT validation. |
none |
oauth2.jwks_refresh_interval |
How often in seconds to refresh the cached JSON Web Key Set (JWKS) keys from oauth2.jwks_url. |
300 |
oauth2.jwks_url |
JWKS endpoint URL used to fetch public keys for OAuth 2.0 JWT validation. |
none |
oauth2.validate |
Enable OAuth 2.0 JWT validation for incoming requests. |
false |
port |
The port for Fluent Bit to listen for incoming connections. | 4318 |
profiles_support |
This is an experimental feature, feel free to test it but don't enable this in production environments. | false |
raw_traces |
Forward traces without processing. When set to false (default), traces are processed using the unified JSON parser with strict validation. When set to true, trace data is forwarded as raw log messages without validation or processing. |
false |
routable |
If set to true, the data generated by the plugin will be routable, meaning that it can be forwarded to other plugins or outputs. If set to false, the data will be discarded. |
true |
storage.pause_on_chunks_overlimit |
Enable pausing on an input when they reach their chunks limit. | none |
storage.type |
Sets the storage type for this input, one of: filesystem, memory or memrb. |
memory |
successful_response_code |
Allows for setting a successful response code. Supported values: 200, 201, or 204. |
201 |
tag |
Set a tag for the events generated by this input plugin. | none |
tag_from_uri |
If no explicit tag is set, the tag is created from the URI. For example, v1_metrics from /v1/metrics. When an explicit tag is configured, it takes precedence over the URI-derived tag regardless of this setting. |
true |
tag_key |
Record accessor key to use for generating tags from incoming records. | none |
thread.ring_buffer.capacity |
Number of slots in the ring buffer for data entries when running in threaded mode. Each slot can hold one data entry. | 1024 |
thread.ring_buffer.window |
Percentage threshold (1-100) of the ring buffer capacity at which a flush is triggered when running in threaded mode. | 5 |
threaded |
Enable multithreading for this input to run in a separate dedicated thread. | false |
tls |
Enable or disable TLS/SSL support. | off |
tls.ca_file |
Absolute path to CA certificate file. | none |
tls.ca_path |
Absolute path to scan for certificate files. | none |
tls.ciphers |
Specify TLS ciphers up to TLSv1.2. | none |
tls.crl_file |
Absolute path to a Certificate Revocation List (CRL) file in PEM format. When set, revoked certificates are rejected during TLS verification. Supported in v5.1.3 or later. | none |
tls.crt_file |
Absolute path to Certificate file. | none |
tls.debug |
Set TLS debug level. Accepts 0 (No debug), 1(Error), 2 (State change), 3 (Informational) and 4 (Verbose). |
1 |
tls.key_file |
Absolute path to private Key file. | none |
tls.key_passwd |
Optional password for tls.key_file file. | none |
tls.max_version |
Specify the maximum version of TLS. | none |
tls.min_version |
Specify the minimum version of TLS. | none |
tls.verify |
Force certificate validation. | on |
tls.verify_hostname |
Enable or disable to verify hostname. | off |
tls.vhost |
Hostname to be used for TLS SNI extension. | none |
http_server.ingress_queue_event_limit와 http_server.ingress_queue_byte_limit 설정은 http_server.workers가 1보다 클 때만 의미가 있어요.
raw_traces가 false(기본값)로 설정되면 trace 엔드포인트(/v1/traces)는 엄격한 검증과 함께 통합 JSON 파서를 사용해 들어오는 trace 데이터를 처리해요. 이 엔드포인트는 protobuf와 JSON으로 인코딩된 페이로드를 모두 받아들여요. raw_traces가 true로 설정되면 trace 엔드포인트로 전달되는 모든 데이터는 처리, 검증, Fluent Bit 내부 trace 형식으로의 변환 없이 하나의 로그 메시지로 패킹되어 전달돼요.
OpenTelemetry 전송 프로토콜 엔드포인트
Fluent Bit는 OpenTelemetry 프로토콜에 기반한 데이터 수집을 위해 다음 엔드포인트를 노출해요.
OTLP/HTTP의 경우:
- Logs
/v1/logs
- Metrics
/v1/metrics
- Traces
/v1/traces
OTLP/GRPC의 경우:
- Logs
/opentelemetry.proto.collector.log.v1.LogService/Export/opentelemetry.proto.collector.log.v1.LogService/Export
- Metrics
/opentelemetry.proto.collector.metric.v1.MetricService/Export/opentelemetry.proto.collector.metrics.v1.MetricsService/Export
- Traces
/opentelemetry.proto.collector.trace.v1.TraceService/Export/opentelemetry.proto.collector.traces.v1.TracesService/Export
시작하기 (Get started)
OpenTelemetry 입력 플러그인은 다음 텔레메트리 데이터 타입을 지원해요.
| Type | HTTP1/JSON | HTTP1/Protobuf | HTTP2/gRPC |
|---|---|---|---|
| Logs | Stable | Stable | Stable |
| Metrics | Stable | Stable | Stable |
| Traces | Stable | Stable | Stable |
시작하기 위한 샘플 설정 파일은 다음과 같이 보일 거예요.
fluent-bit.yaml:
pipeline:
inputs:
- name: opentelemetry
listen: 127.0.0.1
port: 4318
outputs:
- name: stdout
match: '*'
fluent-bit.conf:
[INPUT]
Name opentelemetry
Listen 127.0.0.1
Port 4318
[OUTPUT]
Name stdout
Match *
이 구성으로 Fluent Bit는 데이터를 위해 포트 4318에서 수신 대기해요. 이제 메트릭은 /v1/metrics, 트레이스는 /v1/traces, 로그는 /v1/logs 엔드포인트로 텔레메트리 데이터를 보낼 수 있어요.
JSON으로 인코딩된 로그 데이터를 POST하는 샘플 curl 요청은 다음과 같아요.
curl --header "Content-Type: application/json" --request POST --data '{"resourceLogs":[{"resource":{},"scopeLogs":[{"scope":{},"logRecords":[{"timeUnixNano":"1660296023390371588","body":{"stringValue":"{\"message\":\"dummy\"}"},"traceId":"","spanId":""}]}]}]}' http://0.0.0.0:4318/v1/logs
OpenTelemetry trace 개선 사항
Fluent Bit에는 향상된 JSON 파싱, 오류 처리, 검증 기능을 갖춘 OpenTelemetry trace 지원이 포함돼 있어요.
통합 trace JSON 파서
Fluent Bit는 JSON 형식의 OpenTelemetry trace 데이터를 처리하기 위한 통합 인터페이스를 제공해요. 이 파서는 OpenTelemetry JSON trace 페이로드를 Fluent Bit 내부 trace 표현으로 변환하며, 다음을 포함한 전체 OpenTelemetry trace 명세를 지원해요.
- 속성을 가진 리소스 스팬(Resource spans)
- 계측 스코프(Instrumentation scope) 정보
- 스팬 데이터(이름, ID, 타임스탬프, 상태)
- 스팬 이벤트와 링크
- Trace와 span ID 검증
통합 파서는 OpenTelemetry JSON 인코딩 형식을 처리하는데, 이 형식은 속성 값을 타입별 컨테이너(예: stringValue, intValue, doubleValue, boolValue)로 감싸요.
오류 상태 전파
OpenTelemetry 입력 플러그인은 trace 데이터를 처리할 때 자세한 오류 상태 정보를 제공해요. trace 처리가 실패하면 플러그인은 문제를 식별하는 데 도움이 되는 특정 오류 코드를 반환해요.
FLB_OTEL_TRACES_ERR_INVALID_JSON- Invalid JSON formatFLB_OTEL_TRACES_ERR_INVALID_TRACE_ID- Invalid trace ID format or lengthFLB_OTEL_TRACES_ERR_INVALID_SPAN_ID- Invalid span ID format or lengthFLB_OTEL_TRACES_ERR_INVALID_PARENT_SPAN_ID- Invalid parent span IDFLB_OTEL_TRACES_ERR_STATUS_FAILURE- Invalid span status codeFLB_OTEL_TRACES_ERR_INVALID_ATTRIBUTES- Invalid attribute formatFLB_OTEL_TRACES_ERR_INVALID_EVENT_ENTRY- Invalid span eventFLB_OTEL_TRACES_ERR_INVALID_LINK_ENTRY- Invalid span link
유효한 span 상태 코드
OpenTelemetry 명세는 세 개의 유효한 span 상태 코드를 정의해요. 플러그인은 trace 데이터를 처리할 때 다음 상태 코드 값을 허용해요(대소문자 무시).
OK- The operation completed successfullyERROR- The operation has an errorUNSET- The status isn't set (default)
다른 상태 코드 값은 FLB_OTEL_TRACES_ERR_STATUS_FAILURE를 트리거하고 trace 데이터가 거부돼요. 상태 코드는 span 객체의 status.code 필드에 문자열로 제공되어야 해요.
오류 처리 동작
trace 검증이 실패하면 다음 동작이 적용돼요.
- Trace 데이터는 폐기됨: 잘못된 trace 데이터는 처리되거나 전달되지 않아요. trace 페이로드는 즉시 거부돼요.
- 오류 로깅: 플러그인은 진단에 도움이 되도록 특정 오류 상태 코드가 포함된 오류 메시지를 기록해요. 오류 메시지에는 오류 코드 번호와 설명이 포함돼요.
- 재시도 메커니즘 없음: 실패한 요청은 자동으로 재시도되지 않아요. 클라이언트가 수정된 trace 데이터를 다시 보내야 해요.
- HTTP 응답 코드:
- HTTP/1.1: 검증 실패 시 오류 메시지와 함께
400 Bad Request를 반환해요. 처리가 성공하면 구성된successful_response_code(기본값201 Created)를 반환해요. - gRPC: 검증 실패 시 "Serialization error." 메시지와 함께 gRPC 상태
2 (UNKNOWN)를 반환해요. 처리가 성공하면 빈ExportTraceServiceResponse와 함께 gRPC 상태0 (OK)를 반환해요.
- HTTP/1.1: 검증 실패 시 오류 메시지와 함께
엄격한 ID 디코딩
Fluent Bit는 데이터 무결성을 보장하기 위해 trace와 span ID에 대해 엄격한 검증을 적용해요.
- Trace IDs: 정확히 32개의 16진수 문자(16바이트)여야 함
- Span IDs: 정확히 16개의 16진수 문자(8바이트)여야 함
- Parent Span IDs: 존재할 경우 정확히 16개의 16진수 문자(8바이트)여야 함
검증 과정은 다음과 같아요.
- ID 길이가 예상 크기와 일치하는지 확인
- 모든 문자가 유효한 16진수 숫자(0-9, a-f, A-F)인지 검증
- 16진수 문자열을 이진 형식으로 디코딩
- 잘못된 ID를 적절한 오류 코드로 거부
잘못된 ID는 오류 상태 코드(FLB_OTEL_TRACES_ERR_INVALID_TRACE_ID, FLB_OTEL_TRACES_ERR_INVALID_SPAN_ID 등)를 발생시키고, 손상되거나 잘못된 형식의 trace 정보가 처리되는 것을 방지하기 위해 trace 데이터가 거부돼요.
예시: JSON trace 페이로드
다음 예시는 /v1/traces 엔드포인트로 보낼 수 있는 유효한 OpenTelemetry JSON trace 페이로드를 보여 줘요.
{
"resourceSpans": [
{
"resource": {
"attributes": [
{
"key": "service.name",
"value": {
"stringValue": "my-service"
}
}
]
},
"scopeSpans": [
{
"scope": {
"name": "my-instrumentation",
"version": "1.0.0"
},
"spans": [
{
"traceId": "0123456789abcdef0123456789abcdef",
"spanId": "0123456789abcdef",
"name": "my-span",
"kind": 1,
"startTimeUnixNano": "1660296023390371588",
"endTimeUnixNano": "1660296023391371588",
"status": {
"code": "OK"
},
"attributes": [
{
"key": "http.method",
"value": {
"stringValue": "GET"
}
}
]
}
]
}
]
}
]
}
Trace ID는 정확히 32개의 16진수 문자여야 하고 span ID는 정확히 16개의 16진수 문자여야 해요. 잘못된 ID는 적절한 오류 메시지와 함께 거부돼요.
예시에서 status.code 필드는 "OK"를 사용해요. 유효한 상태 코드 값은 "OK", "ERROR", "UNSET"(대소문자 무시)이에요. 다른 값은 FLB_OTEL_TRACES_ERR_STATUS_FAILURE를 트리거하고 trace가 거부돼요.