models

package
v0.0.0-...-9649366 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bounds

type Bounds struct {
	Start    time.Time
	Duration time.Duration
	StepSize time.Duration
}

Bounds are the time bounds, start time is inclusive but end is exclusive.

func (Bounds) Blocks

func (b Bounds) Blocks(t time.Time) int

Blocks returns the number of blocks until time t.

func (Bounds) Contains

func (b Bounds) Contains(t time.Time) bool

Contains returns whether the time lies between the bounds.

func (Bounds) End

func (b Bounds) End() time.Time

End calculates the end time for the block and is exclusive.

func (Bounds) Equals

func (b Bounds) Equals(other Bounds) bool

Equals is true if two bounds are equal, including step size.

func (Bounds) Nearest

func (b Bounds) Nearest(t time.Time) Bounds

Nearest returns the nearest bound before the given time.

func (Bounds) Next

func (b Bounds) Next(n int) Bounds

Next returns the nth next bound from the current bound.

func (Bounds) Previous

func (b Bounds) Previous(n int) Bounds

Previous returns the nth previous bound from the current bound.

func (Bounds) Steps

func (b Bounds) Steps() int

Steps calculates the number of steps for the bounds.

func (Bounds) String

func (b Bounds) String() string

String representation of the bounds.

func (Bounds) TimeForIndex

func (b Bounds) TimeForIndex(idx int) (time.Time, error)

TimeForIndex returns the start time for a given index assuming a uniform step size.

type FetchedBlockType

type FetchedBlockType uint8

FetchedBlockType determines the type for fetched blocks, and how they are transformed from storage type.

const (
	// TypeSingleBlock represents a single block which contains each encoded fetched
	// series. Default block type for Prometheus queries.
	TypeSingleBlock FetchedBlockType = iota
	// TypeMultiBlock represents multiple blocks, each containing a time-based slice
	// of encoded fetched series. Default block type for non-Prometheus queries.
	TypeMultiBlock
	// TypeDecodedBlock represents a single block which contains all fetched series
	// which get decoded.
	//
	// NB: this is a legacy block type, will be deprecated once there is
	// sufficient confidence that other block types are performing correctly.
	TypeDecodedBlock
)

func (FetchedBlockType) Validate

func (t FetchedBlockType) Validate() error

Validate validates the fetched block type.

type FormatType

type FormatType int

FormatType describes what format to return the data in.

const (
	// FormatPromQL returns results in Prom format
	FormatPromQL FormatType = iota
	// FormatM3QL returns results in M3QL format
	FormatM3QL
)

type IDSchemeType

type IDSchemeType uint16

IDSchemeType determines the scheme for generating series IDs based on their tags.

const (
	// TypeDefault is an invalid scheme that indicates that the default scheme
	// for the tag options version option should be used.
	TypeDefault IDSchemeType = iota
	// TypeLegacy describes a scheme where IDs are generated by appending
	// tag name/value pairs with = and , separators. Note that an additional , is
	// added to the end of the ID.
	//
	// NB: this should not be used, and exists here as a deprecated legacy
	// ID generation scheme, as it may cause collisions in situations where
	// incoming tags contain the following characters: << =," >>,  for example:
	// {t1:v1},{t2:v2} -> t1=v1,t2=v2,
	// {t1:v1,t2:v2}   -> t1=v1,t2=v2,
	TypeLegacy
	// TypeQuoted describes a scheme where IDs are generated by appending
	// tag names with explicitly quoted and escaped tag values. Tag names are
	// also escaped if they contain invalid characters. This is equivalent to
	// the Prometheus ID style.
	// {t1:v1},{t2:v2} -> {t1="v1",t2="v2"}
	// {t1:v1,t2:v2}   -> {t1="v1,t2:v2"}
	// {"t1":"v1"}     -> {\"t1\""="\"v1\""}
	TypeQuoted
	// TypePrependMeta describes a scheme where IDs are generated by prepending
	// the length of each tag at the start of the ID
	// {t1:v1},{t2:v2} -> 2,2,2,2!t1v1t2v2
	// {t1:v1,t2:v2}   -> 2,8!t1v1,t2:v2
	// {"t1":"v1"}     -> 4,4!"t1""v1"
	TypePrependMeta
	// TypeGraphite describes a scheme where IDs are generated to match graphite
	// representation of the tags. This scheme should only be used on the graphite
	// ingestion path, as it ignores tag names and is very prone to collisions if
	// used on non-graphite data.
	// {__g0__:v1},{__g1__:v2} -> v1.v2
	//
	// NB: when TypeGraphite is specified, tags are ordered numerically rather
	// than lexically.
	//
	// NB 2: while the graphite scheme is valid, it is not available to choose as
	// a general ID scheme; instead, it is set on any metric coming through the
	// graphite ingestion path.
	TypeGraphite
)

