Expand description
Alibaba Cloud SLS (Simple Log Service) access-logger (sls-logger).
Ships access-log entries to Alibaba 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 SLS PutLogs REST endpoint, signed with an HMAC-SHA1
Authorization: LOG <id>:<signature> header.
§Deviations from APISIX
APISIX’s sls-logger does not use the SLS HTTP REST API. It serializes
each entry into an RFC 5424 syslog frame (with the project, logstore, and
access keys embedded as syslog structured-data) and streams it over a raw
TLS/TCP socket to the SLS syslog ingress. featherbit has no TCP sink;
its shared infrastructure is HTTP-only. This port therefore targets the
documented SLS PutLogs REST API instead
(https://www.alibabacloud.com/help/en/sls/developer-reference/api-putlogs):
- The batch is POSTed as JSON
{"__topic__","__source__","__logs__":[…]}tohttps://<project>.<host>:<port>/logstores/<logstore>/shards/lb. - Requests are signed per the SLS spec:
Content-MD5,Date, the sortedx-log-*canonical headers, and the canonical resource are HMAC-SHA1 signed with the access-key secret, base64-encoded, and sent asAuthorization: LOG <access_key_id>:<signature>. - SLS requires string log values, so non-string entry fields are JSON-encoded (mirroring how the syslog path stringifies the entry).
The signing helper and its primitives (MD5, HMAC-SHA1) are unit-tested against fixed vectors; no end-to-end SLS handshake is exercised.
Structs§
- SlsFlusher 🔒
- Delivers batches to the SLS
PutLogsREST endpoint. - SlsLogger
Plugin - Node that batches access-log entries and ships them to Alibaba Cloud SLS.
Constants§
Functions§
- build_
logs_ 🔒payload - Builds the SLS
PutLogsJSON payload. Each entry becomes a log object of string values (non-string fields JSON-encoded) plus a__time__field. Pure and network-free for testing. - format_
http_ 🔒date - Formats a Unix timestamp (seconds) as an RFC 1123 GMT date, as SLS’s
Dateheader requires (e.g.Mon, 03 Jan 2022 04:05:06 GMT). - hmac_
sha1 🔒 - HMAC-SHA1 via ring, returning the raw 20-byte tag.
- md5 🔒
- Self-contained MD5 (RFC 1321). SLS requires a
Content-MD5header and the project has no MD5 dependency, so it is implemented here and unit-tested against the RFC vectors. - md5_
hex_ 🔒upper - Uppercase hex MD5 digest, as required for the SLS
Content-MD5header. - required_
string 🔒 - sign_
request 🔒 - Builds the SLS request signature and the headers it covers.
- stringify 🔒
- SLS log values must be strings; keep strings as-is, JSON-encode the rest.