Documentation ¶
Index ¶
- Constants
- Variables
- type BinaryLabelFilter
- type BytesLabelFilter
- type DurationLabelFilter
- type Filterer
- type FiltererFunc
- type JSONParser
- type LabelFilterType
- type LabelFilterer
- type LabelFmt
- type LabelsBuilder
- func (b *LabelsBuilder) Base() labels.Labels
- func (b *LabelsBuilder) Del(ns ...string) *LabelsBuilder
- func (b *LabelsBuilder) Get(key string) (string, bool)
- func (b *LabelsBuilder) GetErr() string
- func (b *LabelsBuilder) HasErr() bool
- func (b *LabelsBuilder) Labels() labels.Labels
- func (b *LabelsBuilder) Reset(base labels.Labels)
- func (b *LabelsBuilder) Set(n, v string) *LabelsBuilder
- func (b *LabelsBuilder) SetErr(err string) *LabelsBuilder
- func (b *LabelsBuilder) WithLabels(names ...string) labels.Labels
- func (b *LabelsBuilder) WithoutLabels(names ...string) labels.Labels
- type LabelsFormatter
- type LineExtractor
- type LineFormatter
- type LogfmtParser
- type NumericLabelFilter
- type Pipeline
- type RegexpParser
- type SampleExtractor
- type SampleExtractorFunc
- type Stage
- type StageFunc
- type StringLabelFilter
Constants ¶
const ( ConvertDuration = "duration" ConvertFloat = "float" )
Variables ¶
var ( NoopPipeline Pipeline = &noopPipeline{} NoopStage Stage = &noopStage{} )
var (
ErrorLabel = "__error__"
)
var (
// NoopLabelFilter is a label filter that doesn't filter out any values.
NoopLabelFilter = noopLabelFilter{}
)
var TrueFilter = trueFilter{}
TrueFilter is a filter that returns and matches all log lines whatever their content.
Functions ¶
This section is empty.
Types ¶
type BinaryLabelFilter ¶
type BinaryLabelFilter struct { Left LabelFilterer Right LabelFilterer // contains filtered or unexported fields }
func NewAndLabelFilter ¶
func NewAndLabelFilter(left LabelFilterer, right LabelFilterer) *BinaryLabelFilter
NewAndLabelFilter creates a new LabelFilterer from a and binary operation of two LabelFilterer.
func NewOrLabelFilter ¶
func NewOrLabelFilter(left LabelFilterer, right LabelFilterer) *BinaryLabelFilter
NewOrLabelFilter creates a new LabelFilterer from a or binary operation of two LabelFilterer.
func (*BinaryLabelFilter) Process ¶
func (b *BinaryLabelFilter) Process(line []byte, lbs *LabelsBuilder) ([]byte, bool)
func (*BinaryLabelFilter) String ¶
func (b *BinaryLabelFilter) String() string
type BytesLabelFilter ¶
type BytesLabelFilter struct { Name string Value uint64 Type LabelFilterType }
func NewBytesLabelFilter ¶
func NewBytesLabelFilter(t LabelFilterType, name string, b uint64) *BytesLabelFilter
NewBytesLabelFilter creates a new label filterer which parses bytes string representation (1KB) from the value of the named label and compares it with the given b value.
func (*BytesLabelFilter) Process ¶
func (d *BytesLabelFilter) Process(line []byte, lbs *LabelsBuilder) ([]byte, bool)
func (*BytesLabelFilter) String ¶
func (d *BytesLabelFilter) String() string
type DurationLabelFilter ¶
type DurationLabelFilter struct { Name string Value time.Duration Type LabelFilterType }
func NewDurationLabelFilter ¶
func NewDurationLabelFilter(t LabelFilterType, name string, d time.Duration) *DurationLabelFilter
NewDurationLabelFilter creates a new label filterer which parses duration string representation (5s) from the value of the named label and compares it with the given d value.
func (*DurationLabelFilter) Process ¶
func (d *DurationLabelFilter) Process(line []byte, lbs *LabelsBuilder) ([]byte, bool)
func (*DurationLabelFilter) String ¶
func (d *DurationLabelFilter) String() string
type Filterer ¶
Filterer is a interface to filter log lines.
func NewAndFilter ¶
NewAndFilter creates a new filter which matches only if left and right matches.
type FiltererFunc ¶
LineFilterFunc is a syntax sugar for creating line filter from a function
func (FiltererFunc) Filter ¶
func (f FiltererFunc) Filter(line []byte) bool
type JSONParser ¶
type JSONParser struct{}
func NewJSONParser ¶
func NewJSONParser() *JSONParser
NewJSONParser creates a log stage that can parse a json log line and add properties as labels.
func (*JSONParser) Process ¶
func (j *JSONParser) Process(line []byte, lbs *LabelsBuilder) ([]byte, bool)
type LabelFilterType ¶
type LabelFilterType int
LabelFilterType is an enum for label filtering types.
const ( LabelFilterEqual LabelFilterType = iota LabelFilterNotEqual LabelFilterGreaterThan LabelFilterGreaterThanOrEqual LabelFilterLesserThan LabelFilterLesserThanOrEqual )
Possible LabelFilterType.
func (LabelFilterType) String ¶
func (f LabelFilterType) String() string
type LabelFilterer ¶
LabelFilterer can filter extracted labels.
func ReduceAndLabelFilter ¶
func ReduceAndLabelFilter(filters []LabelFilterer) LabelFilterer
ReduceAndLabelFilter Reduces multiple label filterer into one using binary and operation.
type LabelFmt ¶
LabelFmt is a configuration struct for formatting a label.
func NewRenameLabelFmt ¶
NewRenameLabelFmt creates a configuration to rename a label.
func NewTemplateLabelFmt ¶
NewTemplateLabelFmt creates a configuration to format a label using text template.
type LabelsBuilder ¶
type LabelsBuilder struct {
// contains filtered or unexported fields
}
LabelsBuilder is the same as labels.Builder but tailored for this package.
func NewLabelsBuilder ¶
func NewLabelsBuilder() *LabelsBuilder
NewLabelsBuilder creates a new labels builder.
func (*LabelsBuilder) Base ¶
func (b *LabelsBuilder) Base() labels.Labels
Base returns the base labels unmodified
func (*LabelsBuilder) Del ¶
func (b *LabelsBuilder) Del(ns ...string) *LabelsBuilder
Del deletes the label of the given name.
func (*LabelsBuilder) GetErr ¶
func (b *LabelsBuilder) GetErr() string
GetErr return the current error label value.
func (*LabelsBuilder) HasErr ¶
func (b *LabelsBuilder) HasErr() bool
HasErr tells if the error label has been set.
func (*LabelsBuilder) Labels ¶
func (b *LabelsBuilder) Labels() labels.Labels
Labels returns the labels from the builder. If no modifications were made, the original labels are returned.
func (*LabelsBuilder) Reset ¶
func (b *LabelsBuilder) Reset(base labels.Labels)
Reset clears all current state for the builder.
func (*LabelsBuilder) Set ¶
func (b *LabelsBuilder) Set(n, v string) *LabelsBuilder
Set the name/value pair as a label.
func (*LabelsBuilder) SetErr ¶
func (b *LabelsBuilder) SetErr(err string) *LabelsBuilder
SetErr sets the error label.
func (*LabelsBuilder) WithLabels ¶
func (b *LabelsBuilder) WithLabels(names ...string) labels.Labels
func (*LabelsBuilder) WithoutLabels ¶
func (b *LabelsBuilder) WithoutLabels(names ...string) labels.Labels
type LabelsFormatter ¶
type LabelsFormatter struct {
// contains filtered or unexported fields
}
func NewLabelsFormatter ¶
func NewLabelsFormatter(fmts []LabelFmt) (*LabelsFormatter, error)
NewLabelsFormatter creates a new formatter that can format multiple labels at once. Either by renaming or using text template. It is not allowed to reformat the same label twice within the same formatter.
func (*LabelsFormatter) Process ¶
func (lf *LabelsFormatter) Process(l []byte, lbs *LabelsBuilder) ([]byte, bool)
type LineExtractor ¶
LineExtractor extracts a float64 from a log line.
var ( CountExtractor LineExtractor = func(line []byte) float64 { return 1. } BytesExtractor LineExtractor = func(line []byte) float64 { return float64(len(line)) } )
func (LineExtractor) ToSampleExtractor ¶
func (l LineExtractor) ToSampleExtractor(groups []string, without bool, noLabels bool) SampleExtractor
ToSampleExtractor transform a LineExtractor into a SampleExtractor. Useful for metric conversion without log Pipeline.
type LineFormatter ¶
func NewFormatter ¶
func NewFormatter(tmpl string) (*LineFormatter, error)
NewFormatter creates a new log line formatter from a given text template.
func (*LineFormatter) Process ¶
func (lf *LineFormatter) Process(_ []byte, lbs *LabelsBuilder) ([]byte, bool)
type LogfmtParser ¶
type LogfmtParser struct {
// contains filtered or unexported fields
}
func NewLogfmtParser ¶
func NewLogfmtParser() *LogfmtParser
NewLogfmtParser creates a parser that can extract labels from a logfmt log line. Each keyval is extracted into a respective label.
func (*LogfmtParser) Process ¶
func (l *LogfmtParser) Process(line []byte, lbs *LabelsBuilder) ([]byte, bool)
type NumericLabelFilter ¶
type NumericLabelFilter struct { Name string Value float64 Type LabelFilterType }
func NewNumericLabelFilter ¶
func NewNumericLabelFilter(t LabelFilterType, name string, v float64) *NumericLabelFilter
NewNumericLabelFilter creates a new label filterer which parses float64 string representation (5.2) from the value of the named label and compares it with the given f value.
func (*NumericLabelFilter) Process ¶
func (n *NumericLabelFilter) Process(line []byte, lbs *LabelsBuilder) ([]byte, bool)
func (*NumericLabelFilter) String ¶
func (n *NumericLabelFilter) String() string
type RegexpParser ¶
type RegexpParser struct {
// contains filtered or unexported fields
}
func NewRegexpParser ¶
func NewRegexpParser(re string) (*RegexpParser, error)
NewRegexpParser creates a new log stage that can extract labels from a log line using a regex expression. The regex expression must contains at least one named match. If the regex doesn't match the line is not filtered out.
func (*RegexpParser) Process ¶
func (r *RegexpParser) Process(line []byte, lbs *LabelsBuilder) ([]byte, bool)
type SampleExtractor ¶
type SampleExtractor interface {
Process(line []byte, lbs labels.Labels) (float64, labels.Labels, bool)
}
SampleExtractor extracts sample for a log line.
func LabelExtractorWithStages ¶
func LabelExtractorWithStages( labelName, conversion string, groups []string, without bool, noLabels bool, preStages []Stage, postFilter Stage, ) (SampleExtractor, error)
LabelExtractorWithStages creates a SampleExtractor that will extract metrics from a labels. A set of log stage is executed before the conversion. A Filtering stage is executed after the conversion allowing to remove sample containing the __error__ label.
func LineExtractorWithStages ¶
func LineExtractorWithStages(ex LineExtractor, stages []Stage, groups []string, without bool, noLabels bool) (SampleExtractor, error)
LineExtractorWithStages creates a SampleExtractor from a LineExtractor. Multiple log stages are run before converting the log line.
type SampleExtractorFunc ¶
type Stage ¶
type Stage interface {
Process(line []byte, lbs *LabelsBuilder) ([]byte, bool)
}
Stage is a single step of a Pipeline.
func ReduceStages ¶
ReduceStages reduces multiple stages into one.
type StringLabelFilter ¶
func NewStringLabelFilter ¶
func NewStringLabelFilter(m *labels.Matcher) *StringLabelFilter
NewStringLabelFilter creates a new label filterer which compares string label. This is the only LabelFilterer that can filter out the __error__ label. Unlike other LabelFilterer which apply conversion, if the label name doesn't exist it is compared with an empty value.
func (*StringLabelFilter) Process ¶
func (s *StringLabelFilter) Process(line []byte, lbs *LabelsBuilder) ([]byte, bool)