loki

package module
v0.99.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 14 Imported by: 2

Documentation

Overview

Package loki provides translation helpers to convert between OTLP and Loki formats.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertEntryToLogRecord added in v0.76.1

func ConvertEntryToLogRecord(entry *push.Entry, lr *plog.LogRecord, labelSet model.LabelSet, keepTimestamp bool)

ConvertEntryToLogRecord converts loki log entry to otlp log record

func Encode

Encode converts an OTLP log record and its resource attributes into a JSON string representing a Loki entry. An error is returned when the record can't be marshaled into JSON.

func EncodeLogfmt added in v0.63.0

func EncodeLogfmt(lr plog.LogRecord, res pcommon.Resource, scope pcommon.InstrumentationScope) (string, error)

EncodeLogfmt converts an OTLP log record and its resource attributes into a logfmt string representing a Loki entry. An error is returned when the record can't be marshaled into logfmt.

func GetTenantFromTenantHint added in v0.75.0

func GetTenantFromTenantHint(logAttr pcommon.Map, resourceAttr pcommon.Map) string

GetTenantFromTenantHint extract an attribute based on the tenant hint. it looks up for the attribute first in resource attributes and fallbacks to record attributes if it is not found.

func LogsToLokiRequests added in v0.63.0

func LogsToLokiRequests(ld plog.Logs, defaultLabelsEnabled map[string]bool) map[string]PushRequest

LogsToLokiRequests converts a Logs pipeline data into Loki PushRequests grouped by tenant. The tenant value is inferred from the `loki.tenant` resource or log attribute hint. If the `loki.tenant` attribute is present in both resource or log attributes, then the resource attribute takes precedence. Labels for each record are inferred based on the hints "loki.attribute.labels" and "loki.resource.labels". Each hint might contain a comma-separated list of attributes (resource or record) that should be promoted to a Loki label. Those attributes are removed from the body as a result, otherwise they would be shown in duplicity in Loki. PushStreams are created based on the labels: all records containing the same set of labels are part of the same stream. All streams are then packed within the resulting PushRequest. When this function isn't able to marshal a log record, the log record is dropped and processing continues, so that the caller can decide to either skip the entire batch or send only the data that could be parsed. The caller can use the PushReport to make this decision, as it includes all of the errors that were encountered, as well as the number of items dropped and submitted.

func PushRequestToLogs added in v0.76.1

func PushRequestToLogs(pushRequest *push.PushRequest, keepTimestamp bool) (plog.Logs, error)

PushRequestToLogs converts loki push request to logs pipeline data

Types

type PushEntry added in v0.75.0

type PushEntry struct {
	Entry  *push.Entry
	Labels model.LabelSet
}

PushEntry is Loki log entry enriched with labels

func LogToLokiEntry added in v0.75.0

func LogToLokiEntry(lr plog.LogRecord, rl pcommon.Resource, scope pcommon.InstrumentationScope, defaultLabelsEnabled map[string]bool) (*PushEntry, error)

LogToLokiEntry converts LogRecord into Loki log entry enriched with normalized labels

type PushReport

type PushReport struct {
	Errors       []error
	NumSubmitted int
	NumDropped   int
}

PushReport contains the summary for the outcome of a LogsToLoki operation

type PushRequest added in v0.63.0

type PushRequest struct {
	*push.PushRequest
	Report *PushReport
}

Jump to

Keyboard shortcuts

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