logstorage

package
v0.14.1 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package logstorage defines storage structure for logs storage.

Index

Constants

View Source
const (
	LabelTraceID  = "trace_id"
	LabelSpanID   = "span_id"
	LabelSeverity = "level"
	LabelBody     = "msg"

	LabelServiceName       = "service_name"        // resource.service.name
	LabelServiceNamespace  = "service_namespace"   // resource.service.namespace
	LabelServiceInstanceID = "service_instance_id" // resource.service.instance.id
)

Labels to use where prometheus compatible labels are required, e.g. loki.

Variables

This section is empty.

Functions

This section is empty.

Types

type Consumer

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

Consumer consumes given logs and inserts them using given Inserter.

func NewConsumer

func NewConsumer(i Inserter) *Consumer

NewConsumer creates new Consumer.

func (*Consumer) ConsumeLogs

func (c *Consumer) ConsumeLogs(ctx context.Context, logs plog.Logs) error

ConsumeLogs implements otelreceiver.Consumer.

type Inserter

type Inserter interface {
	// InsertRecords inserts given records.
	InsertRecords(ctx context.Context, records []Record) error
	// InsertLogLabels insert given set of labels to the storage.
	InsertLogLabels(ctx context.Context, labels map[Label]struct{}) error
}

Inserter is a log storage insert interface.

type Label

type Label struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

Label is a data structure for log label.

type LabelsOptions

type LabelsOptions struct {
	// Start defines time range for search.
	//
	// Querier ignores parameter, if it is zero.
	Start time.Time
	// End defines time range for search.
	//
	// Querier ignores parameter, if it is zero.
	End time.Time
	// Selector that selects the streams to match.
	Query logql.Selector
}

LabelsOptions defines options for [Querier.LabelNames] and [Querier.LabelValues] methods.

type Querier

type Querier interface {
	// LabelNames returns all available label names.
	LabelNames(ctx context.Context, opts LabelsOptions) ([]string, error)
	// LabelValues returns all available label values for given label.
	LabelValues(ctx context.Context, labelName string, opts LabelsOptions) (iterators.Iterator[Label], error)
	// Series returns all available log series.
	Series(ctx context.Context, opts SeriesOptions) (Series, error)
}

Querier is a logs storage query interface.

type Record

type Record struct {
	Timestamp         otelstorage.Timestamp `json:"timestamp"`
	ObservedTimestamp otelstorage.Timestamp `json:"observed_timestamp"`
	TraceID           otelstorage.TraceID   `json:"trace_id"`
	SpanID            otelstorage.SpanID    `json:"span_id"`
	Flags             plog.LogRecordFlags   `json:"flags"`
	SeverityText      string                `json:"severity_text"`
	SeverityNumber    plog.SeverityNumber   `json:"severity_number"`
	Body              string                `json:"body"`
	Attrs             otelstorage.Attrs     `json:"attrs"`

	ResourceAttrs otelstorage.Attrs `json:"resource_attrs"`

	ScopeName    string            `json:"scope_name"`
	ScopeVersion string            `json:"scope_version"`
	ScopeAttrs   otelstorage.Attrs `json:"scope_attrs"`
}

Record is a log record.

func NewRecordFromOTEL

func NewRecordFromOTEL(
	res pcommon.Resource,
	scope pcommon.InstrumentationScope,
	record plog.LogRecord,
) Record

NewRecordFromOTEL creates new Record.

type Series added in v0.13.0

type Series []map[string]string

Series defines a list of series.

type SeriesOptions added in v0.13.0

type SeriesOptions struct {
	// Start defines time range for search.
	//
	// Querier ignores parameter, if it is zero.
	Start time.Time
	// End defines time range for search.
	//
	// Querier ignores parameter, if it is zero.
	End time.Time
	// Selectors defines a list of matchers to filter series.
	Selectors []logql.Selector
}

SeriesOptions defines options for [Querier.Series] method.

Jump to

Keyboard shortcuts

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