promproxy

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package promproxy provides Prometheus proxy for observability and research.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InstantQuery added in v0.7.0

type InstantQuery struct {
	Query       string      `json:"query"`
	Time        OptDateTime `json:"time"`
	Title       OptString   `json:"title"`
	Description OptString   `json:"description"`
}

Ref: #/definitions/instantQuery

func (*InstantQuery) Decode added in v0.7.0

func (s *InstantQuery) Decode(d *jx.Decoder) error

Decode decodes InstantQuery from json.

func (*InstantQuery) Encode added in v0.7.0

func (s *InstantQuery) Encode(e *jx.Encoder)

Encode implements json.Marshaler.

func (*InstantQuery) GetDescription added in v0.7.0

func (s *InstantQuery) GetDescription() OptString

GetDescription returns the value of Description.

func (*InstantQuery) GetQuery added in v0.7.0

func (s *InstantQuery) GetQuery() string

GetQuery returns the value of Query.

func (*InstantQuery) GetTime added in v0.7.0

func (s *InstantQuery) GetTime() OptDateTime

GetTime returns the value of Time.

func (*InstantQuery) GetTitle added in v0.7.0

func (s *InstantQuery) GetTitle() OptString

GetTitle returns the value of Title.

func (*InstantQuery) MarshalJSON added in v0.7.0

func (s *InstantQuery) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*InstantQuery) SetDescription added in v0.7.0

func (s *InstantQuery) SetDescription(val OptString)

SetDescription sets the value of Description.

func (*InstantQuery) SetQuery added in v0.7.0

func (s *InstantQuery) SetQuery(val string)

SetQuery sets the value of Query.

func (*InstantQuery) SetTime added in v0.7.0

func (s *InstantQuery) SetTime(val OptDateTime)

SetTime sets the value of Time.

func (*InstantQuery) SetTitle added in v0.7.0

func (s *InstantQuery) SetTitle(val OptString)

SetTitle sets the value of Title.

func (*InstantQuery) UnmarshalJSON added in v0.7.0

func (s *InstantQuery) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type OptDateTime added in v0.7.0

type OptDateTime struct {
	Value time.Time
	Set   bool
}

OptDateTime is optional time.Time.

func NewOptDateTime added in v0.7.0

func NewOptDateTime(v time.Time) OptDateTime

NewOptDateTime returns new OptDateTime with value set to v.

func (*OptDateTime) Decode added in v0.7.0

func (o *OptDateTime) Decode(d *jx.Decoder, format func(*jx.Decoder) (time.Time, error)) error

Decode decodes time.Time from json.

func (OptDateTime) Encode added in v0.7.0

func (o OptDateTime) Encode(e *jx.Encoder, format func(*jx.Encoder, time.Time))

Encode encodes time.Time as json.

func (OptDateTime) Get added in v0.7.0

func (o OptDateTime) Get() (v time.Time, ok bool)

Get returns value and boolean that denotes whether value was set.

func (OptDateTime) IsSet added in v0.7.0

func (o OptDateTime) IsSet() bool

IsSet returns true if OptDateTime was set.

func (OptDateTime) MarshalJSON added in v0.7.0

func (s OptDateTime) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (OptDateTime) Or added in v0.7.0

func (o OptDateTime) Or(d time.Time) time.Time

Or returns value if set, or given parameter if does not.

func (*OptDateTime) Reset added in v0.7.0

func (o *OptDateTime) Reset()

Reset unsets value.

func (*OptDateTime) SetTo added in v0.7.0

func (o *OptDateTime) SetTo(v time.Time)

SetTo sets value to v.

func (*OptDateTime) UnmarshalJSON added in v0.7.0

func (s *OptDateTime) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type OptInt added in v0.7.0

type OptInt struct {
	Value int
	Set   bool
}

OptInt is optional int.

func NewOptInt added in v0.7.0

func NewOptInt(v int) OptInt

NewOptInt returns new OptInt with value set to v.

func (*OptInt) Decode added in v0.7.0

func (o *OptInt) Decode(d *jx.Decoder) error

Decode decodes int from json.

func (OptInt) Encode added in v0.7.0

func (o OptInt) Encode(e *jx.Encoder)

Encode encodes int as json.

func (OptInt) Get added in v0.7.0

func (o OptInt) Get() (v int, ok bool)

Get returns value and boolean that denotes whether value was set.

