Expand description
Tencent Cloud CLS (Cloud Log Service) access-logger (tencent-cloud-cls).
Ships access-log entries to Tencent Cloudβs Log Service. Each request builds
one log entry (the shared build_entry shape, or a custom log_format)
that is handed to a fire-and-forget BatchSink; a background task POSTs
batches to the CLS /structuredlog upload endpoint, signed with the
CLS/COS-style q-sign-algorithm=sha1 Authorization header.
The signature is ported faithfully from APISIXβs cls-sdk.lua sign():
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". See
https://cloud.tencent.com/document/product/614/12445.
Β§Deviations from APISIX
- JSON body, not protobuf. The CLS SDK serializes the
LogGroupListwith protobuf and sendsapplication/x-protobuf. featherbit has no protobuf codec, so it sends the equivalent structured-log payload as JSON (application/json): each entry is normalized to a list of{key, value}contents(non-string values JSON-encoded), grouped into oneLogGroup. 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 documented as a subset. sourceomitted. The SDK sets eachLogGroup.sourceto 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.
StructsΒ§
- ClsFlusher π
- Delivers batches to the CLS
/structuredlogendpoint. - Tencent
Cloud ClsPlugin - Node that batches access-log entries and ships them to Tencent Cloud CLS.
ConstantsΒ§
- AUTH_
EXPIRE_ πSECS - CLS_
API_ πPATH
FunctionsΒ§
- build_
log_ πpayload - Builds the CLS structured-log payload: one
LogGroupwhoselogscarry the normalized{key, value}contentsof each entry. Pure and network-free for testing. - hmac_
sha1_ πhex - Lowercase hex HMAC-SHA1 (
str_util.to_hex(ngx_hmac_sha1(key, msg))). - required_
string π - sha1_
hex π - Lowercase hex SHA-1 (
str_util.to_hex(ngx_sha1_bin(msg))). - sign π
- Builds the CLS
Authorizationheader value for the current time. Faithful port ofcls-sdk.luaβssign().cur_time(Unix seconds) is injected so the signature is unit-testable. - string_
alias π - stringify π
- CLS
content.valueis a string; keep strings as-is, JSON-encode the rest. - to_hex π