https://github.com/oliverschlueter/sloki
A slog handler which sends logs to Loki
https://github.com/oliverschlueter/sloki
go logging loki slog structured-logging
Last synced: about 1 year ago
JSON representation
A slog handler which sends logs to Loki
- Host: GitHub
- URL: https://github.com/oliverschlueter/sloki
- Owner: OliverSchlueter
- Created: 2025-04-05T19:21:46.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-07T18:30:47.000Z (about 1 year ago)
- Last Synced: 2025-04-10T00:05:56.711Z (about 1 year ago)
- Topics: go, logging, loki, slog, structured-logging
- Language: Go
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Sloki
A slog handler (for GoLang) which sends logs to Loki.
You can find a docker-compose file to run Loki and Grafana in the [loki_docker](loki_docker) directory. There is also an example dashboard for Grafana.
## Installation
```bash
go get github.com/OliverSchlueter/sloki
```
## Usage
```go
package main
import (
"github.com/OliverSchlueter/sloki/sloki"
"log/slog"
)
func main() {
logger := sloki.NewService(sloki.Configuration{
URL: "http://localhost:3100/loki/api/v1/push",
Service: "my-service",
ConsoleLevel: slog.LevelDebug,
LokiLevel: slog.LevelInfo,
})
slog.SetDefault(slog.New(logger))
}
```