Skip to main content

loki-logger

loki-logger

Builds a JSON access-log entry for each request/response and ships accumulated batches to a Grafana Loki push endpoint. Each batch is grouped into a single Loki stream carrying the configured labels, with one [nanosecond_timestamp, json_line] value per entry, and POSTed to <endpoint>/loki/api/v1/push. Place this node in the response pipeline, after the upstream node.

Configuration

KeyTypeDefaultDescription
endpoint_addrsarray— (required)Loki base addresses (e.g. http://loki:3100); one is chosen per flush. A single-string endpoint is also accepted.
endpoint_uristring/loki/api/v1/pushPush path appended to each base address.
tenant_idstringfakeSent as the X-Scope-OrgID header.
log_labelsobject{job: featherbit}Loki stream labels. labels is accepted as an alias.
headersobject{}Extra request headers.
ssl_verifyboolfalseVerify TLS certificates.
timeoutinteger (ms)3000Whole-call deadline per flush.
log_formatobjectCustom flat entry of name -> "$var template".
include_req_bodyboolfalseAdd the request body to the default entry.
include_resp_bodyboolfalseAdd the response body to the default entry.
batch_max_sizeinteger1000Flush when the buffer reaches this many entries.
inactive_timeoutinteger (s)5Flush after this idle period.
buffer_durationinteger (s)60Flush when the oldest buffered entry is this old.
max_retry_countinteger0Retries after a failed flush before dropping the batch.
retry_delayinteger (s)1Delay between retries.
max_pending_entriesinteger10000Queue capacity; entries are dropped with a warning when full.
- id: access-log
type: loki-logger
config:
endpoint_addrs: [http://loki:3100]
tenant_id: my-org
log_labels:
job: featherbit
env: prod
batch_max_size: 1000

Behavior

The node is a pure passthrough: it never modifies the context and never fails, so only its success port is ever taken. push is fire-and-forget and never blocks the request path — when the queue is full, entries are dropped with a tracing::warn!. Delivery, batching, timing, and retries all run on a background task. Note: label values are static (no per-request $var resolution), so a batch forms a single stream.