loki

package
v0.12.0-rc1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2022 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package loki provides a simple best-effort loki log ingestion client supporting batch sends. It is heavily based on https://github.com/grafana/loki/tree/main/clients/pkg/promtail/client.

It is best-effort, meaning it doesn't provide delivery guarantees, it will drop logs if loki isn't accessible. It is meant to be used in local dev environments or where log delivery isn't critical.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client for pushing logs in snappy-compressed protos over HTTP.

func New

func New(endpoint string, service string, logFunc logFunc) *Client

New returns a new Client.

func NewForT

func NewForT(endpoint string, service string, batchWait time.Duration, batchMax int) *Client

NewForT returns a new Client for testing.

func (*Client) Add

func (c *Client) Add(line string)

Add enqueues a line for sending to loki.

func (*Client) Run

func (c *Client) Run()

Run blocks until Stop is called.

  • It batches and sends logs to loki.
  • It sends logs every batchWait time.
  • Failed sends are retried.
  • Enqueue logs are dropped if BatchMax is reached.
  • It tries to send the last batch when Stop is called. It doesn't retry this batch.

func (*Client) Stop

func (c *Client) Stop(ctx context.Context)

Stop triggers graceful shutdown, it blocks until all enqueue logs have been sent or when the context is closed.

Directories

Path Synopsis
lokipb
v1

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL