Documentation
¶
Index ¶
- Constants
- Variables
- func ConfigProcess()
- func ConfigSetup()
- type IdSet
- type KvByCost
- type KvReByCost
- type MemoryIdx
- func (m *MemoryIdx) AddOrUpdate(mkey schema.MKey, data *schema.MetricData, partition int32) (idx.Archive, int32, bool)
- func (m *MemoryIdx) Delete(orgId uint32, pattern string) ([]idx.Archive, error)
- func (m *MemoryIdx) DeleteTagged(orgId uint32, paths []string) ([]idx.Archive, error)
- func (m *MemoryIdx) Find(orgId uint32, pattern string, from int64) ([]idx.Node, error)
- func (m *MemoryIdx) FindByTag(orgId uint32, expressions []string, from int64) ([]idx.Node, error)
- func (m *MemoryIdx) FindTagValues(orgId uint32, tag, prefix string, expressions []string, from int64, limit uint) ([]string, error)
- func (m *MemoryIdx) FindTags(orgId uint32, prefix string, expressions []string, from int64, limit uint) ([]string, error)
- func (m *MemoryIdx) Get(id schema.MKey) (idx.Archive, bool)
- func (m *MemoryIdx) GetPath(orgId uint32, path string) []idx.Archive
- func (m *MemoryIdx) Init() error
- func (m *MemoryIdx) List(orgId uint32) []idx.Archive
- func (m *MemoryIdx) Load(defs []schema.MetricDefinition) int
- func (m *MemoryIdx) Prune(now time.Time) ([]idx.Archive, error)
- func (m *MemoryIdx) Stop()
- func (m *MemoryIdx) TagDetails(orgId uint32, key, filter string, from int64) (map[string]uint64, error)
- func (m *MemoryIdx) Tags(orgId uint32, filter string, from int64) ([]string, error)
- func (m *MemoryIdx) Update(point schema.MetricPoint, partition int32) (idx.Archive, int32, bool)
- func (m *MemoryIdx) UpdateArchive(archive idx.Archive)
- type Node
- type TagIndex
- type TagQuery
- type TagValue
- type TimeLimiter
- type Tree
Constants ¶
const ( EQUAL match = iota // = NOT_EQUAL // != MATCH // =~ regular expression MATCH_TAG // __tag=~ relies on special key __tag. non-standard, required for `/metrics/tags` requests with "filter" NOT_MATCH // !=~ PREFIX // ^= exact prefix, not regex. non-standard, required for auto complete of tag values PREFIX_TAG // __tag^= exact prefix with tag. non-standard, required for auto complete of tag keys )
Variables ¶
var ( Enabled bool TagSupport bool TagQueryWorkers int // number of workers to spin up when evaluation tag expressions IndexRules conf.IndexRules )
Functions ¶
func ConfigProcess ¶
func ConfigProcess()
func ConfigSetup ¶
func ConfigSetup()
Types ¶
type KvReByCost ¶
type KvReByCost []kvRe
func (KvReByCost) Len ¶
func (a KvReByCost) Len() int
func (KvReByCost) Less ¶
func (a KvReByCost) Less(i, j int) bool
func (KvReByCost) Swap ¶
func (a KvReByCost) Swap(i, j int)
type MemoryIdx ¶
Implements the the "MetricIndex" interface
func (*MemoryIdx) AddOrUpdate ¶
func (m *MemoryIdx) AddOrUpdate(mkey schema.MKey, data *schema.MetricData, partition int32) (idx.Archive, int32, bool)
AddOrUpdate returns the corresponding Archive for the MetricData. if it is existing -> updates lastUpdate based on .Time, and partition if was new -> adds new MetricDefinition to index
func (*MemoryIdx) DeleteTagged ¶
func (*MemoryIdx) FindTagValues ¶
func (m *MemoryIdx) FindTagValues(orgId uint32, tag, prefix string, expressions []string, from int64, limit uint) ([]string, error)
FindTagValues returns tag values matching the specified conditions tag: tag key match prefix: value prefix match expressions: tagdb expressions in the same format as graphite from: tags must have at least one metric with LastUpdate >= from limit: the maximum number of results to return
the results will always be sorted alphabetically for consistency
func (*MemoryIdx) FindTags ¶
func (m *MemoryIdx) FindTags(orgId uint32, prefix string, expressions []string, from int64, limit uint) ([]string, error)
FindTags returns tags matching the specified conditions prefix: prefix match expressions: tagdb expressions in the same format as graphite from: tags must have at least one metric with LastUpdate >= from limit: the maximum number of results to return
the results will always be sorted alphabetically for consistency
func (*MemoryIdx) GetPath ¶
GetPath returns the node under the given org and path. this is an alternative to Find for when you have a path, not a pattern, and want to lookup in a specific org tree only.
func (*MemoryIdx) Load ¶
func (m *MemoryIdx) Load(defs []schema.MetricDefinition) int
Used to rebuild the index from an existing set of metricDefinitions.
func (*MemoryIdx) Prune ¶
Prune prunes series from the index if they have become stale per their index-rule
func (*MemoryIdx) TagDetails ¶
func (*MemoryIdx) Tags ¶
Tags returns a list of all tag keys associated with the metrics of a given organization. The return values are filtered by the regex in the second parameter. If the third parameter is >0 then only metrics will be accounted of which the LastUpdate time is >= the given value.
func (*MemoryIdx) Update ¶
Update updates an existing archive, if found. It returns whether it was found, and - if so - the (updated) existing archive and its old partition
func (*MemoryIdx) UpdateArchive ¶
UpdateArchive updates the archive information
type Node ¶
func (*Node) HasChildren ¶
type TagQuery ¶
type TagQuery struct {
// contains filtered or unexported fields
}
TagQuery runs a set of pattern or string matches on tag keys and values against the index. It is executed via: Run() which returns a set of matching MetricIDs RunGetTags() which returns a list of tags of the matching metrics
type TimeLimiter ¶
type TimeLimiter struct {
// contains filtered or unexported fields
}
TimeLimiter limits the rate of a set of serial operations. It does this by tracking how much time has been spent (updated via Add()), and comparing this to the window size and the limit, slowing down further operations as soon as one Add() is called informing it the per-window allowed budget has been exceeded. Limitations: * the last operation is allowed to exceed the budget (but the next call will be delayed to compensate) * concurrency is not supported
For correctness, you should always follow up an Add() with a Wait()
func NewTimeLimiter ¶
func NewTimeLimiter(window, limit time.Duration, now time.Time) *TimeLimiter
NewTimeLimiter creates a new TimeLimiter. limit must <= window
func (*TimeLimiter) Add ¶
func (l *TimeLimiter) Add(d time.Duration)
Add increments the "time spent" counter by "d"
func (*TimeLimiter) Wait ¶
func (l *TimeLimiter) Wait()
Wait returns when we are not rate limited
- if we passed the window, we reset everything (this is only safe for callers that behave correctly, i.e. that wait the instructed time after each add)
- if limit is not reached, no sleep is needed
- if limit has been exceeded, sleep until next period + extra multiple to compensate this is perhaps best explained with an example: if window is 1s and limit 100ms, but we spent 250ms, then we spent effectively 2.5 seconds worth of work. let's say we are 800ms into the 1s window, that means we should sleep 2500-800 = 1.7s in order to maximize work while honoring the imposed limit.
- if limit has been met exactly, sleep until next period (this is a special case of the above)