promhandler

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2025 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package promhandler provides Prometheus API implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TimeoutMiddleware

func TimeoutMiddleware() promapi.Middleware

TimeoutMiddleware sets request timeout by given parameter, if set.

Types

type Engine

type Engine interface {
	NewInstantQuery(ctx context.Context, q storage.Queryable, opts promql.QueryOpts, qs string, ts time.Time) (promql.Query, error)
	NewRangeQuery(ctx context.Context, q storage.Queryable, opts promql.QueryOpts, qs string, start, end time.Time, interval time.Duration) (promql.Query, error)
}

Engine is a Prometheus engine interface.

type PromAPI

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

PromAPI implements promapi.Handler.

func NewPromAPI

func NewPromAPI(
	eng Engine,
	store storage.Queryable,
	exemplars storage.ExemplarQueryable,
	opts PromAPIOptions,
) *PromAPI

NewPromAPI creates new PromAPI.

func (*PromAPI) GetLabelValues

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

func (*PromAPI) GetLabels

func (h *PromAPI) GetLabels(ctx context.Context, params promapi.GetLabelsParams) (*promapi.LabelsResponse, error)

GetLabels implements getLabels operation.

GET /api/v1/labels

func (*PromAPI) GetMetadata

GetMetadata implements getMetadata operation.

GET /api/v1/metadata

func (*PromAPI) GetQuery

func (h *PromAPI) GetQuery(ctx context.Context, params promapi.GetQueryParams) (*promapi.QueryResponse, error)

GetQuery implements getQuery operation.

Query Prometheus.

GET /api/v1/query

func (*PromAPI) GetQueryExemplars

GetQueryExemplars implements getQueryExemplars operation.

Query Prometheus.

GET /api/v1/query_exemplars

func (*PromAPI) GetQueryRange

func (h *PromAPI) GetQueryRange(ctx context.Context, params promapi.GetQueryRangeParams) (*promapi.QueryResponse, error)

GetQueryRange implements getQueryRange operation.

Query Prometheus.

GET /api/v1/query_range

func (*PromAPI) GetRules

GetRules implements getRules operation.

GET /api/v1/rules

func (*PromAPI) GetSeries

func (h *PromAPI) GetSeries(ctx context.Context, params promapi.GetSeriesParams) (*promapi.SeriesResponse, error)

GetSeries implements getSeries operation.

Query Prometheus.

GET /api/v1/series

func (*PromAPI) NewError

func (h *PromAPI) NewError(_ context.Context, err error) *promapi.FailStatusCode

NewError creates *FailStatusCode from error returned by handler.

Used for common default response.

func (*PromAPI) PostLabels

func (h *PromAPI) PostLabels(ctx context.Context, req *promapi.LabelsForm) (*promapi.LabelsResponse, error)

PostLabels implements postLabels operation.

POST /api/v1/labels

func (*PromAPI) PostQuery

func (h *PromAPI) PostQuery(ctx context.Context, req *promapi.QueryForm) (*promapi.QueryResponse, error)

PostQuery implements postQuery operation.

Query Prometheus.

POST /api/v1/query

func (*PromAPI) PostQueryExemplars

func (h *PromAPI) PostQueryExemplars(ctx context.Context, params *promapi.ExemplarsForm) (*promapi.QueryExemplarsResponse, error)

PostQueryExemplars implements postQueryExemplars operation.

Query Prometheus.

POST /api/v1/query_exemplars

func (*PromAPI) PostQueryRange

func (h *PromAPI) PostQueryRange(ctx context.Context, req *promapi.QueryRangeForm) (*promapi.QueryResponse, error)

PostQueryRange implements postQueryRange operation.

Query Prometheus.

POST /api/v1/query_range

func (*PromAPI) PostSeries

func (h *PromAPI) PostSeries(ctx context.Context, req *promapi.SeriesForm) (*promapi.SeriesResponse, error)

PostSeries implements postSeries operation.

Query Prometheus.

POST /api/v1/series

type PromAPIOptions

type PromAPIOptions struct {
	// LookbackDelta sets default lookback delta. Defaults to [time.Hour].
	LookbackDelta time.Duration
}

PromAPIOptions describes PromAPI options.

type PromError

type PromError struct {
	Kind promapi.FailErrorType
	Msg  string
	Err  error
}

PromError is a wrapper for API errors.

func (*PromError) Error

func (e *PromError) Error() string

Error implements [error].

func (*PromError) FormatError

func (e *PromError) FormatError(p errors.Printer) error

FormatError prints the receiver's first error and returns the next error in the error chain, if any.

func (*PromError) Unwrap

func (e *PromError) Unwrap() error

Unwrap returns the next error in the error chain. If there is no next error, Unwrap returns nil.

Jump to

Keyboard shortcuts

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