Loki Logging Plugin
The Loki Log plugin enables pushing logs to your Loki server.
Enterprise Feature
Custom logging is available as an add-on as part of an enterprise plan. If you would like to purchase this feature, please contact us at sales@zuplo.com or reach out to your account manager.
Most enterprise features can be used in a trial mode for a limited time. Feel free to use enterprise features for development and testing purposes.
Setup
To add the Loki logging plugin to your Zuplo project, add the following code to
your zuplo.runtime.ts
file.
modules/zuplo.runtime.ts(ts)
Configuration Options
The LokiLoggingPlugin
constructor accepts an options object with the following
properties:
url
- (required) The URL of the Loki server (e.g.,https://logs-prod-us-central1.grafana.net/loki/api/v1/push
)username
- (required) Username for authenticationpassword
- (required) Password for authenticationversion
- (optional) The version of the Loki transport to use. Version 2 includes tracing information in log valuesjob
- (optional) Job name to include in the log stream. Defaults to "zuplo"fields
- (optional) Custom fields to include in each log entry. Can contain string, number, or boolean values
Custom Fields
Any custom fields you want to include in the log entry can be added to the
fields
property. These values will be appended to every log entry.
Version Configuration
Setting the version
option to 2
changes the log stream to not include the
requestId
value in the stream, but rather include it as a log value with other
tracing information.
Default Fields
Every log entry will have a timestamp and structured data. The structure varies based on the version configuration.
Stream Labels (all versions)
job
- The name of the log stream job. Defaults to "zuplo"level
- The log level (e.g.,ERROR
,INFO
,DEBUG
,WARN
)environmentType
- Where the Zuplo API is running. Values areedge
,working-copy
, orlocal
environmentStage
- The deployment stage:working-copy
,preview
, orproduction
Log Fields (version 2+)
When using version 2 or later, the following fields are included in the log values:
requestId
- The UUID of the request (the value of thezp-rid
header)atomicCounter
- An atomic counter used to order logs with identical timestampsrayId
- The network provider identifier (e.g., Cloudflare Ray ID) of the request
Log trace fields are only included in the log values when the version
option
is set to 2
or later. In version 1, requestId
is included as a stream label.
Log Format
The shape of the logs sent from Zuplo will be in the following format. If using
version 2, tracing info (requestId
, etc.) will be included in the log values.
Code(json)