# HTTP Monitor: how to pause/sleep between two steps

**URL:** <https://community.dynatrace.com/t/http-monitor-how-to-pause-sleep-between-two-steps/22753>\
**Category:** Synthetic Monitoring\
**Tags:** http-monitor, synthetic-monitoring\
**Created:** [December 16, 2019, 5:05am UTC](https://community.dynatrace.com/t/http-monitor-how-to-pause-sleep-between-two-steps/22753 "2019-12-16T05:05:24Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![sylvain\_baerisw](https://avatars.discourse-cdn.com/v4/letter/s/f08c70/32.png) [@sylvain\_baerisw](https://community.dynatrace.com/u/sylvain_baerisw)\
**Post date:** [December 16, 2019, 5:05am UTC](https://community.dynatrace.com/t/http-monitor-how-to-pause-sleep-between-two-steps/22753/1 "2019-12-16T05:05:24Z")

</div>

Hello,

I have a HTTP monitor use case where I would like to wait/sleep a few seconds between step 1 and 2

- the first step does trigger a non-blocking asynchronous action taking several seconds to complete
- so I need to wait enough before checking for the result with a 2nd API call

Is it possible to add in pre/post execution scripts kind of sleep(### seconds) or something equivalent ?

Thanks.

---

<div class="post-metadata">

**Author:** ![skrystosik](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/skrystosik/32/21133_2.png) [@skrystosik](https://community.dynatrace.com/u/skrystosik)\
**Post date:** [December 16, 2019, 8:25am UTC](https://community.dynatrace.com/t/http-monitor-how-to-pause-sleep-between-two-steps/22753/2 "2019-12-16T08:25:09Z")

</div>

You can use JS I think:

> **[Create an HTTP monitor in Classic](https://docs.dynatrace.com/docs/observe/digital-experience-classic/synthetic-monitoring-classic/http-monitors-classic/create-an-http-monitor-classic)**
>
> Learn how to set up an HTTP monitor to check the performance and availability of your site.

you can execute post execution script for the first step which for example will do:

```auto
setTimeout(function () {
   //you can paste some code here if you need
}, 5000);

```

I’ve never tested it, but should be fine 🙂

Sebastian

---

<div class="post-metadata">

**Author:** ![sylvain\_baerisw](https://avatars.discourse-cdn.com/v4/letter/s/f08c70/32.png) [@sylvain\_baerisw](https://community.dynatrace.com/u/sylvain_baerisw)\
**Post date:** [December 16, 2019, 8:41am UTC](https://community.dynatrace.com/t/http-monitor-how-to-pause-sleep-between-two-steps/22753/3 "2019-12-16T08:41:50Z")

</div>

Thanks [@Sebastian K.](https://answers.dynatrace.com/users/15061/view.html), unfortunately it does not work. I tried something equivalent already (assuming we might be able to execute generic JS script) but it failed.

When I paste your content in a post-execution script, I get the following in log:

```auto
Post script execution failed due to: ReferenceError: "setTimeout" is not defined. (script#1)

```

---

<div class="post-metadata">

**Author:** ![skrystosik](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/skrystosik/32/21133_2.png) [@skrystosik](https://community.dynatrace.com/u/skrystosik)\
**Post date:** [December 16, 2019, 8:50am UTC](https://community.dynatrace.com/t/http-monitor-how-to-pause-sleep-between-two-steps/22753/4 "2019-12-16T08:50:21Z")

</div>

Ok you’re right. Here are possibilities you have:

> **[Pre- and post-execution scripts for HTTP monitors in Classic](https://docs.dynatrace.com/docs/observe/digital-experience/synthetic-monitoring/http-monitors-classic/pre-and-post-scripting-for-http-monitors-classic)**
>
> Learn how to apply pre and post scripts to your requests

I don’t see anything that can be handy here.

As a really dirt workaround may be creating some page with setTimeout set that you may use as request in the middle which will takes amount of time defined in query parameter.

Sebastian

---

<div class="post-metadata">

**Author:** ![sylvain\_baerisw](https://avatars.discourse-cdn.com/v4/letter/s/f08c70/32.png) [@sylvain\_baerisw](https://community.dynatrace.com/u/sylvain_baerisw)\
**Post date:** [December 16, 2019, 8:52am UTC](https://community.dynatrace.com/t/http-monitor-how-to-pause-sleep-between-two-steps/22753/5 "2019-12-16T08:52:52Z")

</div>

yes, me too. I reviewed this documentation already. That is why I posted on this forum. I was hoping for some hidden trick.

thanks anyway for your help.

---

<div class="post-metadata">

**Author:** ![Yosi\_Neuman](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/yosi_neuman/32/9845_2.png) [@Yosi\_Neuman](https://community.dynatrace.com/u/Yosi_Neuman)\
**Post date:** [December 16, 2019, 9:32am UTC](https://community.dynatrace.com/t/http-monitor-how-to-pause-sleep-between-two-steps/22753/6 "2019-12-16T09:32:26Z")

</div>

Hi guys

Long shot but you should give it a try and use browser test where you can add wait after step and run JavaScripts.

HTH

Yos

---

<div class="post-metadata">

**Author:** ![sylvain\_baerisw](https://avatars.discourse-cdn.com/v4/letter/s/f08c70/32.png) [@sylvain\_baerisw](https://community.dynatrace.com/u/sylvain_baerisw)\
**Post date:** [December 16, 2019, 10:53am UTC](https://community.dynatrace.com/t/http-monitor-how-to-pause-sleep-between-two-steps/22753/7 "2019-12-16T10:53:08Z")

</div>

unfortunately not for this specific use case as I am testing an API

---

<div class="post-metadata">

**Author:** ![Julius\_Loman](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/julius_loman/32/51_2.png) [@Julius\_Loman](https://community.dynatrace.com/u/Julius_Loman)\
**Post date:** [January 13, 2020, 8:23am UTC](https://community.dynatrace.com/t/http-monitor-how-to-pause-sleep-between-two-steps/22753/8 "2020-01-13T08:23:20Z")

</div>

Would a dummy API call to sleep for a given time solve your problem? For example, the postman echo service has such endpoint if you don’t want to create your own.

This URL will, for example, wait 2 seconds between ending with a response:

```auto
https://postman-echo.com/delay/2

```

---

<div class="post-metadata">

**Author:** ![sylvain\_baerisw](https://avatars.discourse-cdn.com/v4/letter/s/f08c70/32.png) [@sylvain\_baerisw](https://community.dynatrace.com/u/sylvain_baerisw)\
**Post date:** [January 13, 2020, 12:30pm UTC](https://community.dynatrace.com/t/http-monitor-how-to-pause-sleep-between-two-steps/22753/9 "2020-01-13T12:30:01Z")

</div>

This is an interesting approach. Although I would prefer to avoid being dependent on a 3rd party API, I will definitely consider your idea.

Thanks a lot.

---

<div class="post-metadata">

**Author:** ![Julius\_Loman](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/julius_loman/32/51_2.png) [@Julius\_Loman](https://community.dynatrace.com/u/Julius_Loman)\
**Post date:** [January 13, 2020, 12:59pm UTC](https://community.dynatrace.com/t/http-monitor-how-to-pause-sleep-between-two-steps/22753/10 "2020-01-13T12:59:23Z")

</div>

Agreed, but this is just an example. Sure you can deploy such API endpoint in your environment and it will be definitely the most simple one service you will have :-).
