Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/julialogging/lokilogger.jl
Logger sink for sending log messages from Julia to Loki
https://github.com/julialogging/lokilogger.jl
grafana-loki julia logging
Last synced: 18 days ago
JSON representation
Logger sink for sending log messages from Julia to Loki
- Host: GitHub
- URL: https://github.com/julialogging/lokilogger.jl
- Owner: JuliaLogging
- License: mit
- Created: 2021-05-12T07:53:36.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-06-26T01:30:01.000Z (over 3 years ago)
- Last Synced: 2025-01-29T05:17:49.369Z (18 days ago)
- Topics: grafana-loki, julia, logging
- Language: Julia
- Homepage:
- Size: 6.84 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# LokiLogger
| **Build Status** |
|:--------------------------------------------------------------------- |
| [![][gh-actions-img]][gh-actions-url] [![][codecov-img]][codecov-url] |[Julia][julia-url] client for the [Grafana Loki][loki-url] 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][logging-url], and the
[documentation for the `LoggingExtras` package][logextras-url].`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][loki-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`:
```julia
using LokiLoggerlogger = LokiLogger.Logger("http://localhost:3100")
```Logger with custom labels and JSON formatting:
```julia
using LokiLoggerlogger = LokiLogger.Logger(LokiLogger.json, "http://localhost:3100";
labels=Dict("datacenter" => "eu-north", "app" => "my-app"))
```Composing with `LoggingExtras`:
```julia
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
```[gh-actions-img]: https://github.com/fredrikekre/LokiLogger.jl/workflows/CI/badge.svg
[gh-actions-url]: https://github.com/fredrikekre/LokiLogger.jl/actions?query=workflow%3ACI[codecov-img]: https://codecov.io/gh/fredrikekre/LokiLogger.jl/branch/master/graph/badge.svg
[codecov-url]: https://codecov.io/gh/fredrikekre/LokiLogger.jl[julia-url]: https://julialang.org
[loki-url]: https://grafana.com/oss/loki/
[loki-labels]: https://grafana.com/docs/loki/latest/getting-started/labels/
[logging-url]: https://docs.julialang.org/en/v1/stdlib/Logging/
[logextras-url]: https://github.com/oxinabox/LoggingExtras.jl/blob/master/README.md