push

package
v3.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: AGPL-3.0 Imports: 35 Imported by: 1

Documentation

Index

Constants

View Source
const (
	OTLPSeverityNumber = "severity_number"
)

Variables

This section is empty.

Functions

func ParseRequest

func ParseRequest(logger log.Logger, userID string, r *http.Request, tenantsRetention TenantsRetention, limits Limits, pushRequestParser RequestParser, tracker UsageTracker) (*logproto.PushRequest, error)

func RetentionPeriodToString

func RetentionPeriodToString(retentionPeriod time.Duration) string

Types

type Action

type Action string

Action is the action to be performed on OTLP Resource Attribute.

const (
	// IndexLabel stores a Resource Attribute as a label in index to identify streams.
	IndexLabel Action = "index_label"
	// StructuredMetadata stores an Attribute as Structured Metadata with each log entry.
	StructuredMetadata Action = "structured_metadata"
	// Drop drops Attributes for which the Attribute name does match the regex.
	Drop Action = "drop"
)

type AttributesConfig

type AttributesConfig struct {
	Action     Action         `` /* 227-byte string literal not displayed */
	Attributes []string       `yaml:"attributes,omitempty" doc:"description=List of attributes to configure how to store them or drop them altogether"`
	Regex      relabel.Regexp `yaml:"regex,omitempty" doc:"description=Regex to choose attributes to configure how to store them or drop them altogether"`
}

func (*AttributesConfig) UnmarshalYAML

func (c *AttributesConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

type EmptyLimits

type EmptyLimits struct{}

func (EmptyLimits) OTLPConfig

func (EmptyLimits) OTLPConfig(string) OTLPConfig

type GlobalOTLPConfig

type GlobalOTLPConfig struct {
	DefaultOTLPResourceAttributesAsIndexLabels []string `yaml:"default_resource_attributes_as_index_labels"`
}

func (*GlobalOTLPConfig) RegisterFlags

func (cfg *GlobalOTLPConfig) RegisterFlags(fs *flag.FlagSet)

RegisterFlags registers distributor-related flags.

type Limits

type Limits interface {
	OTLPConfig(userID string) OTLPConfig
}

type OTLPConfig

type OTLPConfig struct {
	ResourceAttributes ResourceAttributesConfig `` /* 169-byte string literal not displayed */
	ScopeAttributes    []AttributesConfig       `` /* 147-byte string literal not displayed */
	LogAttributes      []AttributesConfig       `` /* 143-byte string literal not displayed */
}

func DefaultOTLPConfig

func DefaultOTLPConfig(cfg GlobalOTLPConfig) OTLPConfig

func (*OTLPConfig) ActionForLogAttribute

func (c *OTLPConfig) ActionForLogAttribute(attribute string) Action

func (*OTLPConfig) ActionForResourceAttribute

func (c *OTLPConfig) ActionForResourceAttribute(attribute string) Action

func (*OTLPConfig) ActionForScopeAttribute

func (c *OTLPConfig) ActionForScopeAttribute(attribute string) Action

func (*OTLPConfig) ApplyGlobalOTLPConfig

func (c *OTLPConfig) ApplyGlobalOTLPConfig(config GlobalOTLPConfig)

ApplyGlobalOTLPConfig applies global otlp config, specifically DefaultOTLPResourceAttributesAsIndexLabels for the start.

func (*OTLPConfig) Validate

func (c *OTLPConfig) Validate() error

type RequestParser

type RequestParser func(userID string, r *http.Request, tenantsRetention TenantsRetention, limits Limits, tracker UsageTracker) (*logproto.PushRequest, *Stats, error)

type RequestParserWrapper

type RequestParserWrapper func(inner RequestParser) RequestParser

type ResourceAttributesConfig

type ResourceAttributesConfig struct {
	IgnoreDefaults   bool               `` /* 281-byte string literal not displayed */
	AttributesConfig []AttributesConfig `yaml:"attributes_config,omitempty"`
}

type Stats

type Stats struct {
	Errs                            []error
	NumLines                        int64
	LogLinesBytes                   map[time.Duration]int64
	StructuredMetadataBytes         map[time.Duration]int64
	ResourceAndSourceMetadataLabels map[time.Duration]push.LabelsAdapter
	StreamLabelsSize                int64
	MostRecentEntryTimestamp        time.Time
	ContentType                     string
	ContentEncoding                 string

	BodySize int64
	// Extra is a place for a wrapped perser to record any interesting stats as key-value pairs to be logged
	Extra []any
}

func ParseLokiRequest

func ParseLokiRequest(userID string, r *http.Request, tenantsRetention TenantsRetention, _ Limits, tracker UsageTracker) (*logproto.PushRequest, *Stats, error)

func ParseOTLPRequest

func ParseOTLPRequest(userID string, r *http.Request, tenantsRetention TenantsRetention, limits Limits, tracker UsageTracker) (*logproto.PushRequest, *Stats, error)

type TenantsRetention

type TenantsRetention interface {
	RetentionPeriodFor(userID string, lbs labels.Labels) time.Duration
}

type UsageTracker

type UsageTracker interface {

	// ReceivedBytesAdd records ingested bytes by tenant, retention period and labels.
	ReceivedBytesAdd(ctx context.Context, tenant string, retentionPeriod time.Duration, labels labels.Labels, value float64)

	// DiscardedBytesAdd records discarded bytes by tenant and labels.
	DiscardedBytesAdd(ctx context.Context, tenant, reason string, labels labels.Labels, value float64)
}

Jump to

Keyboard shortcuts

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