ArvanCloud CloudLogs 출력 플러그인
로그 레코드를 ArvanCloud CloudLogs 수집 API로 보내고 싶을 때 쓰는 출력 플러그인입니다. 함께 살펴보겠습니다.
출처: 문서
본문
ArvanCloud CloudLogs에 로그 보내기
{% hint style="info" %}
Supported event types: logs
{% endhint %}
ArvanCloud CloudLogs 출력 플러그인은 HTTPS를 통해 로그 레코드를 ArvanCloud CloudLogs 수집 API로 보냅니다.
Fluent Bit는 고정 엔드포인트 https://napi.arvancloud.ir/logging/v1/entries/write로 JSON 본문을 게시합니다. 각 Fluent Bit 레코드는 CloudLogs 항목 스키마로 감싸집니다. 인증은 Authorization 헤더에 apikey <value>로 보내는 API 키를 사용합니다.
이 플러그인은 Fluent Bit 5.1.3 이상 버전에서 사용할 수 있어요. 공식 빌드에 포함되어 있습니다. Fluent Bit를 소스에서 컴파일하면 FLB_OUT_ARVANCLOUD_CLOUDLOGS 빌드 옵션이 기본으로 활성화됩니다.
Configuration parameters
| Key | Description | Default |
|---|---|---|
apikey |
Required. API key used for authorization. Fluent Bit sends it as `Authorization: apikey *** | none |
gzip |
Enable gzip compression of the HTTP request body. If compression fails, Fluent Bit sends the uncompressed payload. | false |
include_tag_key |
When enabled, include the original Fluent Bit tag as an extra field on each CloudLogs entry. | false |
log_type |
Static logType value used when log_type_key isn't set, or when the record field referenced by log_type_key is missing or empty. |
fluentbit |
log_type_key |
Optional record accessor that selects a field from the record to use as logType. When the field exists and isn't empty, it takes priority over log_type. |
none |
tag_key |
Field name used for the Fluent Bit tag when include_tag_key is enabled. |
tag |
timestamp_key |
Optional record accessor that selects a record field to forward as the CloudLogs timestamp. The value is sent as-is. If the key is unset, or the field is missing or empty, Fluent Bit uses the event timestamp formatted as UTC RFC3339 with microseconds. |
none |
대상 호스트(napi.arvancloud.ir), 포트(443), URI(/logging/v1/entries/write), HTTPS 스킴은 플러그인에 고정되어 있습니다. 호스트, 포트, URI는 설정할 수 없어요.
Request payload
Fluent Bit는 플러시마다 하나의 JSON 객체를 만듭니다:
{
"logs": [
{
"logType": "fluentbit",
"timestamp": "2024-01-15T10:30:45.000000Z",
"severity": "INFO",
"resource": {
"type": "general"
},
"payload": {
"key": "value"
}
}
]
}
동작 참고 사항:
payload는 원본 레코드 맵을 변경 없이 포함합니다.severity는 항상INFO로 설정됩니다.resource는 항상{"type":"general"}로 설정됩니다.include_tag_key가 활성화되면 태그가tag_key를 사용해payload의 형제 필드로 추가됩니다.logType결정 순서는log_type_key(존재하고 비어 있지 않은 경우), 그다음log_type입니다.- 타임스탬프 결정:
timestamp_key가 설정되고 필드가 존재하며 비어 있지 않으면 필드 값을 그대로 전달합니다.- 그렇지 않으면 Fluent Bit 이벤트 타임스탬프를 UTC RFC3339 + 마이크로초로 형식화해 사용합니다 (예:
2024-01-15T10:30:45.000000Z).
타임스탬프 문자열을 이벤트 시간으로 파싱하려면 parser를 사용하세요.
HTTP response handling
| Status | Result |
|---|---|
200-205 |
Success (FLB_OK) |
400, 401, 403 |
Failure without retry (FLB_ERROR) |
429 |
Retry (FLB_RETRY) |
500 or greater |
Retry (FLB_RETRY) |
| Other HTTP client errors | Failure without retry (FLB_ERROR) |
| Connection or transport failure | Retry (FLB_RETRY) |
시작하기
최소 구성
apikey는 유일한 필수 옵션입니다:
{% tabs %} {% tab title="fluent-bit.yaml" %}
pipeline:
inputs:
- name: dummy
tag: app.logs
outputs:
- name: arvancloud_cloudlogs
match: '*'
apikey: ***
{% endtab %}
{% tab title="fluent-bit.conf" %}
[INPUT]
Name dummy
Tag app.logs
[OUTPUT]
Name arvancloud_cloudlogs
Match *
Apikey YOUR_API_KEY_HERE
{% endtab %} {% endtabs %}
전체 구성 예시
{% tabs %} {% tab title="fluent-bit.yaml" %}
pipeline:
inputs:
- name: dummy
tag: app.logs
dummy: '{"message":"hello","category":"security","ts":"2024-01-15T10:30:45.123456+01:00"}'
outputs:
- name: arvancloud_cloudlogs
match: '*'
apikey: ***
log_type: myapp
log_type_key: $category
timestamp_key: $ts
gzip: true
include_tag_key: true
tag_key: fluentbit_tag
{% endtab %}
{% tab title="fluent-bit.conf" %}
[INPUT]
Name dummy
Tag app.logs
Dummy {"message":"hello","category":"security","ts":"2024-01-15T10:30:45.123456+01:00"}
[OUTPUT]
Name arvancloud_cloudlogs
Match *
Apikey YOUR_API_KEY_HERE
Log_Type myapp
Log_Type_Key $category
Timestamp_Key $ts
Gzip true
Include_Tag_Key true
Tag_Key fluentbit_tag
{% endtab %} {% endtabs %}
이 예시를 통해 Fluent Bit는 $category(security)에서 logType을 유도하고, $ts를 CloudLogs 타임스탬프로 전달하며, 가능하면 gzip으로 요청 본문을 압축하고, fluentbit_tag 아래에 태그를 포함합니다.