Logstash generate a random number for an HTTP wait request?

i have a logstash http filter that reaches out to a public API for enrichment of the data. i'm limited to 1 request per second.

i've thrown a "sleep" filter in.. to make it wait 1 second.. i'm still getting "request limit reached" i'm guessing because logstash is multi-threaded and sending more than one request at a time.

the only solution i can thing of is making thje sleep a random amount between 1-10 seconds.. so each threat waits a different amount of time.

is there a way to do this easily?
sleep {
time => %[random number between 1 and 10]%
every => "1"

i hope that makes sense

Well you could set pipeline.workers to 1 to eliminate the multi-threading. That will restrict your throughput, but in your case that is exactly what you want :slight_smile:

i tried that, i'm still running into it.. i set. pipeline workers to 1 and sleep to 2 seconds.
i'm just querying the API too often.

thank you for your help.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.