activeseries

package
v0.0.0-...-51498b2 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
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) 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) 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 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

func (cfg *Config) RegisterFlags(f *flag.FlagSet)

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) 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) Len

func (m *Matchers) Len() int

func (*Matchers) Less

func (m *Matchers) Less(i, j int) bool

func (*Matchers) MatcherNames

func (m *Matchers) MatcherNames() []string

func (*Matchers) Swap

func (m *Matchers) Swap(i, j int)

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

func (*Postings) At

func (a *Postings) At() storage.SeriesRef

At implements index.Postings.

func (*Postings) Err

func (a *Postings) Err() error

Err implements index.Postings.

func (*Postings) Next

func (a *Postings) Next() bool

Next implements index.Postings.

func (*Postings) Seek

func (a *Postings) Seek(v storage.SeriesRef) bool

Seek implements index.Postings.

type PostingsReader

type PostingsReader interface {
	Postings(ctx context.Context, name string, values ...string) (index.Postings, error)
}

Jump to

Keyboard shortcuts

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