Documentation
¶
Index ¶
- Constants
- func BuildConnectorSchema(metadata *Metadata) (*schema.SchemaResponse, error)
- func DecodeStringSlice(value any) ([]string, error)
- func FindNativeQueryVariableNames(query string) []string
- func ReplaceNativeQueryVariable(query string, name string, value string) string
- type AggregationOperator
- type Configuration
- type ConversionFunction
- type LabelFilterSetting
- type LabelFormatRule
- type LabelInfo
- type LogPipeline
- type LogPipelineType
- type Metadata
- type ModelField
- type ModelFieldValue
- type ModelInfo
- type ModelLabelInfo
- type ModelPipeline
- type NativeOperations
- type NativeQuery
- type NativeQueryArgumentInfo
- type Ordering
- type PipelineDrop
- type PipelineJSON
- type PipelineKeep
- type PipelineLabelFilter
- type PipelineLabelFormat
- type PipelineLineFilter
- type PipelineLineFormat
- type PipelineLogFormat
- type PipelinePattern
- type PipelineRegexp
- type PipelineUnpack
- type QueryType
- type RuntimeFormatSettings
- type RuntimeSettings
- type ScalarName
- type State
- type TimestampFormat
- type UnixTimeUnit
- type ValueFormat
Constants ¶
const ( Equal = "_eq" NotEqual = "_neq" Like = "_like" ILike = "_ilike" NotLike = "_nlike" NotILike = "_nilike" In = "_in" NotIn = "_nin" Regex = "_regex" NotRegex = "_nregex" Least = "_lt" LeastOrEqual = "_lte" Greater = "_gt" GreaterOrEqual = "_gte" ContainIP = "_ip" NotContainIP = "_nip" Since = "_since" )
const ( TimestampKey = "timestamp" ValueKey = "value" LogLineKey = "log_line" LogLinesKey = "log_lines" MetricValueKey = "metric_value" MetricValuesKey = "metric_values" OriginalLabelsKey = "original_labels" KKey = "k" ByKey = "by" WithoutKey = "without" RangeKey = "range" UnwrapKey = "unwrap" ConversionFunctionKey = "conversion_function" QuantileKey = "quantile" )
const ( ArgumentKeyFlat = "flat" ArgumentKeyTimeout = "timeout" ArgumentKeyStep = "step" ArgumentKeyInterval = "interval" ArgumentKeyOffset = "offset" ArgumentKeyAggregations = "aggregations" )
const ( QueryTypeStream = "stream" QueryTypeMetric = "metric" )
Variables ¶
This section is empty.
Functions ¶
func BuildConnectorSchema ¶
func BuildConnectorSchema(metadata *Metadata) (*schema.SchemaResponse, error)
BuildConnectorSchema builds the schema for the data connector from metadata
func DecodeStringSlice ¶
DecodeStringSlice decodes string slice from an unknown argument value
func FindNativeQueryVariableNames ¶
FindNativeQueryVariableNames find possible variables in the native query
Types ¶
type AggregationOperator ¶
type AggregationOperator string
AggregationOperator represents an aggregate operator enum
const ( // Calculate sum over labels Sum AggregationOperator = "sum" // Calculate the average over labels Avg AggregationOperator = "avg" // Select minimum over labels Min AggregationOperator = "min" // Select maximum over labels Max AggregationOperator = "max" // Calculate the population standard deviation over labels Stddev AggregationOperator = "stddev" // Calculate the population standard variance over labels Stdvar AggregationOperator = "stdvar" // Count number of elements in the vector Count AggregationOperator = "count" // Select largest k elements by sample value TopK AggregationOperator = "topk" // Select smallest k elements by sample value BottomK AggregationOperator = "bottomk" // returns vector elements sorted by their sample values, in ascending order. Sort AggregationOperator = "sort" // Same as sort, but sorts in descending order. SortDesc AggregationOperator = "sort_desc" // calculates the number of entries per second Rate AggregationOperator = "rate" // calculates per second rate of the values in the specified interval and treating them as “counter metric”. RateCounter AggregationOperator = "rate_counter" // counts the entries for each log stream within the given range. CountOverTime AggregationOperator = "count_over_time" // calculates the number of bytes per second for each stream. BytesRate AggregationOperator = "bytes_rate" // counts the amount of bytes used by each log stream for a given range. BytesOverTime AggregationOperator = "bytes_over_time" // returns an empty vector if the range vector passed to it has any elements and a 1-element vector with the value 1 if the range vector passed to it has no elements. // (absent_over_time is useful for alerting on when no time series and logs stream exist for label combination for a certain amount of time.) AbsentOverTime AggregationOperator = "absent_over_time" // the average value of all points in the specified interval. AvgOverTime AggregationOperator = "avg_over_time" // the minimum value of all points in the specified interval MinOverTime AggregationOperator = "min_over_time" // the maximum value of all points in the specified interval. MaxOverTime AggregationOperator = "max_over_time" // the sum of all values in the specified interval. SumOverTime AggregationOperator = "sum_over_time" // the φ-quantile (0 ≤ φ ≤ 1) of the values in the specified interval. QuantileOverTime AggregationOperator = "quantile_over_time" // the population standard deviation of the values in the specified interval. StddevOverTime AggregationOperator = "stddev_over_time" // the population standard variance of the values in the specified interval. StdvarOverTime AggregationOperator = "stdvar_over_time" // the first value of all points in the specified interval FirstOverTime AggregationOperator = "first_over_time" // the last value of all points in the specified interval LastOverTime AggregationOperator = "last_over_time" )
type Configuration ¶
type Configuration struct { // Connection settings to connect the Loki server ConnectionSettings client.ClientSettings `json:"connection_settings" yaml:"connection_settings"` // The metadata of log stream and metric models Metadata Metadata `json:"metadata" yaml:"metadata"` // Runtime settings Runtime RuntimeSettings `json:"runtime" yaml:"runtime"` }
Configuration the configuration of the Loki connector
func ReadConfiguration ¶
func ReadConfiguration(configurationDir string) (*Configuration, error)
ReadConfiguration reads the configuration from file
type ConversionFunction ¶
type ConversionFunction string
ConversionFunction represents the conversion function enum
const ( ConversionDuration ConversionFunction = "duration" ConversionDurationSeconds ConversionFunction = "duration_seconds" ConversionBytes ConversionFunction = "bytes" )
func ParseConversionFunction ¶
func ParseConversionFunction(input string) (ConversionFunction, error)
ParseConversionFunction parse the conversion function enum from string
type LabelFilterSetting ¶
type LabelFilterSetting struct { // The filter operator to be used. Operator string `json:"operator" yaml:"operator" jsonschema:"enum=_eq,enum=_neq,enum=_regex,enum=_nregex,default=_eq"` // The filter value. Value string `json:"value" yaml:"value"` // The static filter can't be changed. Static *bool `json:"static,omitempty" yaml:"static,omitempty"` }
LabelFilterSetting represents the filter setting for the label
type LabelFormatRule ¶
type LabelFormatRule struct { Source string `json:"source" yaml:"source" jsonschema:"oneof_required=source_label"` Template string `json:"template" yaml:"template" jsonschema:"oneof_required=template"` }
LabelFormatOperation the format operation of a label
type LabelInfo ¶
type LabelInfo struct { // The source label name. Source string `json:"source,omitempty" yaml:"source,omitempty"` // Description of the label. Description *string `json:"description,omitempty" yaml:"description,omitempty"` }
LabelInfo the information of a log label
type LogPipeline ¶
type LogPipeline interface { // GetType returns the pipeline type. GetType() LogPipelineType // Render return a pipeline expression string Render() (string, error) }
LogPipeline abstracts the a log pipeline interface.
type LogPipelineType ¶
type LogPipelineType string
LogPipelineType represents a log pipeline type of the model
const ( PipelineTypeLineFilter LogPipelineType = "line_filter" PipelineTypeLabelFilter LogPipelineType = "label_filter" PipelineTypeJSON LogPipelineType = "json" PipelineTypeLogFormat LogPipelineType = "logfmt" PipelineTypePattern LogPipelineType = "pattern" PipelineTypeRegexp LogPipelineType = "regexp" PipelineTypeUnpack LogPipelineType = "unpack" PipelineTypeLineFormat LogPipelineType = "line_format" PipelineTypeLabelFormat LogPipelineType = "label_format" PipelineTypeKeep LogPipelineType = "keep" PipelineTypeDrop LogPipelineType = "drop" )
func ParseLogPipelineType ¶
func ParseLogPipelineType(input string) (LogPipelineType, error)
ParseLogPipelineType parses the LogPipelineType from a string.
func (*LogPipelineType) UnmarshalJSON ¶
func (m *LogPipelineType) UnmarshalJSON(b []byte) error
UnmarshalJSON implements json.Unmarshaler.
type Metadata ¶
type Metadata struct { // Definition of stream models Models map[string]ModelInfo `json:"models" yaml:"models"` // The collection of native operations NativeOperations NativeOperations `json:"native_operations" yaml:"native_operations"` }
Metadata the metadata configuration
type ModelField ¶
type ModelField struct { // Description of the field. Description *string `json:"description,omitempty" yaml:"description,omitempty"` // The path to select the value from JSON or logfmt log body. Selector *string `json:"selector,omitempty" yaml:"selector,omitempty"` }
ModelField the metadata of a field.
type ModelFieldValue ¶
type ModelFieldValue struct { ModelField Value *string }
ModelFieldValue wraps the ModelField with value.
type ModelInfo ¶
type ModelInfo struct { // The list of preprocessing pipelines Pipelines []ModelPipeline `json:"pipelines" yaml:"pipelines"` // The pattern to be used if the parser type is pattern or regexp Pattern string `json:"pattern,omitempty" yaml:"pattern,omitempty"` // Description of the model. Description *string `json:"description,omitempty" yaml:"description,omitempty"` // Labels returned by the model. Labels map[string]ModelLabelInfo `json:"labels" yaml:"labels"` // Stripping ANSI sequences (color codes) from the line. Decolorize *bool `json:"decolorize,omitempty" yaml:"decolorize,omitempty"` // contains filtered or unexported fields }
ModelInfo represents the metadata of a log model.
func (*ModelInfo) GetFields ¶
func (m *ModelInfo) GetFields() map[string]ModelFieldValue
GetFields get the final model field map
func (*ModelInfo) GetFirstLabelName ¶
GetFirstLabelName get the first label name in alphabet order
func (*ModelInfo) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type ModelLabelInfo ¶
type ModelLabelInfo struct { LabelInfo `yaml:",inline"` // Default filter setting for the label Filter *LabelFilterSetting `json:"filter,omitempty"` }
ModelLabelInfo represents the label information of the model
type ModelPipeline ¶
type ModelPipeline struct {
LogPipeline
}
ModelPipeline represents a log pipeline
func (ModelPipeline) JSONSchema ¶
func (m ModelPipeline) JSONSchema() *jsonschema.Schema
JSONSchema defines the json schema for the model pipeline
func (ModelPipeline) MarshalYAML ¶
func (m ModelPipeline) MarshalYAML() (interface{}, error)
MarshalYAML implements yaml.Marshaler interface.
func (*ModelPipeline) UnmarshalYAML ¶
func (m *ModelPipeline) UnmarshalYAML(value *yaml.Node) error
UnmarshalYAML implements yaml.Marshaler interface.
type NativeOperations ¶
type NativeOperations struct { // The definition map of native queries Queries map[string]NativeQuery `json:"queries" yaml:"queries"` }
NativeOperations the list of native query and mutation definitions
type NativeQuery ¶
type NativeQuery struct { // the type of native query Type QueryType `json:"type" yaml:"type" jsonschema:"enum=stream,enum=metric"` // The LogQL query string to use for the Native Query. // We can interpolate values using `${<varname>}` syntax, // such as {job="${<varname>}"} Query string `json:"query" yaml:"query"` // Description of the query Description *string `json:"description,omitempty" yaml:"description,omitempty"` // Labels returned by the native query Labels map[string]LabelInfo `json:"labels" yaml:"labels"` // Information of input arguments Arguments map[string]NativeQueryArgumentInfo `json:"arguments" yaml:"arguments"` }
NativeQuery contains the information a native query
type NativeQueryArgumentInfo ¶
type NativeQueryArgumentInfo struct { // Description of the argument Description *string `json:"description,omitempty" yaml:"description,omitempty"` Type string `json:"type" yaml:"type" jsonschema:"enum=Int64,enum=Float64,enum=String,enum=Duration"` }
NativeQueryArgumentInfo the input argument
type Ordering ¶
type Ordering string
Ordering represents a sort order enum
func ParseOrdering ¶
ParseOrdering parse the conversion function enum from string
type PipelineDrop ¶
type PipelineDrop struct { Type LogPipelineType `json:"type" yaml:"type" jsonschema:"enum=drop"` // The collection of selected fields from the pipeline. Fields map[string]ModelField `json:"fields" yaml:"fields"` }
PipelineDrop will drop the given labels in the pipeline.
func (PipelineDrop) GetType ¶
func (p PipelineDrop) GetType() LogPipelineType
GetType returns the pipeline type.
func (PipelineDrop) Render ¶
func (p PipelineDrop) Render() (string, error)
String implement the fmt.Stringer interface.
type PipelineJSON ¶
type PipelineJSON struct { Type LogPipelineType `json:"type" yaml:"type" jsonschema:"enum=json"` // The collection of selected fields from the pipeline. Fields map[string]ModelField `json:"fields" yaml:"fields"` }
PipelineJSON extracts all json properties as labels if the log line is a valid json document.
func (PipelineJSON) GetType ¶
func (p PipelineJSON) GetType() LogPipelineType
GetType returns the pipeline type.
func (PipelineJSON) Render ¶
func (p PipelineJSON) Render() (string, error)
String implement the fmt.Stringer interface.
type PipelineKeep ¶
type PipelineKeep struct { Type LogPipelineType `json:"type" yaml:"type" jsonschema:"enum=keep"` // The collection of selected fields from the pipeline. Fields map[string]ModelField `json:"fields" yaml:"fields"` }
PipelineKeep will keep only the specified labels in the pipeline and drop all the other labels.
func (PipelineKeep) GetType ¶
func (p PipelineKeep) GetType() LogPipelineType
GetType returns the pipeline type.
func (PipelineKeep) Render ¶
func (p PipelineKeep) Render() (string, error)
String implement the fmt.Stringer interface.
type PipelineLabelFilter ¶
type PipelineLabelFilter struct { Type LogPipelineType `json:"type" yaml:"type" jsonschema:"enum=label_filter"` Name string `json:"name" yaml:"name"` Operator string `` /* 145-byte string literal not displayed */ Value any `json:"value" yaml:"value"` }
PipelineLabelFilter allows filtering log line using their original and extracted labels.
func NewPipelineLabelFilter ¶
func NewPipelineLabelFilter(name string, operator string, value any) *PipelineLabelFilter
NewPipelineLabelFilter creates a new PipelineLabelFilter instance.
func (PipelineLabelFilter) GetType ¶
func (p PipelineLabelFilter) GetType() LogPipelineType
GetType returns the pipeline type.
func (PipelineLabelFilter) Render ¶
func (p PipelineLabelFilter) Render() (string, error)
String implement the fmt.Stringer interface.
type PipelineLabelFormat ¶
type PipelineLabelFormat struct { Type LogPipelineType `json:"type" yaml:"type" jsonschema:"enum=label_format"` Labels map[string]LabelFormatRule `json:"labels" yaml:"labels"` }
PipelineLabelFormat can rename, modify or add labels.
func (PipelineLabelFormat) GetType ¶
func (p PipelineLabelFormat) GetType() LogPipelineType
GetType returns the pipeline type.
func (PipelineLabelFormat) Render ¶
func (p PipelineLabelFormat) Render() (string, error)
String implement the fmt.Stringer interface.
type PipelineLineFilter ¶
type PipelineLineFilter struct { Type LogPipelineType `json:"type" yaml:"type" jsonschema:"enum=line_filter"` Operator string `` /* 136-byte string literal not displayed */ Value string `json:"value" yaml:"value"` }
PipelineLineFilter does a distributed grep over the aggregated logs from the matching log streams.
func NewPipelineLineFilter ¶
func NewPipelineLineFilter(operator string, value string) *PipelineLineFilter
NewPipelineLineFilter creates a new PipelineLineFilter instance.
func (PipelineLineFilter) GetType ¶
func (p PipelineLineFilter) GetType() LogPipelineType
GetType returns the pipeline type.
func (PipelineLineFilter) Render ¶
func (p PipelineLineFilter) Render() (string, error)
String implement the fmt.Stringer interface.
type PipelineLineFormat ¶
type PipelineLineFormat struct { Type LogPipelineType `json:"type" yaml:"type" jsonschema:"enum=line_format"` Template string `json:"template" yaml:"template"` }
PipelineLineFormat can rewrite the log line content by using the text/template format.
func (PipelineLineFormat) GetType ¶
func (p PipelineLineFormat) GetType() LogPipelineType
GetType returns the pipeline type.
func (PipelineLineFormat) Render ¶
func (p PipelineLineFormat) Render() (string, error)
String implement the fmt.Stringer interface.
type PipelineLogFormat ¶
type PipelineLogFormat struct { Type LogPipelineType `json:"type" yaml:"type" jsonschema:"enum=logfmt"` // The collection of selected fields from the pipeline. Fields map[string]ModelField `json:"fields" yaml:"fields"` }
PipelineLogFormat extracts keys and values from the logfmt formatted log line.
func (PipelineLogFormat) GetType ¶
func (p PipelineLogFormat) GetType() LogPipelineType
GetType returns the pipeline type.
func (PipelineLogFormat) Render ¶
func (p PipelineLogFormat) Render() (string, error)
String implement the fmt.Stringer interface.
type PipelinePattern ¶
type PipelinePattern struct { Type LogPipelineType `json:"type" yaml:"type" jsonschema:"enum=pattern"` Pattern string `json:"pattern" yaml:"pattern"` // The collection of selected fields from the pipeline. Fields map[string]ModelField `json:"fields" yaml:"fields"` }
PipelinePattern allows the explicit extraction of fields from log lines by defining a pattern expression.
func (PipelinePattern) GetType ¶
func (p PipelinePattern) GetType() LogPipelineType
GetType returns the pipeline type.
func (PipelinePattern) Render ¶
func (p PipelinePattern) Render() (string, error)
String implement the fmt.Stringer interface.
type PipelineRegexp ¶
type PipelineRegexp struct { Type LogPipelineType `json:"type" yaml:"type" jsonschema:"enum=regexp"` Pattern string `json:"pattern" yaml:"pattern"` // The collection of selected fields from the pipeline. Fields map[string]ModelField `json:"fields" yaml:"fields"` }
PipelineRegexp takes a regular expression using the Golang RE2 syntax to parse the log line.
func (PipelineRegexp) GetType ¶
func (p PipelineRegexp) GetType() LogPipelineType
GetType returns the pipeline type.
func (PipelineRegexp) Render ¶
func (p PipelineRegexp) Render() (string, error)
String implement the fmt.Stringer interface.
type PipelineUnpack ¶
type PipelineUnpack struct { Type LogPipelineType `json:"type" yaml:"type" jsonschema:"enum=unpack"` // The collection of selected fields from the pipeline. Fields map[string]ModelField `json:"fields" yaml:"fields"` }
PipelineUnpack the parser parses a JSON log line, unpacking all embedded labels from Promtail’s pack stage. A special property _entry will also be used to replace the original log line.
func (PipelineUnpack) GetType ¶
func (p PipelineUnpack) GetType() LogPipelineType
GetType returns the pipeline type.
func (PipelineUnpack) Render ¶
func (p PipelineUnpack) Render() (string, error)
String implement the fmt.Stringer interface.
type RuntimeFormatSettings ¶
type RuntimeFormatSettings struct { // The serialization format for timestamp Timestamp TimestampFormat `json:"timestamp" yaml:"timestamp" jsonschema:"enum=rfc3339,enum=unix,default=unix"` // The serialization format for value Value ValueFormat `json:"value" yaml:"value" jsonschema:"enum=string,enum=float64,default=string"` // The serialization format for not-a-number values NaN any `json:"nan" yaml:"nan" jsonschema:"oneof_type=string;number;null"` // The serialization format for infinite values Inf any `json:"inf" yaml:"inf" jsonschema:"oneof_type=string;number;null"` // The serialization format for negative infinite values NegativeInf any `json:"negative_inf" yaml:"negative_inf" jsonschema:"oneof_type=string;number;null"` }
RuntimeFormatSettings format settings for timestamps and values in runtime
type RuntimeSettings ¶
type RuntimeSettings struct { // Flatten value points to the root array Flat bool `json:"flat" yaml:"flat"` // The default unit for unix timestamp UnixTimeUnit UnixTimeUnit `json:"unix_time_unit" yaml:"unix_time_unit" jsonschema:"enum=s,enum=ms,enum=us,enum=ns,default=s"` // The serialization format for response fields Format RuntimeFormatSettings `json:"format" yaml:"format"` // The concurrency limit of queries if there are many variables in a single query QueryConcurrencyLimit int `json:"query_concurrency_limit,omitempty" yaml:"query_concurrency_limit,omitempty"` // The concurrency limit of operations if there are many operations in a single mutation MutationConcurrencyLimit int `json:"mutation_concurrency_limit,omitempty" yaml:"mutation_concurrency_limit,omitempty"` }
RuntimeSettings contain settings for the runtime engine
type ScalarName ¶
type ScalarName string
const ( ScalarBoolean ScalarName = "Boolean" ScalarInt64 ScalarName = "Int64" ScalarFloat64 ScalarName = "Float64" ScalarString ScalarName = "String" ScalarLogLine ScalarName = "LogLine" ScalarDecimal ScalarName = "Decimal" ScalarTimestamp ScalarName = "Timestamp" ScalarLabel ScalarName = "Label" ScalarLabelSet ScalarName = "LabelSet" ScalarDuration ScalarName = "Duration" ScalarJSON ScalarName = "JSON" ScalarConversionFunction ScalarName = "ConversionFunction" ScalarOrdering ScalarName = "Ordering" )
type TimestampFormat ¶
type TimestampFormat string
TimestampFormat the format for timestamp serialization
const ( // Represents the timestamp as a Unix timestamp in RFC3339 string. TimestampRFC3339 TimestampFormat = "rfc3339" // Represents the timestamp as a Unix timestamp in seconds. TimestampUnix TimestampFormat = "unix" // Represents the timestamp as a Unix timestamp in milliseconds. TimestampUnixMilli TimestampFormat = "unix_ms" // Represents the timestamp as a Unix timestamp in microseconds. TimestampUnixMicro TimestampFormat = "unix_us" // Represents the timestamp as a Unix timestamp in nanoseconds. TimestampUnixNano TimestampFormat = "unix_ns" )
type UnixTimeUnit ¶
type UnixTimeUnit string
UnixTimeUnit the unit for unix timestamp
const ( UnixTimeSecond UnixTimeUnit = "s" UnixTimeMilli UnixTimeUnit = "ms" UnixTimeMicro UnixTimeUnit = "us" UnixTimeNano UnixTimeUnit = "ns" )
func (UnixTimeUnit) Duration ¶
func (ut UnixTimeUnit) Duration() time.Duration
Duration returns the duration of the unit
type ValueFormat ¶
type ValueFormat string
ValueFormat the format for value serialization
const ( ValueString ValueFormat = "string" ValueFloat64 ValueFormat = "float64" )