Skip to main content

Module loki_logger

Module loki_logger 

Source
Expand description

The loki-logger node — ships access logs to a Grafana Loki push API in batches.

Ports the APISIX loki-logger plugin onto featherbit’s shared BatchSink. Each request builds a log entry and hands it to the sink with a non-blocking push; a background task groups a batch into a single Loki stream (the configured labels) and POSTs the {streams:[{stream, values:[[ns_ts, line], ...]}]} payload to <endpoint>/loki/api/v1/push. The node never mutates the request/response and never fails, so it belongs in the response pipeline, after the upstream node.

Structs§

LokiLoggerFlusher 🔒
Delivers batches by POSTing the Loki streams payload to a push endpoint.
LokiLoggerPlugin
Batches access-log entries and POSTs them to a Grafana Loki push endpoint.

Functions§

build_loki_payload 🔒
Builds the Loki push payload: one stream carrying labels, with one [ns_timestamp, json_line] value per entry. Timestamps are the current wall-clock time in nanoseconds (as a decimal string, per the Loki API). Factored out of the network path for unit testing.
default_labels 🔒
parse_labels 🔒
Reads log_labels (or labels) as a string map, defaulting to {job: featherbit}.