limits

package
v3.6.7 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultActiveWindow  = 2 * time.Hour
	DefaultRateWindow    = 5 * time.Minute
	DefaultBucketSize    = 1 * time.Minute
	DefaultEvictInterval = 10 * time.Minute
	DefaultNumPartitions = 64
	DefaultConsumerGroup = "ingest-limits"
)
View Source
const (
	// Ring
	RingKey  = "ingest-limits"
	RingName = "ingest-limits"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Enabled enables the ingest limits service.
	Enabled bool `yaml:"enabled"`

	// ActiveWindow defines the duration for which streams are considered
	// active. Streams that have not been updated within the ActiveWindow
	// are considered inactive and are not counted towards limits.
	ActiveWindow time.Duration `yaml:"active_window"`

	// RateWindow defines the time window for rate calculation.
	// This should match the window used in Prometheus rate() queries for consistency,
	// when using the `loki_ingest_limits_ingested_bytes_total` metric.
	RateWindow time.Duration `yaml:"rate_window"`

	// BucketSize defines the size of the buckets used to calculate stream
	// rates. Smaller buckets provide more precise rates but require more
	// memory.
	BucketSize time.Duration `yaml:"bucket_size"`

	// EvictionInterval defines the interval at which old streams are evicted.
	EvictionInterval time.Duration `yaml:"eviction_interval"`

	// The number of partitions for the Kafka topic used to read and write stream metadata.
	// It is fixed, not a maximum.
	NumPartitions int `yaml:"num_partitions"`

	// LifecyclerConfig is the config to build a ring lifecycler.
	LifecyclerConfig ring.LifecyclerConfig `yaml:"lifecycler,omitempty"`
	KafkaConfig      kafka.Config          `yaml:"-"`
	ConsumerGroup    string                `yaml:"consumer_group"`
	Topic            string                `yaml:"topic"`
}

Config represents the configuration for the ingest limits service.

func (*Config) RegisterFlags

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

func (*Config) Validate

func (cfg *Config) Validate() error

type Limits added in v3.6.0

type Limits interface {
	IngestionRateBytes(userID string) float64
	IngestionBurstSizeBytes(userID string) int
	MaxGlobalStreamsPerUser(userID string) int
}

Limits contains all limits enforced by the limits frontend.

type Reason added in v3.6.0

type Reason int
const (
	// ReasonUnknown is the zero value.
	ReasonUnknown Reason = iota
	// ReasonFailed is the reason returned when a stream cannot be checked
	// against limits due to an error.
	ReasonFailed
	// ReasonMaxStreams is returned when a stream cannot be accepted because
	// the tenant has either reached or exceeded their maximum stream limit.
	ReasonMaxStreams
)

func (Reason) String added in v3.6.0

func (r Reason) String() string

type Service added in v3.6.0

type Service struct {
	services.Service
	// contains filtered or unexported fields
}

Service is a service that manages stream metadata limits.

func New added in v3.6.0

func New(cfg Config, limits Limits, logger log.Logger, reg prometheus.Registerer) (*Service, error)

New creates a new IngestLimits service. It initializes the metadata map and sets up a Kafka client The client is configured to consume stream metadata from a dedicated topic with the metadata suffix.

func (*Service) CheckReady added in v3.6.0

func (s *Service) CheckReady(ctx context.Context) error

func (*Service) ExceedsLimits added in v3.6.0

ExceedsLimits implements the proto.IngestLimitsServer interface.

func (*Service) Flush added in v3.6.0

func (s *Service) Flush()

Flush implements ring.FlushTransferer. It transfers state to another ingest limits instance.

func (*Service) GetAssignedPartitions added in v3.6.0

GetAssignedPartitions implements the proto.IngestLimitsServer interface.

func (*Service) ServeHTTP added in v3.6.0

func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements the http.Handler interface. It returns the current stream counts and status per tenant as a JSON response.

func (*Service) TransferOut added in v3.6.0

func (s *Service) TransferOut(_ context.Context) error

TransferOut implements ring.FlushTransferer. It transfers state to another ingest limits instance.

Directories

Path Synopsis
Package client provides gRPC client implementation for limits service.
Package client provides gRPC client implementation for limits service.
Package frontend contains provides a frontend service for ingest limits.
Package frontend contains provides a frontend service for ingest limits.
client
Package client provides gRPC client implementation for limits-frontend.
Package client provides gRPC client implementation for limits-frontend.

Jump to

Keyboard shortcuts

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