func (OptInt) IsSet added in v0.7.0

func (o OptInt) IsSet() bool

IsSet returns true if OptInt was set.

func (OptInt) MarshalJSON added in v0.7.0

func (s OptInt) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (OptInt) Or added in v0.7.0

func (o OptInt) Or(d int) int

Or returns value if set, or given parameter if does not.

func (*OptInt) Reset added in v0.7.0

func (o *OptInt) Reset()

Reset unsets value.

func (*OptInt) SetTo added in v0.7.0

func (o *OptInt) SetTo(v int)

SetTo sets value to v.

func (*OptInt) UnmarshalJSON added in v0.7.0

func (s *OptInt) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type OptString added in v0.7.0

type OptString struct {
	Value string
	Set   bool
}

OptString is optional string.

func NewOptString added in v0.7.0

func NewOptString(v string) OptString

NewOptString returns new OptString with value set to v.

func (*OptString) Decode added in v0.7.0

func (o *OptString) Decode(d *jx.Decoder) error

Decode decodes string from json.

func (OptString) Encode added in v0.7.0

func (o OptString) Encode(e *jx.Encoder)

Encode encodes string as json.

func (OptString) Get added in v0.7.0

func (o OptString) Get() (v string, ok bool)

Get returns value and boolean that denotes whether value was set.

func (OptString) IsSet added in v0.7.0

func (o OptString) IsSet() bool

IsSet returns true if OptString was set.

func (OptString) MarshalJSON added in v0.7.0

func (s OptString) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (OptString) Or added in v0.7.0

func (o OptString) Or(d string) string

Or returns value if set, or given parameter if does not.

func (*OptString) Reset added in v0.7.0

func (o *OptString) Reset()

Reset unsets value.

func (*OptString) SetTo added in v0.7.0

func (o *OptString) SetTo(v string)

SetTo sets value to v.

func (*OptString) UnmarshalJSON added in v0.7.0

func (s *OptString) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type Query added in v0.7.0

type Query struct {
	Type         QueryType // switch on this field
	RangeQuery   RangeQuery
	InstantQuery InstantQuery
	SeriesQuery  SeriesQuery
}

Ref: #/definitions/query Query represents sum type.

func NewInstantQueryQuery added in v0.7.0

func NewInstantQueryQuery(v InstantQuery) Query

NewInstantQueryQuery returns new Query from InstantQuery.

func NewRangeQueryQuery added in v0.7.0

func NewRangeQueryQuery(v RangeQuery) Query

NewRangeQueryQuery returns new Query from RangeQuery.

func NewSeriesQueryQuery added in v0.7.0

func NewSeriesQueryQuery(v SeriesQuery) Query

NewSeriesQueryQuery returns new Query from SeriesQuery.

func (*Query) Decode added in v0.7.0

func (s *Query) Decode(d *jx.Decoder) error

Decode decodes Query from json.

func (Query) Encode added in v0.7.0

func (s Query) Encode(e *jx.Encoder)

Encode encodes Query as json.

func (Query) GetInstantQuery added in v0.7.0

func (s Query) GetInstantQuery() (v InstantQuery, ok bool)

GetInstantQuery returns InstantQuery and true boolean if Query is InstantQuery.

func (Query) GetRangeQuery added in v0.7.0

func (s Query) GetRangeQuery() (v RangeQuery, ok bool)

GetRangeQuery returns RangeQuery and true boolean if Query is RangeQuery.

func (Query) GetSeriesQuery added in v0.7.0

func (s Query) GetSeriesQuery() (v SeriesQuery, ok bool)

GetSeriesQuery returns SeriesQuery and true boolean if Query is SeriesQuery.

func (Query) IsInstantQuery added in v0.7.0

func (s Query) IsInstantQuery() bool

IsInstantQuery reports whether Query is InstantQuery.

func (Query) IsRangeQuery added in v0.7.0

func (s Query) IsRangeQuery() bool

IsRangeQuery reports whether Query is RangeQuery.

func (Query) IsSeriesQuery added in v0.7.0

func (s Query) IsSeriesQuery() bool

IsSeriesQuery reports whether Query is SeriesQuery.

func (Query) MarshalJSON added in v0.7.0

func (s Query) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*Query) SetInstantQuery added in v0.7.0

func (s *Query) SetInstantQuery(v InstantQuery)

