# Fetch the total request count during runtime

**URL:** <https://community.gatling.io/t/fetch-the-total-request-count-during-runtime/5932>\
**Category:** Gatling (Open-Source)\
**Created:** [December 12, 2020, 5:56am UTC](https://community.gatling.io/t/fetch-the-total-request-count-during-runtime/5932 "2020-12-12T05:56:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aravind\_G](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@Aravind\_G](https://community.gatling.io/u/Aravind_G)\
**Post date:** [December 12, 2020, 5:56am UTC](https://community.gatling.io/t/fetch-the-total-request-count-during-runtime/5932/1 "2020-12-12T05:56:00Z")

</div>

Hi all,

Could you please tell, if we can get the Ok count or the total request count of a particular API executed at runtime.

I need to execute a condition based on the number of times a particular call is executed.

Regards,  
Aravind.

---

<div class="post-metadata">

**Author:** ![Aravind\_G](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@Aravind\_G](https://community.gatling.io/u/Aravind_G)\
**Post date:** [December 16, 2020, 8:04am UTC](https://community.gatling.io/t/fetch-the-total-request-count-during-runtime/5932/2 "2020-12-16T08:04:54Z")

</div>

Hi All,

Handled this scenario by using the below code and its working now

var a2 = 1;  
/…

.exec(  
session =\> {  
a2 += 1  
session.set(“a2”, a2)  
})  
.doIf(session =\> session(“a2”).as[String].toInt % 5 == (0))(exec(http(“A”) // the request will be triggered every 5th time

.get("/A/")  
.headers(SA)  
.check(status.is(200))))

Regards,  
Aravind
