Documentation
¶
Index ¶
- Constants
- Variables
- func BaseTemplateFuncs() template.FuncMap
- func Drain(ch chan []LogEntry)
- func EntryTemplateLabels(entry LogEntry) map[string]string
- func ExecuteLineFormatTemplate(tpl *template.Template, bind func(LogEntry), entry LogEntry) (string, error)
- func FloorDiv(a, b int64) int64
- func Gcd(a, b int64) int64
- func GetDuration(script any) (time.Duration, error)
- func GetOffset(script any) (time.Duration, error)
- func GetStrSelector(script any) *logql_parser.StrSelector
- func JsonPathParamToArray(param string) ([]string, error)
- func JsonPathParamToTypedArray(param string) ([]string, error)
- func PrepareLineFormatTemplate(templateStr string) (*template.Template, func(LogEntry), error)
- func TamePanic(out chan []LogEntry)
- type ClickhouseGetterPlanner
- func (c *ClickhouseGetterPlanner) IsMatrix() bool
- func (c *ClickhouseGetterPlanner) Process(ctx *PlannerContext, ch chan []LogEntry) (chan []LogEntry, error)
- func (c *ClickhouseGetterPlanner) Scan(ctx *PlannerContext, rows *sql.Rows, res chan []LogEntry)
- func (c *ClickhouseGetterPlanner) ScanMatrix(ctx *PlannerContext, rows *sql.Rows, res chan []LogEntry)
- type EvalGrid
- type GenericTraceRequestProcessor
- type LogEntry
- type NotSupportedError
- type PlannerContext
- type RandomFilter
- type RequestPlanner
- type RequestProcessor
- type RequestProcessorChain
- type SQLRequestPlanner
- type TraceRequestProcessor
Constants ¶
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__=""`).
const ( JSONParserErr = "JSONParserErr" LogfmtParserErr = "LogfmtParserErr" )
Values set in ErrorLabel, one per parser kind.
const SAMPLES_TYPE_BOTH = 0
const SAMPLES_TYPE_LOGS = 1
const SAMPLES_TYPE_METRICS = 2
Variables ¶
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 ¶
BaseTemplateFuncs returns the shared LogQL template functions used by line_format and label_format, excluding per-entry builtins such as __line__ and __timestamp__.
func Drain ¶ added in v5.5.5
func Drain(ch chan []LogEntry)
Drain discards whatever is left in ch in the background, so the goroutine feeding it can finish and release what it holds (e.g. a ClickHouse connection) once its consumer stops reading early.
func EntryTemplateLabels ¶
EntryTemplateLabels returns label values available to line_format templates.
func ExecuteLineFormatTemplate ¶
func ExecuteLineFormatTemplate(tpl *template.Template, bind func(LogEntry), entry LogEntry) (string, error)
ExecuteLineFormatTemplate renders a parsed template for a single log entry.
func FloorDiv ¶ added in v5.6.0
FloorDiv divides rounding toward negative infinity; b must be positive.
func GetOffset ¶ added in v5.6.0
GetOffset returns the offset of the script's range aggregation, 0 if none.
func GetStrSelector ¶
func GetStrSelector(script any) *logql_parser.StrSelector
func JsonPathParamToArray ¶
func PrepareLineFormatTemplate ¶
PrepareLineFormatTemplate parses a line_format/label_format template and returns a binder that must be called before each Execute with the current log entry.
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 EvalGrid ¶ added in v5.6.0
EvalGrid holds the evaluation times of a LogQL metric query: FirstNs + k*StepNs for k in [0, Points). StepNs is 0 for an instant query.
func NewEvalGrid ¶ added in v5.6.0
func NewEvalGrid(ctx *PlannerContext) (EvalGrid, error)
NewEvalGrid returns the grid of a request: To for an instant query, else epoch k*Step from From floored to To ceiled.
type GenericTraceRequestProcessor ¶
type GenericTraceRequestProcessor[T any] interface { Process(*PlannerContext) (chan []T, 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
// Instant marks an instant query, evaluated at To.
Instant bool
// Grid is the evaluation grid of a range aggregation on the Go path.
Grid *EvalGrid
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 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)
}