SetInstantQuery sets Query to InstantQuery.

func (*Query) SetRangeQuery added in v0.7.0

func (s *Query) SetRangeQuery(v RangeQuery)

SetRangeQuery sets Query to RangeQuery.

func (*Query) SetSeriesQuery added in v0.7.0

func (s *Query) SetSeriesQuery(v SeriesQuery)

SetSeriesQuery sets Query to SeriesQuery.

func (*Query) UnmarshalJSON added in v0.7.0

func (s *Query) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

func (Query) Validate added in v0.7.0

func (s Query) Validate() error

type QueryType added in v0.7.0

type QueryType string

QueryType is oneOf type of Query.

const (
	RangeQueryQuery   QueryType = "RangeQuery"
	InstantQueryQuery QueryType = "InstantQuery"
	SeriesQueryQuery  QueryType = "SeriesQuery"
)

Possible values for QueryType.

type RangeQuery added in v0.7.0

type RangeQuery struct {
	Query string      `json:"query"`
	Start OptDateTime `json:"start"`
	End   OptDateTime `json:"end"`
	// Step in seconds.
	Step        OptInt    `json:"step"`
	Title       OptString `json:"title"`
	Description OptString `json:"description"`
}

Ref: #/definitions/rangeQuery

func (*RangeQuery) Decode added in v0.7.0

func (s *RangeQuery) Decode(d *jx.Decoder) error

Decode decodes RangeQuery from json.

func (*RangeQuery) Encode added in v0.7.0

func (s *RangeQuery) Encode(e *jx.Encoder)

Encode implements json.Marshaler.

func (*RangeQuery) GetDescription added in v0.7.0

func (s *RangeQuery) GetDescription() OptString

GetDescription returns the value of Description.

func (*RangeQuery) GetEnd added in v0.7.0

func (s *RangeQuery) GetEnd() OptDateTime

GetEnd returns the value of End.

func (*RangeQuery) GetQuery added in v0.7.0

func (s *RangeQuery) GetQuery() string

GetQuery returns the value of Query.

func (*RangeQuery) GetStart added in v0.7.0

func (s *RangeQuery) GetStart() OptDateTime

GetStart returns the value of Start.

func (*RangeQuery) GetStep added in v0.7.0

func (s *RangeQuery) GetStep() OptInt

GetStep returns the value of Step.

func (*RangeQuery) GetTitle added in v0.7.0

func (s *RangeQuery) GetTitle() OptString

GetTitle returns the value of Title.

func (*RangeQuery) MarshalJSON added in v0.7.0

func (s *RangeQuery) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*RangeQuery) SetDescription added in v0.7.0

func (s *RangeQuery) SetDescription(val OptString)

SetDescription sets the value of Description.

func (*RangeQuery) SetEnd added in v0.7.0

func (s *RangeQuery) SetEnd(val OptDateTime)

SetEnd sets the value of End.

func (*RangeQuery) SetQuery added in v0.7.0

func (s *RangeQuery) SetQuery(val string)

SetQuery sets the value of Query.

func (*RangeQuery) SetStart added in v0.7.0

func (s *RangeQuery) SetStart(val OptDateTime)

SetStart sets the value of Start.

func (*RangeQuery) SetStep added in v0.7.0

func (s *RangeQuery) SetStep(val OptInt)

SetStep sets the value of Step.

func (*RangeQuery) SetTitle added in v0.7.0

func (s *RangeQuery) SetTitle(val OptString)

SetTitle sets the value of Title.

func (*RangeQuery) UnmarshalJSON added in v0.7.0

func (s *RangeQuery) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type Record added in v0.7.0

type Record struct {
	Start   OptDateTime    `json:"start"`
	End     OptDateTime    `json:"end"`
	Step    OptInt         `json:"step"`
	Series  []SeriesQuery  `json:"series"`
	Instant []InstantQuery `json:"instant"`
	Range   []RangeQuery   `json:"range"`
	Queries []Query        `json:"queries"`
}

func (*Record) Decode added in v0.7.0

func (s *Record) Decode(d *jx.Decoder) error

Decode decodes Record from json.

func (*Record) Encode added in v0.7.0

func (s *Record) Encode(e *jx.Encoder)

Encode implements json.Marshaler.

func (*Record) GetEnd added in v0.7.0

func (s *Record) GetEnd() OptDateTime

GetEnd returns the value of End.

