throttle

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2022 License: BSD-3-Clause Imports: 7 Imported by: 0

README

Throttle plugin

It discards the events if pipeline throughput gets higher than a configured threshold.

Config params

throttle_field cfg.FieldSelector

The event field which will be used as a key for throttling. It means that throttling will work separately for events with different keys. If not set, it's assumed that all events have the same key.


time_field cfg.FieldSelector default=time

The event field which defines the time when event was fired. It is used to detect the event throughput in a particular time range. If not set, the current time will be taken.


time_field_format string default=rfc3339nano options=ansic|unixdate|rubydate|rfc822|rfc822z|rfc850|rfc1123|rfc1123z|rfc3339|rfc3339nano|kitchen|stamp|stampmilli|stampmicro|stampnano

It defines how to parse the time field format.


default_limit int64 default=5000

The default events limit that plugin allows per interval


limit_kind string default=count options=count|size

What we're limiting: number of messages, or total size of the messages


buckets_count int default=60

How much time buckets to hold in the memory. E.g. if buckets_count is 60 and interval is 5m, then 5 hours will be covered. Events with time later than now() - 5h will be dropped even if threshold isn't exceeded.


bucket_interval cfg.Duration default=1m

Time interval to check event throughput.


rules []RuleConfig

Rules to override the default_limit for different group of event. It's a list of objects. Each object has the limit and conditions fields.

  • limit – the value which will override the default_limit, if conditions are met.
  • limit_kind – the type of a limit: count - number of messages, size - total size from all messages
  • conditions – the map of event field name => event field value. The conditions are checked using AND operator.


Generated using insane-doc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLimiter

func NewLimiter(interval time.Duration, bucketCount int, limit complexLimit) *limiter

func NewRule

func NewRule(conditions map[string]string, limit complexLimit) *rule

NewRule returns new Limit instance.

Types

type Config

type Config struct {
	//> @3@4@5@6
	//>
	//> The event field which will be used as a key for throttling.
	//> It means that throttling will work separately for events with different keys.
	//> If not set, it's assumed that all events have the same key.
	ThrottleField  cfg.FieldSelector `json:"throttle_field" default:"" parse:"selector"` //*
	ThrottleField_ []string

	//> @3@4@5@6
	//>
	//> The event field which defines the time when event was fired.
	//> It is used to detect the event throughput in a particular time range.
	//> If not set, the current time will be taken.
	TimeField  cfg.FieldSelector `json:"time_field" default:"time"` //*
	TimeField_ []string

	//> @3@4@5@6
	//>
	//> It defines how to parse the time field format.
	TimeFieldFormat string `` //*
	/* 185-byte string literal not displayed */

	//> @3@4@5@6
	//>
	//> The default events limit that plugin allows per `interval`
	DefaultLimit int64 `json:"default_limit" default:"5000"` //*

	//> @3@4@5@6
	//>
	//> What we're limiting: number of messages, or total size of the messages
	LimitKind string `json:"limit_kind" default:"count" options:"count|size"` //*

	//> @3@4@5@6
	//>
	//> How much time buckets to hold in the memory. E.g. if `buckets_count` is `60` and `interval` is `5m`,
	//> then `5 hours` will be covered. Events with time later than `now() - 5h` will be dropped even if threshold isn't exceeded.
	BucketsCount int `json:"buckets_count" default:"60"` //*

	//> @3@4@5@6
	//>
	//> Time interval to check event throughput.
	BucketInterval  cfg.Duration `json:"bucket_interval" parse:"duration" default:"1m"` //*
	BucketInterval_ time.Duration

	//> @3@4@5@6
	//>
	//> Rules to override the `default_limit` for different group of event. It's a list of objects.
	//> Each object has the `limit` and `conditions` fields.
	//> * `limit` – the value which will override the `default_limit`, if `conditions` are met.
	//> * `limit_kind` – the type of a limit: `count` - number of messages, `size` - total size from all messages
	//> * `conditions` – the map of `event field name => event field value`. The conditions are checked using `AND` operator.
	Rules []RuleConfig `json:"rules" default:"" slice:"true"` //*
}

! config-params ^ config-params

type Plugin

type Plugin struct {
	// contains filtered or unexported fields
}

{ introduction It discards the events if pipeline throughput gets higher than a configured threshold. }

func (*Plugin) Do

func (p *Plugin) Do(event *pipeline.Event) pipeline.ActionResult

func (*Plugin) Start

func (p *Plugin) Start(config pipeline.AnyConfig, params *pipeline.ActionPluginParams)

func (*Plugin) Stop

func (p *Plugin) Stop()

type RuleConfig

type RuleConfig struct {
	Limit      int64             `json:"limit"`
	LimitKind  string            `json:"limit_kind" default:"count" options:"count|size"`
	Conditions map[string]string `json:"conditions"`
}

Jump to

Keyboard shortcuts

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