JuliaLogging / LokiLogger.jl

Logger sink for sending log messages from Julia to Loki

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LokiLogger

Build Status

Julia client for the Grafana Loki log aggregation system.

Usage

If you are not familiar with the logging system in Julia I strongly recommend reading the documentation for the Logging stdlib, and the documentation for the LoggingExtras package.

LokiLogger provides a logging sink, i.e. an end of the logging chain, that pushes the log events to a Loki server. The only required argument is the Loki logger server URL. It is possible to configure the logger stream labels (see Loki documentation about labels), and the formatting of the log messages. Refer to the docstring for LokiLogger.Logger for more details. LokiLogger composes nicely with other loggers, in particular with the various loggers from LoggingExtras as seen in the examples below.

Examples

Basic logger with Loki server on localhost:

using LokiLogger

logger = LokiLogger.Logger("http://localhost:3100")

Logger with custom labels and JSON formatting:

using LokiLogger

logger = LokiLogger.Logger(LokiLogger.json, "http://localhost:3100";
                           labels=Dict("datacenter" => "eu-north", "app" => "my-app"))

Composing with LoggingExtras:

using LokiLogger, LoggingExtras

# Create a logger that passes messages to a Loki server running on localhost
logger = TeeLogger(
    global_logger(),
    LokiLogger.Logger("http://localhost:3100"),
)

Installation

Install the package using the package manager (] to enter pkg> mode):

(v1) pkg> add LokiLogger

About

Logger sink for sending log messages from Julia to Loki

License:MIT License


Languages

Language:Julia 100.0%