query

package
v0.7.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2022 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              map[string]MetricQuery = 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 (h HistogramQuery) BestMatch(in []string) string

func (HistogramQuery) Construct

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

func (HistogramQuery) FillQueryTemplate

func (h 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 (h 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 (h HistogramQuery) IsHistogram() bool

func (HistogramQuery) IsRatio

func (h HistogramQuery) IsRatio() bool

func (HistogramQuery) Validate

func (h 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 (r RatioQuery) BestMatch(in []string) string

func (RatioQuery) Construct

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

func (RatioQuery) FillQueryTemplate

func (r 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 (r 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 (r RatioQuery) IsHistogram() bool

func (RatioQuery) IsRatio

func (r RatioQuery) IsRatio() bool

func (RatioQuery) Validate

func (r 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