promproxy

package
v0.45.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: Apache-2.0 Imports: 16 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

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

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

Decode decodes InstantQuery from json.

func (*InstantQuery) Encode

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

Encode implements json.Marshaler.

func (*InstantQuery) GetDescription

func (s *InstantQuery) GetDescription() OptString

GetDescription returns the value of Description.

func (*InstantQuery) GetQuery

func (s *InstantQuery) GetQuery() string

GetQuery returns the value of Query.

func (*InstantQuery) GetTime

func (s *InstantQuery) GetTime() OptDateTime

GetTime returns the value of Time.

func (*InstantQuery) GetTitle

func (s *InstantQuery) GetTitle() OptString

GetTitle returns the value of Title.

func (*InstantQuery) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*InstantQuery) SetDescription

func (s *InstantQuery) SetDescription(val OptString)

SetDescription sets the value of Description.

func (*InstantQuery) SetQuery

func (s *InstantQuery) SetQuery(val string)

SetQuery sets the value of Query.

func (*InstantQuery) SetTime

func (s *InstantQuery) SetTime(val OptDateTime)

SetTime sets the value of Time.

func (*InstantQuery) SetTitle

func (s *InstantQuery) SetTitle(val OptString)

SetTitle sets the value of Title.

func (*InstantQuery) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type OptDateTime

type OptDateTime struct {
	Value time.Time
	Set   bool
}

OptDateTime is optional time.Time.

func NewOptDateTime

func NewOptDateTime(v time.Time) OptDateTime

NewOptDateTime returns new OptDateTime with value set to v.

func (*OptDateTime) Decode

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

Decode decodes time.Time from json.

func (OptDateTime) Encode

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

Encode encodes time.Time as json.

func (OptDateTime) Get

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

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

func (OptDateTime) IsSet

func (o OptDateTime) IsSet() bool

IsSet returns true if OptDateTime was set.

func (OptDateTime) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (OptDateTime) Or

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

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

func (*OptDateTime) Reset

func (o *OptDateTime) Reset()

Reset unsets value.

func (*OptDateTime) SetTo

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

SetTo sets value to v.

func (*OptDateTime) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type OptInt

type OptInt struct {
	Value int
	Set   bool
}

OptInt is optional int.

func NewOptInt

func NewOptInt(v int) OptInt

NewOptInt returns new OptInt with value set to v.

func (*OptInt) Decode

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

Decode decodes int from json.

func (OptInt) Encode

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

Encode encodes int as json.

func (OptInt) Get

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

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

func (OptInt) IsSet

func (o OptInt) IsSet() bool

IsSet returns true if OptInt was set.

func (OptInt) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (OptInt) Or

func (o OptInt) Or(d int) int

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

func (*OptInt) Reset

func (o *OptInt) Reset()

Reset unsets value.

func (*OptInt) SetTo

func (o *OptInt) SetTo(v int)

SetTo sets value to v.

func (*OptInt) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type OptString

type OptString struct {
	Value string
	Set   bool
}

OptString is optional string.

func NewOptString

func NewOptString(v string) OptString

NewOptString returns new OptString with value set to v.

func (*OptString) Decode

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

Decode decodes string from json.

func (OptString) Encode

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

Encode encodes string as json.

func (OptString) Get

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

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

func (OptString) IsSet

func (o OptString) IsSet() bool

IsSet returns true if OptString was set.

func (OptString) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (OptString) Or

func (o OptString) Or(d string) string

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

func (*OptString) Reset

func (o *OptString) Reset()

Reset unsets value.

func (*OptString) SetTo

func (o *OptString) SetTo(v string)

SetTo sets value to v.

func (*OptString) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type Query

type Query struct {
	// Type selects the active sum variant, switch on this field.
	Type         QueryType
	RangeQuery   RangeQuery
	InstantQuery InstantQuery
	SeriesQuery  SeriesQuery
}

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

func NewInstantQueryQuery

func NewInstantQueryQuery(v InstantQuery) Query

NewInstantQueryQuery returns new Query from InstantQuery.

func NewRangeQueryQuery

func NewRangeQueryQuery(v RangeQuery) Query

NewRangeQueryQuery returns new Query from RangeQuery.

func NewSeriesQueryQuery

func NewSeriesQueryQuery(v SeriesQuery) Query

NewSeriesQueryQuery returns new Query from SeriesQuery.

func (*Query) Decode

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

Decode decodes Query from json.

func (Query) Encode

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

Encode encodes Query as json.

func (Query) GetInstantQuery

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

GetInstantQuery returns InstantQuery and true boolean if Query is InstantQuery.

func (Query) GetRangeQuery

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

GetRangeQuery returns RangeQuery and true boolean if Query is RangeQuery.

func (Query) GetSeriesQuery

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

GetSeriesQuery returns SeriesQuery and true boolean if Query is SeriesQuery.

func (Query) IsInstantQuery

func (s Query) IsInstantQuery() bool

IsInstantQuery reports whether Query is InstantQuery.

func (Query) IsRangeQuery

func (s Query) IsRangeQuery() bool

IsRangeQuery reports whether Query is RangeQuery.

func (Query) IsSeriesQuery

func (s Query) IsSeriesQuery() bool

IsSeriesQuery reports whether Query is SeriesQuery.

func (Query) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*Query) SetInstantQuery

func (s *Query) SetInstantQuery(v InstantQuery)

SetInstantQuery sets Query to InstantQuery.

