telegraf icon indicating copy to clipboard operation
telegraf copied to clipboard

Telegraf Rate limiting feature - the ability to detect and reduce spikes in traffic automatically

Open edbernier opened this issue 8 years ago • 7 comments

Feature Request

Requesting an ability to add rate limiting capability to Telegraf. For example: If traffic increased more than x% for any series reduce the rate by randomizing the data by the same percentage increase to maintain a certain ingest rate.

Proposal:

We need to have some kind of rate limiting features. These are some of the things we are looking for…

a. A simple % sampling based on TAG or MEASUREMENT criteria set

CRITERIA_SET_1: SAMPLE_RATE # i.e., 0.1 or 10% CRITERIA_SET_2: SAMPLE_RATE DEFAULT: SAMPLE_RATE

b. Another thing we may want as an alternative to an explicit rate is a count over time parameter, possibly mixed and matched with sample rate…

CRITERIA_SET_1: SAMPLE_RATE CRITERIA_SET_2: N PER TIME # i.e., 100000 PER 1h DEFAULT: SAMPLE_RATE

edbernier avatar May 18 '18 22:05 edbernier

Important complementary feature to https://github.com/influxdata/influxdb/issues/9878

JimHagan avatar May 21 '18 14:05 JimHagan

Also see this feature request for a monitoring cardinality #4124

danielnelson avatar May 21 '18 18:05 danielnelson

@edbernier I believe as we understand our pain points better the number one thing that could get u sin the direction of rate limiting would be to have the ability to add a simple drop_rate associated with names or tag values in the namedrop and tagdrop functions.

For example a short term fix could be...

Configuration may look like


namedrop = ["function_execution_time:0.5","HealthCheck*:0.8","other_metric"]

In this scenario we are saying drop 50% of functional_execution_time and 80% of HealthCheck* and by default 100% of other_metric. It could work similarly with namepass where the % is indicates what % to keep. This can be done by a simple random number / coin flip algorithm to start. No need to take into a account temporal issues.

JimHagan avatar Aug 06 '18 21:08 JimHagan

I think this would work well as a processor. The processor can select metrics using measurement filtering and skip every 1/factor metrics.

Example that skips half of the cpu measurements:

[[processors.sample]]
  namepass = ["cpu"]
  factor = 0.5

danielnelson avatar Aug 07 '18 00:08 danielnelson

is reducing the data collection rate a "simple" (i.e. no code) option? Doesn't it achieve the same result??

timhallinflux avatar Aug 08 '18 19:08 timhallinflux

For metrics produced by Telegraf via polling I would say yes, but if the metrics are produced by another application and sent to a service input it may be difficult to limit the amount of data.

In this case another solution might be to use an aggregator such as basicstats or histogram to report the aggregate metrics only.

danielnelson avatar Aug 08 '18 20:08 danielnelson

Telegraf has changed a lot since this issue was filed. In some cases it can now use backpressure to stop gathering metrics when outputs can't keep up writing what is queued.

Since so much has changed since this was filed it makes sense to me to close this. If you have specific needs related to rate limiting please open a new issue and reference this one. Thanks!

reimda avatar May 26 '22 20:05 reimda