func (*Record) GetInstant added in v0.7.0

func (s *Record) GetInstant() []InstantQuery

GetInstant returns the value of Instant.

func (*Record) GetQueries added in v0.7.0

func (s *Record) GetQueries() []Query

GetQueries returns the value of Queries.

func (*Record) GetRange added in v0.7.0

func (s *Record) GetRange() []RangeQuery

GetRange returns the value of Range.

func (*Record) GetSeries added in v0.7.0

func (s *Record) GetSeries() []SeriesQuery

GetSeries returns the value of Series.

func (*Record) GetStart added in v0.7.0

func (s *Record) GetStart() OptDateTime

GetStart returns the value of Start.

func (*Record) GetStep added in v0.7.0

func (s *Record) GetStep() OptInt

GetStep returns the value of Step.

func (*Record) MarshalJSON added in v0.7.0

func (s *Record) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*Record) SetEnd added in v0.7.0

func (s *Record) SetEnd(val OptDateTime)

SetEnd sets the value of End.

func (*Record) SetInstant added in v0.7.0

func (s *Record) SetInstant(val []InstantQuery)

SetInstant sets the value of Instant.

func (*Record) SetQueries added in v0.7.0

func (s *Record) SetQueries(val []Query)

SetQueries sets the value of Queries.

func (*Record) SetRange added in v0.7.0

func (s *Record) SetRange(val []RangeQuery)

SetRange sets the value of Range.

func (*Record) SetSeries added in v0.7.0

func (s *Record) SetSeries(val []SeriesQuery)

SetSeries sets the value of Series.

func (*Record) SetStart added in v0.7.0

func (s *Record) SetStart(val OptDateTime)

SetStart sets the value of Start.

func (*Record) SetStep added in v0.7.0

func (s *Record) SetStep(val OptInt)

SetStep sets the value of Step.

func (*Record) UnmarshalJSON added in v0.7.0

func (s *Record) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

func (*Record) Validate added in v0.7.0

func (s *Record) Validate() error

type Recorder added in v0.7.0

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

Recorder of prometheus queries.

func NewRecorder added in v0.7.0

func NewRecorder(writer io.Writer) *Recorder

NewRecorder returns new Recorder.

func (*Recorder) RecordGetQuery added in v0.7.0

func (r *Recorder) RecordGetQuery(v promapi.GetQueryParams) error

func (*Recorder) RecordGetQueryRange added in v0.7.0

func (r *Recorder) RecordGetQueryRange(v promapi.GetQueryRangeParams) error

RecordGetQueryRange records range query.

func (*Recorder) RecordSeriesQuery added in v0.7.0

func (r *Recorder) RecordSeriesQuery(v promapi.GetSeriesParams) error

type SeriesQuery added in v0.7.0

type SeriesQuery struct {
	Matchers    []string    `json:"matchers"`
	Start       OptDateTime `json:"start"`
	End         OptDateTime `json:"end"`
	Title       OptString   `json:"title"`
	Description OptString   `json:"description"`
}

Ref: #/definitions/seriesQuery

func (*SeriesQuery) Decode added in v0.7.0

func (s *SeriesQuery) Decode(d *jx.Decoder) error

Decode decodes SeriesQuery from json.

func (*SeriesQuery) Encode added in v0.7.0

func (s *SeriesQuery) Encode(e *jx.Encoder)

Encode implements json.Marshaler.

func (*SeriesQuery) GetDescription added in v0.7.0

func (s *SeriesQuery) GetDescription() OptString

GetDescription returns the value of Description.

func (*SeriesQuery) GetEnd added in v0.7.0

func (s *SeriesQuery) GetEnd() OptDateTime

GetEnd returns the value of End.

func (*SeriesQuery) GetMatchers added in v0.7.0

func (s *SeriesQuery) GetMatchers() []string

GetMatchers returns the value of Matchers.

func (*SeriesQuery) GetStart added in v0.7.0

func (s *SeriesQuery) GetStart() OptDateTime

GetStart returns the value of Start.

func (*SeriesQuery) GetTitle added in v0.7.0

func (s *SeriesQuery) GetTitle() OptString

GetTitle returns the value of Title.

func (*SeriesQuery) MarshalJSON added in v0.7.0

func (s *SeriesQuery) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*SeriesQuery) SetDescription added in v0.7.0