func (*Query) SetRangeQuery

func (s *Query) SetRangeQuery(v RangeQuery)

SetRangeQuery sets Query to RangeQuery.

func (*Query) SetSeriesQuery

func (s *Query) SetSeriesQuery(v SeriesQuery)

SetSeriesQuery sets Query to SeriesQuery.

func (*Query) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

func (Query) Validate

func (s Query) Validate() error

type QueryType

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

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

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

Decode decodes RangeQuery from json.

func (*RangeQuery) Encode

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

Encode implements json.Marshaler.

func (*RangeQuery) GetDescription

func (s *RangeQuery) GetDescription() OptString

GetDescription returns the value of Description.

func (*RangeQuery) GetEnd

func (s *RangeQuery) GetEnd() OptDateTime

GetEnd returns the value of End.

func (*RangeQuery) GetQuery

func (s *RangeQuery) GetQuery() string

GetQuery returns the value of Query.

func (*RangeQuery) GetStart

func (s *RangeQuery) GetStart() OptDateTime

GetStart returns the value of Start.

func (*RangeQuery) GetStep

func (s *RangeQuery) GetStep() OptInt

GetStep returns the value of Step.

func (*RangeQuery) GetTitle

func (s *RangeQuery) GetTitle() OptString

GetTitle returns the value of Title.

func (*RangeQuery) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*RangeQuery) SetDescription

func (s *RangeQuery) SetDescription(val OptString)

SetDescription sets the value of Description.

func (*RangeQuery) SetEnd

func (s *RangeQuery) SetEnd(val OptDateTime)

SetEnd sets the value of End.

func (*RangeQuery) SetQuery

func (s *RangeQuery) SetQuery(val string)

SetQuery sets the value of Query.

func (*RangeQuery) SetStart

func (s *RangeQuery) SetStart(val OptDateTime)

SetStart sets the value of Start.

func (*RangeQuery) SetStep

func (s *RangeQuery) SetStep(val OptInt)

SetStep sets the value of Step.

func (*RangeQuery) SetTitle

func (s *RangeQuery) SetTitle(val OptString)

SetTitle sets the value of Title.

func (*RangeQuery) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type Record

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

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

Decode decodes Record from json.

func (*Record) Encode

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

Encode implements json.Marshaler.

func (*Record) GetEnd

func (s *Record) GetEnd() OptDateTime

GetEnd returns the value of End.

func (*Record) GetInstant

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

GetInstant returns the value of Instant.

func (*Record) GetQueries

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

GetQueries returns the value of Queries.

func (*Record) GetRange

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

GetRange returns the value of Range.

func (*Record) GetSeries

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

GetSeries returns the value of Series.

func (*Record) GetStart

func (s *Record) GetStart() OptDateTime

GetStart returns the value of Start.

func (*Record) GetStep

func (s *Record) GetStep() OptInt

GetStep returns the value of Step.

func (*Record) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*Record) SetEnd

func (s *Record) SetEnd(val OptDateTime)

SetEnd sets the value of End.

func (*Record) SetInstant

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

SetInstant sets the value of Instant.

func (*Record) SetQueries

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

SetQueries sets the value of Queries.

func (*Record) SetRange

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

SetRange sets the value of Range.

func (*Record) SetSeries

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

SetSeries sets the value of Series.

func (*Record) SetStart

func (s *Record) SetStart(val OptDateTime)

SetStart sets the value of Start.

func (*Record) SetStep

func (s *Record) SetStep(val OptInt)

SetStep sets the value of Step.

func (*Record) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

func (*Record) Validate

func (s *Record) Validate() error

type Recorder

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

Recorder of prometheus queries.

func NewRecorder

func NewRecorder(writer io.Writer) *Recorder

NewRecorder returns new Recorder.

func (*Recorder) RecordGetQuery

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

func (*Recorder) RecordGetQueryRange

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

RecordGetQueryRange records range query.

func (*Recorder) RecordSeriesQuery

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

type SeriesQuery

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

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

Decode decodes SeriesQuery from json.

func (*SeriesQuery) Encode

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

Encode implements json.Marshaler.

func (*SeriesQuery) GetDescription

func (s *SeriesQuery) GetDescription() OptString

GetDescription returns the value of Description.

func (*SeriesQuery) GetEnd

func (s *SeriesQuery) GetEnd() OptDateTime

GetEnd returns the value of End.

func (*SeriesQuery) GetMatchers

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

GetMatchers returns the value of Matchers.

func (*SeriesQuery) GetStart

func (s *SeriesQuery) GetStart() OptDateTime

GetStart returns the value of Start.

func (*SeriesQuery) GetTitle

func (s *SeriesQuery) GetTitle() OptString

GetTitle returns the value of Title.

func (*SeriesQuery) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*SeriesQuery) SetDescription

func (s *SeriesQuery) SetDescription(val OptString)

SetDescription sets the value of Description.

func (*SeriesQuery) SetEnd

func (s *SeriesQuery) SetEnd(val OptDateTime)

SetEnd sets the value of End.

func (*SeriesQuery) SetMatchers

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

SetMatchers sets the value of Matchers.

func (*SeriesQuery) SetStart

func (s *SeriesQuery) SetStart(val OptDateTime)

SetStart sets the value of Start.

func (*SeriesQuery) SetTitle

func (s *SeriesQuery) SetTitle(val OptString)

SetTitle sets the value of Title.

func (*SeriesQuery) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

func (*SeriesQuery) Validate

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