Documentation ¶
Index ¶
- Constants
- func IsLabelValueActive(ctx context.Context, reader PostingsReader, activeSeries *ActiveSeries, ...) (bool, error)
- type ActiveSeries
- func (c *ActiveSeries) Active() (total, totalNativeHistograms, totalNativeHistogramBuckets int)
- func (c *ActiveSeries) ActiveWithMatchers() (total int, totalMatching []int, totalNativeHistograms int, ...)
- func (c *ActiveSeries) Clear()
- func (c *ActiveSeries) ContainsRef(ref storage.SeriesRef) bool
- func (c *ActiveSeries) CurrentConfig() CustomTrackersConfig
- func (c *ActiveSeries) CurrentMatcherNames() []string
- func (c *ActiveSeries) Delete(ref chunks.HeadSeriesRef)
- func (c *ActiveSeries) NativeHistogramBuckets(ref storage.SeriesRef) (int, bool)
- func (c *ActiveSeries) PostDeletion(deleted map[chunks.HeadSeriesRef]labels.Labels)
- func (c *ActiveSeries) Purge(now time.Time) bool
- func (c *ActiveSeries) ReloadMatchers(asm *Matchers, now time.Time)
- func (c *ActiveSeries) UpdateSeries(series labels.Labels, ref storage.SeriesRef, now time.Time, ...)
- type BucketCountPostings
- type Config
- type CustomTrackersConfig
- func (c CustomTrackersConfig) Empty() bool
- func (c CustomTrackersConfig) Equal(other CustomTrackersConfig) bool
- func (c CustomTrackersConfig) ExampleDoc() (comment string, yaml interface{})
- func (c CustomTrackersConfig) MarshalYAML() (interface{}, error)
- func (c *CustomTrackersConfig) Set(s string) error
- func (c CustomTrackersConfig) String() string
- func (c *CustomTrackersConfig) UnmarshalYAML(value *yaml.Node) error
- type Matchers
- type NativeHistogramPostings
- type Postings
- type PostingsReader
Constants ¶
const ( EnabledFlag = "ingester.active-series-metrics-enabled" IdleTimeoutFlag = "ingester.active-series-metrics-idle-timeout" )
Variables ¶
This section is empty.
Functions ¶
func IsLabelValueActive ¶
func IsLabelValueActive(ctx context.Context, reader PostingsReader, activeSeries *ActiveSeries, name, value string) (bool, error)
Types ¶
type ActiveSeries ¶
type ActiveSeries struct {
// contains filtered or unexported fields
}
ActiveSeries is keeping track of recently active series for a single tenant.
func NewActiveSeries ¶
func NewActiveSeries(asm *Matchers, timeout time.Duration) *ActiveSeries
func (*ActiveSeries) Active ¶
func (c *ActiveSeries) Active() (total, totalNativeHistograms, totalNativeHistogramBuckets int)
Active returns the total numbers of active series, active native histogram series, and buckets of those native histogram series. This method does not purge expired entries, so Purge should be called periodically.
func (*ActiveSeries) ActiveWithMatchers ¶
func (c *ActiveSeries) ActiveWithMatchers() (total int, totalMatching []int, totalNativeHistograms int, totalMatchingNativeHistograms []int, totalNativeHistogramBuckets int, totalMatchingNativeHistogramBuckets []int)
ActiveWithMatchers returns the total number of active series, as well as a slice of active series matching each one of the custom trackers provided (in the same order as custom trackers are defined), and then the same thing for only active series that are native histograms, then the same for the number of buckets in those active native histogram series. This method does not purge expired entries, so Purge should be called periodically.
func (*ActiveSeries) Clear ¶
func (c *ActiveSeries) Clear()
func (*ActiveSeries) ContainsRef ¶
func (c *ActiveSeries) ContainsRef(ref storage.SeriesRef) bool
func (*ActiveSeries) CurrentConfig ¶
func (c *ActiveSeries) CurrentConfig() CustomTrackersConfig
func (*ActiveSeries) CurrentMatcherNames ¶
func (c *ActiveSeries) CurrentMatcherNames() []string
func (*ActiveSeries) Delete ¶
func (c *ActiveSeries) Delete(ref chunks.HeadSeriesRef)
func (*ActiveSeries) NativeHistogramBuckets ¶
func (c *ActiveSeries) NativeHistogramBuckets(ref storage.SeriesRef) (int, bool)
func (*ActiveSeries) PostDeletion ¶
func (c *ActiveSeries) PostDeletion(deleted map[chunks.HeadSeriesRef]labels.Labels)
PostDeletion should be called when series are deleted from the head. Sometimes series can be deleted before they're considered inactive (this happens with OOO series), in this case we need to mark those series as deleted and save their labels to avoid accounting from them twice if new series for same labels is created shortly after.
func (*ActiveSeries) Purge ¶
func (c *ActiveSeries) Purge(now time.Time) bool
Purge purges expired entries and returns true if enough time has passed since last reload. This should be called periodically to avoid unbounded memory growth.
func (*ActiveSeries) ReloadMatchers ¶
func (c *ActiveSeries) ReloadMatchers(asm *Matchers, now time.Time)
func (*ActiveSeries) UpdateSeries ¶
func (c *ActiveSeries) UpdateSeries(series labels.Labels, ref storage.SeriesRef, now time.Time, numNativeHistogramBuckets int)
UpdateSeries updates series timestamp to 'now'. Function is called to make a copy of labels if entry doesn't exist yet. Pass -1 in numNativeHistogramBuckets if the series is not a native histogram series.
type BucketCountPostings ¶
type Config ¶
type Config struct { Enabled bool `yaml:"active_series_metrics_enabled" category:"advanced"` UpdatePeriod time.Duration `yaml:"active_series_metrics_update_period" category:"advanced"` IdleTimeout time.Duration `yaml:"active_series_metrics_idle_timeout" category:"advanced"` }
func (*Config) RegisterFlags ¶
type CustomTrackersConfig ¶
type CustomTrackersConfig struct {
// contains filtered or unexported fields
}
CustomTrackersConfig configures active series custom trackers. It can be set using a flag, or parsed from yaml.
func NewCustomTrackersConfig ¶
func NewCustomTrackersConfig(m map[string]string) (c CustomTrackersConfig, err error)
func (CustomTrackersConfig) Empty ¶
func (c CustomTrackersConfig) Empty() bool
func (CustomTrackersConfig) Equal ¶
func (c CustomTrackersConfig) Equal(other CustomTrackersConfig) bool
Equal compares two CustomTrackersConfig. This is needed to allow cmp.Equal to compare two CustomTrackersConfig.
func (CustomTrackersConfig) ExampleDoc ¶
func (c CustomTrackersConfig) ExampleDoc() (comment string, yaml interface{})
ExampleDoc provides an example doc for this config, especially valuable since it's custom-unmarshaled.
func (CustomTrackersConfig) MarshalYAML ¶
func (c CustomTrackersConfig) MarshalYAML() (interface{}, error)
MarshalYAML implements yaml.Marshaler.
func (*CustomTrackersConfig) Set ¶
func (c *CustomTrackersConfig) Set(s string) error
Set implements flag.Value, and is used to set the config value from a flag value provided as string.
func (CustomTrackersConfig) String ¶
func (c CustomTrackersConfig) String() string
String is a canonical representation of the config, it is compatible with flag definition. String is also needed to implement flag.Value.
func (*CustomTrackersConfig) UnmarshalYAML ¶
func (c *CustomTrackersConfig) UnmarshalYAML(value *yaml.Node) error
UnmarshalYAML implements the yaml.Unmarshaler interface. CustomTrackersConfig are marshaled in yaml as a map[string]string, with matcher names as keys and strings as matchers definitions.
type Matchers ¶
type Matchers struct {
// contains filtered or unexported fields
}
func NewMatchers ¶
func NewMatchers(matchersConfig CustomTrackersConfig) *Matchers
func (*Matchers) Config ¶
func (m *Matchers) Config() CustomTrackersConfig
func (*Matchers) MatcherNames ¶
type NativeHistogramPostings ¶
type NativeHistogramPostings struct {
// contains filtered or unexported fields
}
NativeHistogramPostings is a wrapper around ActiveSeries and index.Postings. Similar to Postings, but filters its output to native histogram series. Implements index.Postings interface and returns only series references that are active in ActiveSeries and are native histograms. It is only valid to use NativeHistogramPostings if the postings are from the open TSDB head. It is not valid to use NativeHistogramPostings if the postings are from a block.
func NewNativeHistogramPostings ¶
func NewNativeHistogramPostings(activeSeries *ActiveSeries, postings index.Postings) *NativeHistogramPostings
func (*NativeHistogramPostings) At ¶
func (a *NativeHistogramPostings) At() storage.SeriesRef
At implements index.Postings.
func (*NativeHistogramPostings) AtBucketCount ¶
func (a *NativeHistogramPostings) AtBucketCount() (storage.SeriesRef, int)
AtBucketCount returns the current bucket count for the series reference at the current position.
func (*NativeHistogramPostings) Err ¶
func (a *NativeHistogramPostings) Err() error
Err implements index.Postings.
func (*NativeHistogramPostings) Next ¶
func (a *NativeHistogramPostings) Next() bool
Next implements index.Postings.
type Postings ¶
type Postings struct {
// contains filtered or unexported fields
}
Postings is a wrapper around ActiveSeries and index.Postings. It implements index.Postings interface and returns only series references that are active in ActiveSeries. It is only valid to use Postings if the postings are from the open TSDB head. It is not valid to use Postings if the postings are from a block.
func NewPostings ¶
func NewPostings(activeSeries *ActiveSeries, postings index.Postings) *Postings