Documentation
¶
Overview ¶
Package loki provides translation helpers to convert between OTLP and Loki formats.
Index ¶
- func ConvertEntryToLogRecord(entry *push.Entry, lr *plog.LogRecord, labelSet model.LabelSet, ...)
- func Encode(lr plog.LogRecord, res pcommon.Resource, scope pcommon.InstrumentationScope) (string, error)
- func EncodeLogfmt(lr plog.LogRecord, res pcommon.Resource, scope pcommon.InstrumentationScope) (string, error)
- func GetTenantFromTenantHint(logAttr pcommon.Map, resourceAttr pcommon.Map) string
- func LogsToLokiRequests(ld plog.Logs, defaultLabelsEnabled map[string]bool) map[string]PushRequest
- func PushRequestToLogs(pushRequest *push.PushRequest, keepTimestamp bool) (plog.Logs, error)
- type PushEntry
- type PushReport
- type PushRequest
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 ¶
func Encode(lr plog.LogRecord, res pcommon.Resource, scope pcommon.InstrumentationScope) (string, error)
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
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
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
PushRequestToLogs converts loki push request to logs pipeline data
Types ¶
type PushReport ¶
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 }