func (IDSchemeType) String

func (t IDSchemeType) String() string

func (*IDSchemeType) UnmarshalYAML

func (t *IDSchemeType) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unmarshals a stored merics type.

func (IDSchemeType) Validate

func (t IDSchemeType) Validate() error

Validate validates that the scheme type is valid.

type MatchType

type MatchType int

MatchType is an enum for label matching types.

const (
	MatchEqual MatchType = iota
	MatchNotEqual
	MatchRegexp
	MatchNotRegexp
	MatchField
	MatchNotField
	MatchAll
)

Possible MatchTypes.

func (MatchType) String

func (m MatchType) String() string

type Matcher

type Matcher struct {
	Type  MatchType `json:"type"`
	Name  []byte    `json:"name"`
	Value []byte    `json:"value"`
	// contains filtered or unexported fields
}

Matcher models the matching of a label. NB: when serialized to JSON, name and value will be in base64.

func NewMatcher

func NewMatcher(t MatchType, n, v []byte) (Matcher, error)

NewMatcher returns a matcher object.

func (Matcher) String

func (m Matcher) String() string

type Matchers

type Matchers []Matcher

Matchers is a list of individual matchers.

func MatchersFromString

func MatchersFromString(s string) (Matchers, error)

MatchersFromString parses a string into Matchers TODO: make this more robust, handle types other than MatchEqual

func (Matchers) String

func (m Matchers) String() string

func (Matchers) ToTags

func (m Matchers) ToTags(
	tagOptions TagOptions,
) (Tags, error)

ToTags converts Matchers to Tags NB (braskin): this only works for exact matches

type Metric

type Metric struct {
	ID   []byte
	Tags Tags
}

Metric is the individual metric that gets returned from the search endpoint.

type Metrics

type Metrics []Metric

Metrics is a list of individual metrics.

type QueryContext

type QueryContext struct {
	Ctx      context.Context
	Scope    tally.Scope
	Enforcer cost.ChainedEnforcer
	Options  QueryContextOptions
}

QueryContext provides all external state needed to execute and track a query. It acts as a hook back into the execution engine for things like cost accounting.

func NewQueryContext

func NewQueryContext(
	ctx context.Context,
	scope tally.Scope,
	enforcer cost.ChainedEnforcer,
	options QueryContextOptions,
) *QueryContext

NewQueryContext constructs a QueryContext using the given Enforcer to enforce per query limits.

func NoopQueryContext

func NoopQueryContext() *QueryContext

NoopQueryContext returns a query context with no active components.

func (*QueryContext) WithContext

func (qc *QueryContext) WithContext(ctx context.Context) *QueryContext

WithContext creates a shallow copy of this QueryContext using the new context. Sample usage:

ctx, cancel := context.WithTimeout(qc.Ctx, 5*time.Second) defer cancel() qc = qc.WithContext(ctx)

type QueryContextOptions

type QueryContextOptions struct {
	// LimitMaxTimeseries limits the number of time series returned by each
	// storage node.
	LimitMaxTimeseries int
	RestrictFetchType  *RestrictFetchTypeQueryContextOptions
}

QueryContextOptions contains optional configuration for the query context.

type RequestParams

type RequestParams struct {
	Start time.Time
	End   time.Time
	// Now captures the current time and fixes it throughout the request, we
	// may let people override it in the future.
	Now              time.Time
	Timeout          time.Duration
	Step             time.Duration
	Query            string
	Debug            bool
	KeepNans         bool
	IncludeEnd       bool
	BlockType        FetchedBlockType
	FormatType       FormatType
	LookbackDuration time.Duration
}

RequestParams represents the params from the request.

func (RequestParams) ExclusiveEnd

func (r RequestParams) ExclusiveEnd() time.Time

ExclusiveEnd returns the end exclusive.

type RestrictFetchTypeQueryContextOptions

type RestrictFetchTypeQueryContextOptions struct {
	MetricsType   uint
	StoragePolicy policy.StoragePolicy
}

RestrictFetchTypeQueryContextOptions allows for specifying the restrict options for a query.

type Tag

type Tag struct {
	Name  []byte
	Value []byte
}

Tag is a key/value metric tag pair.

func (Tag) Clone

func (t Tag) Clone() Tag

Clone returns a copy of the tag.

func (Tag) Equals

func (t Tag) Equals(other Tag) bool

Equals returns a boolean indicating whether the provided tags are equal.

NB: does not check that compared tags have the same underlying bytes.

