Documentation
¶
Index ¶
- Constants
- func AddDBResultResponseHeaders(w http.ResponseWriter, meta block.ResultMetadata, ...) error
- func AddReturnedLimitResponseHeaders(w http.ResponseWriter, returnedDataLimited *ReturnedDataLimited, ...) error
- func ParseDuration(r *http.Request, key string) (time.Duration, error)
- func ParseDurationLimit(req *http.Request, header, formValue string, defaultLimit time.Duration) (time.Duration, error)
- func ParseInstanceMultiple(req *http.Request, defaultValue float32) (float32, error)
- func ParseLimit(req *http.Request, header, formValue string, defaultLimit int) (int, error)
- func ParseLookbackDuration(r *http.Request) (time.Duration, bool, error)
- func ParseRequestTimeout(r *http.Request, configFetchTimeout time.Duration) (time.Duration, error)
- func ParseRequireExhaustive(req *http.Request, defaultValue bool) (bool, error)
- func ParseRequireNoWait(req *http.Request) (bool, error)
- func ParseStep(r *http.Request) (time.Duration, bool, error)
- type DropOp
- type DropWithValueOp
- type FetchOptionsBuilder
- type FetchOptionsBuilderLimitsOptions
- type FetchOptionsBuilderOptions
- type MapTagsOptions
- type PromWriteHandlerForwardTargetOptions
- type PromWriteHandlerForwardingOptions
- type ReplaceOp
- type ReturnedDataLimited
- type ReturnedMetadataLimited
- type StringMatch
- type StringTagOptions
- type TagMapper
- type Waiting
- type WriteOp
Constants ¶
const ( // RequestHeaderKey is the key which headers will be added to in the // request context. RequestHeaderKey headerKey = "RequestHeaderKey" // StepParam is the step parameter. StepParam = "step" // LookbackParam is the lookback parameter. LookbackParam = "lookback" // TimeoutParam is the timeout parameter. TimeoutParam = "timeout" )
Variables ¶
This section is empty.
Functions ¶
func AddDBResultResponseHeaders ¶ added in v1.2.0
func AddDBResultResponseHeaders( w http.ResponseWriter, meta block.ResultMetadata, fetchOpts *storage.FetchOptions, ) error
AddDBResultResponseHeaders adds response headers based on metadata and fetch options related to the database result.
func AddReturnedLimitResponseHeaders ¶ added in v1.2.0
func AddReturnedLimitResponseHeaders( w http.ResponseWriter, returnedDataLimited *ReturnedDataLimited, returnedMetadataLimited *ReturnedMetadataLimited, ) error
AddReturnedLimitResponseHeaders adds headers related to hitting limits on the allowed amount of data that can be returned to the client.
func ParseDuration ¶
ParseDuration parses a duration HTTP parameter. nolint: unparam
func ParseDurationLimit ¶ added in v1.2.0
func ParseDurationLimit( req *http.Request, header, formValue string, defaultLimit time.Duration, ) (time.Duration, error)
ParseDurationLimit parses request limit from either header or query string.
func ParseInstanceMultiple ¶ added in v1.2.0
ParseInstanceMultiple parses request instance multiple from header.
func ParseLimit ¶
ParseLimit parses request limit from either header or query string.
func ParseLookbackDuration ¶
ParseLookbackDuration parses a lookback duration for an HTTP request.
func ParseRequestTimeout ¶ added in v1.0.1
func ParseRequestTimeout( r *http.Request, configFetchTimeout time.Duration, ) (time.Duration, error)
ParseRequestTimeout parses the input request timeout with a default.
func ParseRequireExhaustive ¶ added in v0.15.2
ParseRequireExhaustive parses request limit require exhaustive from header or query string.
func ParseRequireNoWait ¶ added in v1.2.0
ParseRequireNoWait parses the no-wait behavior from header or query string.
Types ¶
type DropOp ¶
type DropOp struct {
Tag string `json:"tag"`
}
DropOp with tag="foo" and an empty value will remove all tag-value pairs in all timeseries in the write request where the tag was "foo".
type DropWithValueOp ¶
DropWithValueOp will remove all tag-value pairs in all timeseries in the writer equest if and only if the tag AND value in the timeseries is equal to those on the operation.
func (DropWithValueOp) IsEmpty ¶
func (op DropWithValueOp) IsEmpty() bool
IsEmpty returns true if the operation is empty.
type FetchOptionsBuilder ¶
type FetchOptionsBuilder interface {
// NewFetchOptions parses an http request into fetch options.
NewFetchOptions(
ctx context.Context,
req *http.Request,
) (context.Context, *storage.FetchOptions, error)
}
FetchOptionsBuilder builds fetch options based on a request and default config.
func NewFetchOptionsBuilder ¶
func NewFetchOptionsBuilder( opts FetchOptionsBuilderOptions, ) (FetchOptionsBuilder, error)
NewFetchOptionsBuilder returns a new fetch options builder.
type FetchOptionsBuilderLimitsOptions ¶ added in v0.15.4
type FetchOptionsBuilderLimitsOptions struct {
SeriesLimit int
InstanceMultiple float32
DocsLimit int
RangeLimit time.Duration
ReturnedSeriesLimit int
ReturnedDatapointsLimit int
ReturnedSeriesMetadataLimit int
RequireExhaustive bool
}
FetchOptionsBuilderLimitsOptions provides limits options to use when creating a fetch options builder.
type FetchOptionsBuilderOptions ¶
type FetchOptionsBuilderOptions struct {
Limits FetchOptionsBuilderLimitsOptions
RestrictByTag *storage.RestrictByTag
Timeout time.Duration
}
FetchOptionsBuilderOptions provides options to use when creating a fetch options builder.
func (FetchOptionsBuilderOptions) Validate ¶ added in v1.0.1
func (o FetchOptionsBuilderOptions) Validate() error
Validate validates the fetch options builder options.
type MapTagsOptions ¶
type MapTagsOptions struct {
TagMappers []TagMapper `json:"tagMappers"`
}
MapTagsOptions representations mutations to be applied to all timeseries in a write request.
type PromWriteHandlerForwardTargetOptions ¶
type PromWriteHandlerForwardTargetOptions struct {
// URL of the target to send to.
URL string `yaml:"url"`
// Method defaults to POST if not set.
Method string `yaml:"method"`
// Headers to send along with requests to the target.
Headers map[string]string `yaml:"headers"`
}
PromWriteHandlerForwardTargetOptions is a prometheus write handler forwarder target.
type PromWriteHandlerForwardingOptions ¶
type PromWriteHandlerForwardingOptions struct {
// MaxConcurrency is the max parallel forwarding and if zero will be unlimited.
MaxConcurrency int `yaml:"maxConcurrency"`
Timeout time.Duration `yaml:"timeout"`
Retry *retry.Configuration `yaml:"retry"`
Targets []PromWriteHandlerForwardTargetOptions `yaml:"targets"`
}
PromWriteHandlerForwardingOptions is the forwarding options for prometheus write handler.
type ReplaceOp ¶
type ReplaceOp struct {
Tag string `json:"tag"`
OldValue string `json:"old"`
NewValue string `json:"new"`
}
ReplaceOp with tag="foo", an empty old field, and a non-empty new field will unconditionally replace the value of any tag-value pair of any timeseries in the write request where the tag is "foo" with the value of new. If old is non-empty, a value will only be replaced if the value was equal to old.
type ReturnedDataLimited ¶ added in v1.2.0
type ReturnedDataLimited struct {
Series int
Datapoints int
// Total series is the total number of series which maybe be >= Series.
// Truncation happens at the series-level to avoid presenting partial series
// and so this value is useful for indicating how many series would have
// been rendered without limiting either series or datapoints.
TotalSeries int
// Limited signals that the results returned were
// limited by either series or datapoint limits.
Limited bool
}
ReturnedDataLimited is info about whether data was limited by a query.
type ReturnedMetadataLimited ¶ added in v1.2.0
type ReturnedMetadataLimited struct {
// Results is the total amount of rendered results.
Results int
// TotalResults is the total amount of metadata results.
TotalResults int
// Limited signals that the results returned were limited by a limit.
Limited bool
}
ReturnedMetadataLimited is info about whether data was limited by a query.
type StringMatch ¶
type StringMatch struct {
Name string `json:"name"`
Type string `json:"type"`
Value string `json:"value"`
}
StringMatch is an easy to use JSON representation of models.Matcher that allows plaintext fields rather than forcing base64 encoded values.
type StringTagOptions ¶
type StringTagOptions struct {
Restrict []StringMatch `json:"match"`
Strip []string `json:"strip"`
}
StringTagOptions is an easy to use JSON representation of storage.RestrictByTag that allows plaintext string fields rather than forcing base64 encoded values.
func (*StringTagOptions) StorageOptions ¶ added in v0.15.4
func (o *StringTagOptions) StorageOptions() (*storage.RestrictByTag, error)
StorageOptions returns the corresponding storage.RestrictByTag options.
func (*StringTagOptions) Validate ¶ added in v0.15.4
func (o *StringTagOptions) Validate() error
Validate validates the string tag options.
type TagMapper ¶
type TagMapper struct {
Write WriteOp `json:"write,omitEmpty"`
Drop DropOp `json:"drop,omitEmpty"`
DropWithValue DropWithValueOp `json:"dropWithValue,omitEmpty"`
Replace ReplaceOp `json:"replace,omitEmpty"`
}
TagMapper represents one of a variety of tag mapping operations.
type Waiting ¶ added in v1.2.0
type Waiting struct {
// WaitedIndex counts how many times index querying had to wait for permits.
WaitedIndex int `json:"waitedIndex"`
// WaitedSeriesRead counts how many times series being read had to wait for permits.
WaitedSeriesRead int `json:"waitedSeriesRead"`
}
Waiting is info about an operation waiting for permits.