Documentation ¶
Overview ¶
Package promhandler provides Prometheus API implementation.
Index ¶
- Variables
- func TimeoutMiddleware() promapi.Middleware
- type Engine
- type PromAPI
- func (h *PromAPI) GetLabelValues(ctx context.Context, params promapi.GetLabelValuesParams) (*promapi.LabelValuesResponse, error)
- func (h *PromAPI) GetLabels(ctx context.Context, params promapi.GetLabelsParams) (*promapi.LabelsResponse, error)
- func (h *PromAPI) GetMetadata(context.Context, promapi.GetMetadataParams) (*promapi.MetadataResponse, error)
- func (h *PromAPI) GetQuery(ctx context.Context, params promapi.GetQueryParams) (*promapi.QueryResponse, error)
- func (h *PromAPI) GetQueryExemplars(ctx context.Context, params promapi.GetQueryExemplarsParams) (*promapi.QueryExemplarsResponse, error)
- func (h *PromAPI) GetQueryRange(ctx context.Context, params promapi.GetQueryRangeParams) (*promapi.QueryResponse, error)
- func (h *PromAPI) GetRules(context.Context, promapi.GetRulesParams) (*promapi.RulesResponse, error)
- func (h *PromAPI) GetSeries(ctx context.Context, params promapi.GetSeriesParams) (*promapi.SeriesResponse, error)
- func (h *PromAPI) NewError(_ context.Context, err error) *promapi.FailStatusCode
- func (h *PromAPI) PostLabels(ctx context.Context, req *promapi.LabelsForm) (*promapi.LabelsResponse, error)
- func (h *PromAPI) PostQuery(ctx context.Context, req *promapi.QueryForm) (*promapi.QueryResponse, error)
- func (h *PromAPI) PostQueryExemplars(ctx context.Context, params *promapi.ExemplarsForm) (*promapi.QueryExemplarsResponse, error)
- func (h *PromAPI) PostQueryRange(ctx context.Context, req *promapi.QueryRangeForm) (*promapi.QueryResponse, error)
- func (h *PromAPI) PostSeries(ctx context.Context, req *promapi.SeriesForm) (*promapi.SeriesResponse, error)
- type PromAPIOptions
- type PromError
Constants ¶
This section is empty.
Variables ¶
var ( // MinTime is the default timestamp used for the begin of optional time ranges. // Exposed to let downstream projects to reference it. MinTime = time.Unix(math.MinInt64/1000+62135596801, 0).UTC() // MaxTime is the default timestamp used for the end of optional time ranges. // Exposed to let downstream projects to reference it. MaxTime = time.Unix(math.MaxInt64/1000-62135596801, 999999999).UTC() )
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 ¶
func (h *PromAPI) GetLabelValues(ctx context.Context, params promapi.GetLabelValuesParams) (*promapi.LabelValuesResponse, error)
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 ¶
func (h *PromAPI) GetMetadata(context.Context, promapi.GetMetadataParams) (*promapi.MetadataResponse, error)
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 ¶
func (h *PromAPI) GetQueryExemplars(ctx context.Context, params promapi.GetQueryExemplarsParams) (*promapi.QueryExemplarsResponse, error)
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 ¶
func (h *PromAPI) GetRules(context.Context, promapi.GetRulesParams) (*promapi.RulesResponse, error)
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 ¶
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) FormatError ¶
FormatError prints the receiver's first error and returns the next error in the error chain, if any.