func (Tag) String

func (t Tag) String() string

String returns the string representation of the tag.

type TagOptions

type TagOptions interface {
	// Validate validates these tag options.
	Validate() error
	// SetMetricName sets the name for the `metric name` tag.
	SetMetricName(metricName []byte) TagOptions
	// MetricName gets the name for the `metric name` tag.
	MetricName() []byte
	// SetBucketName sets the name for the `bucket label` tag.
	SetBucketName(metricName []byte) TagOptions
	// BucketName gets the name for the `bucket label` tag.
	BucketName() []byte
	// SetIDSchemeType sets the ID generation scheme type.
	SetIDSchemeType(scheme IDSchemeType) TagOptions
	// IDSchemeType gets the ID generation scheme type.
	IDSchemeType() IDSchemeType
	// Equals determines if two tag options are equivalent.
	Equals(other TagOptions) bool
}

TagOptions describes additional options for tags.

func NewTagOptions

func NewTagOptions() TagOptions

NewTagOptions builds a new tag options with default values.

type Tags

type Tags struct {
	Opts TagOptions
	Tags []Tag
}

Tags represents a set of tags with options.

func EmptyTags

func EmptyTags() Tags

EmptyTags returns empty tags with a default tag options.

func MustMakeTags

func MustMakeTags(tag ...string) Tags

MustMakeTags creates tags given that the number of args is even.

func NewTags

func NewTags(size int, opts TagOptions) Tags

NewTags builds a tags with the given size and tag options.

func (Tags) Add

func (t Tags) Add(other Tags) Tags

Add is used to add two tag structures and maintain sorted order.

func (Tags) AddOrUpdateTag

func (t Tags) AddOrUpdateTag(tag Tag) Tags

AddOrUpdateTag is used to add a single tag and maintain sorted order, or to replace the value of an existing tag.

func (Tags) AddTag

func (t Tags) AddTag(tag Tag) Tags

AddTag is used to add a single tag and maintain sorted order.

func (Tags) AddTagWithoutNormalizing

func (t Tags) AddTagWithoutNormalizing(tag Tag) Tags

AddTagWithoutNormalizing is used to add a single tag.

func (Tags) AddTags

func (t Tags) AddTags(tags []Tag) Tags

AddTags is used to add a list of tags and maintain sorted order.

func (Tags) AddTagsIfNotExists

func (t Tags) AddTagsIfNotExists(tags []Tag) Tags

AddTagsIfNotExists is used to add a list of tags with unique names and maintain sorted order.

func (Tags) Bucket

func (t Tags) Bucket() ([]byte, bool)

Bucket gets the bucket tag value.

func (Tags) Clone

func (t Tags) Clone() Tags

Clone returns a copy of the tags.

func (Tags) Equals

func (t Tags) Equals(other Tags) bool

Equals returns a boolean reporting whether the compared tags have the same values.

NB: does not check that compared tags have the same underlying bytes.

func (Tags) Get

func (t Tags) Get(key []byte) ([]byte, bool)

Get returns the value for the tag with the given name.

func (Tags) HashedID

func (t Tags) HashedID() uint64

HashedID returns the hashed ID for the tags.

func (Tags) ID

func (t Tags) ID() []byte

ID returns a byte slice representation of the tags, using the generation strategy from the tag options.

func (Tags) Len

func (t Tags) Len() int

func (Tags) Less

func (t Tags) Less(i, j int) bool

func (Tags) Name

func (t Tags) Name() ([]byte, bool)

Name gets the metric name.

func (Tags) Normalize

func (t Tags) Normalize() Tags

Normalize normalizes the tags by sorting them in place. In the future, it might also ensure other things like uniqueness.

func (Tags) Reset

func (t Tags) Reset() Tags

HashedID returns the hashed ID for the tags.

func (Tags) SetBucket

func (t Tags) SetBucket(value []byte) Tags

SetBucket sets the bucket tag value.

func (Tags) SetName

func (t Tags) SetName(value []byte) Tags

SetName sets the metric name.

func (Tags) String

func (t Tags) String() string

String returns the string representation of the tags.

func (Tags) Swap

func (t Tags) Swap(i, j int)

func (Tags) TagsWithKeys

func (t Tags) TagsWithKeys(includeKeys [][]byte) Tags

TagsWithKeys returns only the tags which have the given keys.

func (Tags) TagsWithoutKeys

func (t Tags) TagsWithoutKeys(excludeKeys [][]byte) Tags

TagsWithoutKeys returns only the tags which do not have the given keys.

func (Tags) WithoutName

func (t Tags) WithoutName() Tags

WithoutName copies the tags excluding the name tag.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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