Skip to main content

tencent-cloud-cls

tencent-cloud-cls

Builds one access-log entry per request and hands it to a fire-and-forget batching sink; a background task POSTs batches to Tencent Cloud Log Service (CLS) at its /structuredlog upload endpoint, signed with the CLS/COS-style q-sign-algorithm=sha1 Authorization header. Place it in the response pipeline, after the upstream node. The node passes the context through unchanged and never fails.

Configuration

KeyTypeDefaultDescription
cls_hoststringCLS upload host, e.g. ap-guangzhou.cls.tencentcs.com. Alias endpoint. Required.
cls_topicstringDestination topic id, sent as the topic_id query parameter. Alias topic_id. Required.
secret_idstringAPI secret id. Required.
secret_keystringAPI secret key (used to sign each request). Required.
schemestringhttpshttp or https.
ssl_verifybooltrueVerify TLS certificates.
timeoutinteger (ms)10000Per-flush HTTP deadline.
global_tagobjectFields merged into every entry before batching.
include_req_bodyboolfalseInclude the request body in the default entry.
include_resp_bodyboolfalseInclude the response body in the default entry.
log_formatobjectCustom flat entry of name -> "$var template".
batch_max_sizeinteger1000Entries per batch before an immediate flush.
inactive_timeoutinteger (s)5Flush after this much idle time.
buffer_durationinteger (s)60Flush when the oldest buffered entry is this old.
max_retry_countinteger0Retries after a failed flush.
retry_delayinteger (s)1Delay between retries.
max_pending_entriesinteger10000Queue capacity; entries are dropped (with a warning) when full.
- id: cls-log
type: tencent-cloud-cls
config:
cls_host: ap-guangzhou.cls.tencentcs.com
cls_topic: xxxxxxxx-xxxx-xxxx
secret_id: ${CLS_SECRET_ID}
secret_key: ${CLS_SECRET_KEY}
scheme: https

Behavior

Each flush POSTs <scheme>://<cls_host>/structuredlog?topic_id=<cls_topic>. The signature follows the CLS scheme: sign_key = hex(hmac_sha1(secret_key, sign_time)), then signature = hex(hmac_sha1(sign_key, string_to_sign)), where string_to_sign = "sha1\n<sign_time>\n<sha1(http_request_info)>\n" and http_request_info = "post\n/structuredlog\n\n\n". Each entry is normalized into a list of {key, value} contents (non-string values JSON-encoded), grouped into one LogGroup. Response statuses 413/404/401/403 are non-retryable (the batch is dropped); other non-200 responses fail the batch and are retried per the batch settings.

Limitations

  • JSON body, not protobuf. The CLS SDK serializes the LogGroupList with protobuf and sends application/x-protobuf. featherbit has no protobuf codec, so it sends the equivalent structured-log payload as JSON (application/json). The signature, endpoint, topic query parameter, and log normalization are otherwise faithful. Against a live CLS endpoint the protobuf content type would be required; this is a documented subset.
  • source omitted. The SDK sets each LogGroup.source to the host IP; featherbit does not resolve its own IP and leaves it empty.

The signing helper and its primitives (SHA-1, HMAC-SHA1) are unit-tested against fixed vectors.