shared

package
v4.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorLabel        = "__error__"
	ErrorDetailsLabel = "__error_details__"
)

Synthetic labels injected onto a log entry when a parser stage fails to process its line, mirroring Loki's behavior. They are ordinary labels and so are filterable with the usual label filters (e.g. `| __error__=""`).

View Source
const (
	JSONParserErr   = "JSONParserErr"
	LogfmtParserErr = "LogfmtParserErr"
)

Values set in ErrorLabel, one per parser kind.

View Source
const SAMPLES_TYPE_BOTH = 0
View Source
const SAMPLES_TYPE_LOGS = 1
View Source
const SAMPLES_TYPE_METRICS = 2

Variables

View Source
var ParserErrorType = map[string]string{
	"json":   JSONParserErr,
	"logfmt": LogfmtParserErr,
}

ParserErrorType maps a parser op name to the ErrorLabel value it emits on failure. Parsers absent from the map (e.g. regexp) do not flag runtime errors.

Functions

func BaseTemplateFuncs added in v4.3.0

func BaseTemplateFuncs() template.FuncMap

BaseTemplateFuncs returns the shared LogQL template functions used by line_format and label_format, excluding per-entry builtins such as __line__ and __timestamp__.

func EntryTemplateLabels added in v4.3.0

func EntryTemplateLabels(entry LogEntry) map[string]string

EntryTemplateLabels returns label values available to line_format templates.

func ExecuteLineFormatTemplate added in v4.3.0

func ExecuteLineFormatTemplate(tpl *template.Template, bind func(LogEntry), entry LogEntry) (string, error)

ExecuteLineFormatTemplate renders a parsed template for a single log entry.

func GetDuration

func GetDuration(script any) (time.Duration, error)

func GetStrSelector

func GetStrSelector(script any) *logql_parser.StrSelector

func JsonPathParamToArray

func JsonPathParamToArray(param string) ([]string, error)

func JsonPathParamToTypedArray

func JsonPathParamToTypedArray(param string) ([]string, error)

func PrepareLineFormatTemplate added in v4.3.0

func PrepareLineFormatTemplate(templateStr string) (*template.Template, func(LogEntry), error)

PrepareLineFormatTemplate parses a line_format/label_format template and returns a binder that must be called before each Execute with the current log entry.

func TamePanic

func TamePanic(out chan []LogEntry)

Types

type ClickhouseGetterPlanner

type ClickhouseGetterPlanner struct {
	ClickhouseRequestPlanner SQLRequestPlanner
	Matrix                   bool
}

func (*ClickhouseGetterPlanner) IsMatrix

func (c *ClickhouseGetterPlanner) IsMatrix() bool

func (*ClickhouseGetterPlanner) Process

func (c *ClickhouseGetterPlanner) Process(ctx *PlannerContext,
	ch chan []LogEntry) (chan []LogEntry, error)

func (*ClickhouseGetterPlanner) Scan

func (c *ClickhouseGetterPlanner) Scan(ctx *PlannerContext, rows *sql.Rows, res chan []LogEntry)

func (*ClickhouseGetterPlanner) ScanMatrix

func (c *ClickhouseGetterPlanner) ScanMatrix(ctx *PlannerContext, rows *sql.Rows, res chan []LogEntry)

type GenericTraceRequestProcessor

type GenericTraceRequestProcessor[T any] interface {
	Process(*PlannerContext) (chan []T, error)
}

type LogEntry

type LogEntry struct {
	TimestampNS int64
	Fingerprint uint64
	Labels      map[string]string
	Message     string
	Value       float64

	Err error
}

type NotSupportedError

type NotSupportedError struct {
	Msg string
}

func (*NotSupportedError) Error

func (n *NotSupportedError) Error() string

type PlannerContext

type PlannerContext struct {
	IsCluster bool
	From      time.Time
	To        time.Time
	OrderASC  bool
	Limit     int64
	Offset    time.Duration

	TimeSeriesGinTableName     string
	TimeSeriesGinDistTableName string
	SamplesTableName           string
	SamplesDistTableName       string
	TimeSeriesTableName        string
	TimeSeriesDistTableName    string
	Metrics15sTableName        string
	Metrics15sDistTableName    string
	PatternsTable              string

	TracesAttrsTable     string
	TracesAttrsDistTable string
	TracesTable          string
	TracesDistTable      string
	TracesKVTable        string
	TracesKVDistTable    string

	ProfilesSeriesGinTable     string
	ProfilesSeriesGinDistTable string
	ProfilesTable              string
	ProfilesDistTable          string
	ProfilesSeriesTable        string
	ProfilesSeriesDistTable    string
	PatternsDistTable          string

	UseCache bool

	Ctx context.Context

	CHDb       model.ISqlxDB
	CHFinalize bool
	CHSqlCtx   *sql.Ctx

	DDBSamplesTable string
	DDBTSTable      string

	CancelCtx context.CancelFunc

	Step time.Duration

	DeleteID string

	Type uint8

	RandomFilter   RandomFilter
	CachedTraceIds []string
	VersionInfo    dbversion.VersionInfo

	// TracesIntrinsicWhere holds extra WHERE conditions for the tempo_traces table
	// (e.g., nestedSetParent < 0 → parent_id = ”).
	TracesIntrinsicWhere []sql.SQLCondition
	// contains filtered or unexported fields
}

func (*PlannerContext) Id

func (p *PlannerContext) Id() int

type RandomFilter

type RandomFilter struct {
	Max int
	I   int
}

type RequestPlanner

type RequestPlanner interface {
	Process(cnain RequestProcessorChain) (RequestProcessorChain, error)
}

type RequestProcessor

type RequestProcessor interface {
	IsMatrix() bool
	Process(*PlannerContext, chan []LogEntry) (chan []LogEntry, error)
}

type RequestProcessorChain

type RequestProcessorChain []RequestProcessor

type SQLRequestPlanner

type SQLRequestPlanner interface {
	Process(ctx *PlannerContext) (sql.ISelect, error)
}

type TraceRequestProcessor

type TraceRequestProcessor interface {
	Process(*PlannerContext) (chan []model.TraceInfo, error)
}

Jump to

Keyboard shortcuts

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