query

package
v0.8.3-rc1 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Module for defining collectors and their good/bad events API.

There are registered manually in preconfigured metrics builder in `def.go`

There are registered automatically to an auto-instrumentation server in `pkg/test/instrumentation.go`

Index

Constants

View Source
const MockTestServerName = "MyServer"

must not contain spaces

Variables

View Source
var (
	AvailableQueries              = make(map[string]MetricQuery)
	GetDownstreamMetricQueryTempl = template.Must(template.New("").Parse(`
		group by(__name__)({__name__=~"{{.NameRegex}}"})
	`))
)

Functions

func MatchMinLength

func MatchMinLength(metrics []string) string

Types

type HistogramQuery

type HistogramQuery struct {
	// contains filtered or unexported fields
}

func (HistogramQuery) BestMatch

func (hq HistogramQuery) BestMatch(in []string) string

func (HistogramQuery) Construct

func (hq HistogramQuery) Construct(serv *api.ServiceInfo) (string, error)

func (HistogramQuery) FillQueryTemplate

func (hq HistogramQuery) FillQueryTemplate(info templateExecutor) (string, error)

func (HistogramQuery) GetGoodCollector

func (hq HistogramQuery) GetGoodCollector() prometheus.Collector

func (HistogramQuery) GetGoodEvents

func (hq HistogramQuery) GetGoodEvents() func(w http.ResponseWriter, r *http.Request)

func (HistogramQuery) GetMetricFilter

func (hq HistogramQuery) GetMetricFilter() string

func (HistogramQuery) GetTotalCollector

func (hq HistogramQuery) GetTotalCollector() prometheus.Collector

func (HistogramQuery) GetTotalEvents

func (hq HistogramQuery) GetTotalEvents() func(w http.ResponseWriter, r *http.Request)

func (HistogramQuery) IsHistogram

func (hq HistogramQuery) IsHistogram() bool

func (HistogramQuery) IsRatio

func (hq HistogramQuery) IsRatio() bool

func (HistogramQuery) Validate

func (hq HistogramQuery) Validate() error

type MetricQuery

type MetricQuery interface {
	// User facing name of the pre-confured metric
	Name() string
	// User-facing description of the pre-configured metric
	Description() string
	// Each metric has a unique opni datasource (monitoring vs logging) by which it is filtered by
	Datasource() string
	Construct(*api.ServiceInfo) (*SLOQueryResult, error)
	// Some metrics will have different labels for metrics, so handle them independently
	GetGoodQuery() Query
	GetTotalQuery() Query

	GetCollector() prometheus.Collector
	GetGoodEventGenerator() func(w http.ResponseWriter, r *http.Request)
	GetBadEventGenerator() func(w http.ResponseWriter, r *http.Request)
}

type PrometheusQueryImpl

type PrometheusQueryImpl struct {
	GoodQuery  Query
	TotalQuery Query
	LabelRegex regexp.Regexp
	// contains filtered or unexported fields
}

func (*PrometheusQueryImpl) Construct

func (p *PrometheusQueryImpl) Construct(service *api.ServiceInfo) (*SLOQueryResult, error)

The actual metricId and window are only known at SLO creation time

func (*PrometheusQueryImpl) Datasource

func (p *PrometheusQueryImpl) Datasource() string

func (*PrometheusQueryImpl) Description

func (p *PrometheusQueryImpl) Description() string

func (*PrometheusQueryImpl) GetBadEventGenerator

func (p *PrometheusQueryImpl) GetBadEventGenerator() func(w http.ResponseWriter, r *http.Request)

func (*PrometheusQueryImpl) GetCollector

func (p *PrometheusQueryImpl) GetCollector() prometheus.Collector

func (*PrometheusQueryImpl) GetGoodEventGenerator

func (p *PrometheusQueryImpl) GetGoodEventGenerator() func(w http.ResponseWriter, r *http.Request)

func (*PrometheusQueryImpl) GetGoodQuery

func (p *PrometheusQueryImpl) GetGoodQuery() Query

func (*PrometheusQueryImpl) GetTotalQuery

func (p *PrometheusQueryImpl) GetTotalQuery() Query

func (*PrometheusQueryImpl) Name

func (p *PrometheusQueryImpl) Name() string

type Query

type Query interface {
	FillQueryTemplate(info templateExecutor) (string, error)
	GetMetricFilter() string
	Validate() error
	IsRatio() bool
	BestMatch([]string) string
	IsHistogram() bool
	Construct(*api.ServiceInfo) (string, error)
}

type QueryBuilder

type QueryBuilder interface {
	Query(string) QueryBuilder
	MetricFilter(string) QueryBuilder
	Matcher(*matcher) QueryBuilder
	BuildRatio() RatioQuery
	BuildHistogram() HistogramQuery
}

func NewQueryBuilder

func NewQueryBuilder() QueryBuilder

type RatioQuery

type RatioQuery struct {
	// contains filtered or unexported fields
}

func (RatioQuery) BestMatch

func (rq RatioQuery) BestMatch(in []string) string

func (RatioQuery) Construct

func (rq RatioQuery) Construct(serv *api.ServiceInfo) (string, error)

func (RatioQuery) FillQueryTemplate

func (rq RatioQuery) FillQueryTemplate(info templateExecutor) (string, error)

func (RatioQuery) GetGoodCollector

func (rq RatioQuery) GetGoodCollector() prometheus.Collector

func (RatioQuery) GetGoodEvents

func (rq RatioQuery) GetGoodEvents() func(w http.ResponseWriter, r *http.Request)

func (RatioQuery) GetMetricFilter

func (rq RatioQuery) GetMetricFilter() string

func (RatioQuery) GetTotalCollector

func (rq RatioQuery) GetTotalCollector() prometheus.Collector

func (RatioQuery) GetTotalEvents

func (rq RatioQuery) GetTotalEvents() func(w http.ResponseWriter, r *http.Request)

func (RatioQuery) IsHistogram

func (rq RatioQuery) IsHistogram() bool

func (RatioQuery) IsRatio

func (rq RatioQuery) IsRatio() bool

func (RatioQuery) Validate

func (rq RatioQuery) Validate() error

type SLOQueryResult

type SLOQueryResult struct {
	GoodQuery  string
	TotalQuery string
}

type SloQueryBuilder

type SloQueryBuilder interface {
	Name(name string) SloQueryBuilder
	GoodQuery(q Query) SloQueryBuilder
	TotalQuery(q Query) SloQueryBuilder
	Description(description string) SloQueryBuilder
	Datasource(datasource string) SloQueryBuilder
	Collector(prometheus.Collector) SloQueryBuilder
	GoodEventGenerator(goodEvents func(w http.ResponseWriter, r *http.Request)) SloQueryBuilder
	BadEventGenerator(badEvents func(w http.ResponseWriter, r *http.Request)) SloQueryBuilder
	Build() PrometheusQueryImpl
}

func New

func New() SloQueryBuilder

Jump to

Keyboard shortcuts

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