activeseries

package
v0.0.0-...-fbfa8e9 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: AGPL-3.0 Imports: 12 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 *asmodel.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() asmodel.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 *asmodel.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 BucketCountPostings interface {
	index.Postings
	// AtBucketCount returns the series reference currently pointed to and its bucket count (if it's a native histogram series).
	AtBucketCount() (storage.SeriesRef, int)
}

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

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.

func (*NativeHistogramPostings) Seek

Seek 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

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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