# Logstash generate a random number for an HTTP wait request?

**URL:** <https://discuss.elastic.co/t/logstash-generate-a-random-number-for-an-http-wait-request/226936>\
**Category:** Logstash\
**Created:** [April 7, 2020, 3:25pm UTC](https://discuss.elastic.co/t/logstash-generate-a-random-number-for-an-http-wait-request/226936 "2020-04-07T15:25:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![stcdarrell](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@stcdarrell](https://discuss.elastic.co/u/stcdarrell)\
**Post date:** [April 7, 2020, 3:25pm UTC](https://discuss.elastic.co/t/logstash-generate-a-random-number-for-an-http-wait-request/226936/1 "2020-04-07T15:25:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [April 7, 2020, 3:40pm UTC](https://discuss.elastic.co/t/logstash-generate-a-random-number-for-an-http-wait-request/226936/2 "2020-04-07T15:40:06Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![stcdarrell](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@stcdarrell](https://discuss.elastic.co/u/stcdarrell)\
**Post date:** [April 7, 2020, 3:53pm UTC](https://discuss.elastic.co/t/logstash-generate-a-random-number-for-an-http-wait-request/226936/3 "2020-04-07T15:53:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 5, 2020, 3:53pm UTC](https://discuss.elastic.co/t/logstash-generate-a-random-number-for-an-http-wait-request/226936/4 "2020-05-05T15:53:53Z")

</div>

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