Skip to main content

sls-logger

sls-logger

Builds one access-log entry per request and hands it to a fire-and-forget batching sink; a background task POSTs batches to Alibaba Cloud Simple Log Service (SLS) using its signed PutLogs REST API. Place it in the response pipeline, after the upstream node. The node passes the context through unchanged and never fails.

Configuration

KeyTypeDefaultDescription
hoststringSLS endpoint, e.g. cn-hangzhou.log.aliyuncs.com. Required.
portintegerEndpoint port, e.g. 443. Required.
projectstringSLS project; prefixed to host as the request authority <project>.<host>. Required.
logstorestringDestination logstore. Required.
access_key_idstringRAM access-key id. Required.
access_key_secretstringRAM access-key secret (used to sign each request). Required.
timeoutinteger (ms)5000Per-flush HTTP deadline.
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: sls-log
type: sls-logger
config:
host: cn-hangzhou.log.aliyuncs.com
port: 443
project: my-project
logstore: gateway
access_key_id: ${SLS_KEY_ID}
access_key_secret: ${SLS_KEY_SECRET}

Behavior

Each flush POSTs https://<project>.<host>:<port>/logstores/<logstore>/shards/lb with a JSON body {"__topic__","__source__","__logs__":[…]}. SLS requires string log values, so non-string entry fields are JSON-encoded. The request is signed per the SLS spec: Content-MD5, Date, the sorted x-log-* canonical headers, and the canonical resource are HMAC-SHA1 signed with the access-key secret, base64-encoded, and sent as Authorization: LOG <access_key_id>:<signature>. A non-200 response fails the batch, which is retried per the batch settings.

Behavior notes

featherbit's shared logging infrastructure is HTTP-only — there is no raw TLS/TCP syslog delivery path to the SLS syslog ingress. This node targets the documented SLS PutLogs REST API:

  • The batch is POSTed as JSON to /logstores/<logstore>/shards/lb.
  • Requests are signed with the SLS HMAC-SHA1 Authorization: LOG <id>:<signature> scheme (with a self-contained MD5 for Content-MD5).

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