func (s *SeriesQuery) SetDescription(val OptString)

SetDescription sets the value of Description.

func (*SeriesQuery) SetEnd added in v0.7.0

func (s *SeriesQuery) SetEnd(val OptDateTime)

SetEnd sets the value of End.

func (*SeriesQuery) SetMatchers added in v0.7.0

func (s *SeriesQuery) SetMatchers(val []string)

SetMatchers sets the value of Matchers.

func (*SeriesQuery) SetStart added in v0.7.0

func (s *SeriesQuery) SetStart(val OptDateTime)

SetStart sets the value of Start.

func (*SeriesQuery) SetTitle added in v0.7.0

func (s *SeriesQuery) SetTitle(val OptString)

SetTitle sets the value of Title.

func (*SeriesQuery) UnmarshalJSON added in v0.7.0

func (s *SeriesQuery) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

func (*SeriesQuery) Validate added in v0.7.0

func (s *SeriesQuery) Validate() error

type Server

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

Server implement proxy server.

func NewServer

func NewServer(api *promapi.Client, rec *Recorder) *Server

NewServer initializes new proxy Server from openapi client.

func (*Server) GetLabelValues

GetLabelValues implements getLabelValues operation. GET /api/v1/label/{label}/values

func (*Server) GetLabels

func (s *Server) GetLabels(ctx context.Context, params promapi.GetLabelsParams) (*promapi.LabelsResponse, error)

GetLabels implements getLabels operation.

GET /api/v1/labels

func (*Server) GetMetadata

func (s *Server) GetMetadata(ctx context.Context, params promapi.GetMetadataParams) (*promapi.MetadataResponse, error)

GetMetadata implements getMetadata operation.

GET /api/v1/metadata

func (*Server) GetQuery

func (s *Server) GetQuery(ctx context.Context, params promapi.GetQueryParams) (*promapi.QueryResponse, error)

GetQuery implements getQuery operation.

Query Prometheus.

GET /api/v1/query

func (*Server) GetQueryExemplars

GetQueryExemplars implements getQueryExemplars operation.

Query Prometheus.

GET /api/v1/query_examplars

func (*Server) GetQueryRange

func (s *Server) GetQueryRange(ctx context.Context, params promapi.GetQueryRangeParams) (*promapi.QueryResponse, error)

GetQueryRange implements getQueryRange operation.

Query Prometheus.

GET /api/v1/query_range

func (*Server) GetRules

func (s *Server) GetRules(ctx context.Context, params promapi.GetRulesParams) (*promapi.RulesResponse, error)

GetRules implements getRules operation.

GET /api/v1/rules

func (*Server) GetSeries

func (s *Server) GetSeries(ctx context.Context, params promapi.GetSeriesParams) (*promapi.SeriesResponse, error)

GetSeries implements getSeries operation. Query Prometheus.

GET /api/v1/series

func (Server) NewError

func (s Server) NewError(ctx context.Context, err error) *promapi.FailStatusCode

NewError creates *FailStatusCode from error returned by handler.

Used for common default response.

func (*Server) PostLabels

func (s *Server) PostLabels(ctx context.Context, req *promapi.LabelsForm) (*promapi.LabelsResponse, error)

PostLabels implements postLabels operation.

POST /api/v1/labels

func (*Server) PostQuery

func (s *Server) PostQuery(ctx context.Context, req *promapi.QueryForm) (*promapi.QueryResponse, error)

PostQuery implements postQuery operation.

Query Prometheus.

POST /api/v1/query

func (*Server) PostQueryExemplars

func (s *Server) PostQueryExemplars(ctx context.Context, req *promapi.ExemplarsForm) (*promapi.QueryExemplarsResponse, error)

PostQueryExemplars implements postQueryExemplars operation.

Query Prometheus.

POST /api/v1/query_examplars

func (*Server) PostQueryRange

func (s *Server) PostQueryRange(ctx context.Context, req *promapi.QueryRangeForm) (*promapi.QueryResponse, error)

PostQueryRange implements postQueryRange operation.

Query Prometheus.

POST /api/v1/query_range

func (*Server) PostSeries

func (s *Server) PostSeries(ctx context.Context, req *promapi.SeriesForm) (*promapi.SeriesResponse, error)

PostSeries implements postSeries operation.

Query Prometheus.

POST /api/v1/series

Jump to

Keyboard shortcuts

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