Help with initial script in API monitoring

17 views
Skip to first unread message

Rajendra Prasad G

unread,
Jul 27, 2022, 9:15:50 PM7/27/22
to BlazeMeter Forum

Hi,

The APIs we are testing takes a session id which is generated using different API.

Current I have added the API to get session ID as step 1 and passing the session ID to the actual API under test in step2.

Now the problem is in logs or statistics we are getting the response time of both the steps whereas we want only the API under test response time.

So to avoid that i wanted to move the step1 which generates session ID to Initial script and set env variable. Can you provide a sample on how to add this code to Initial script or is there any way to exclude the step1 response time and consider only step2 response time.

I tried to use ajax, fetch code to initial script but on execution runscope throws error.

Thanks & Regards,
Rajendra

Dmitri T

unread,
Jul 28, 2022, 3:03:42 AM7/28/22
to BlazeMeter Forum
If you're not interested in the step 1 response time you can use Filter Results Tool to remove the step 1 related sample results from the .jtl results file. Filter Results Tool can be installed using JMeter Plugins Manager

Another option is adding a JSR223 PostProcessor as a child of the Sampler which executes step1 and putting the following code into "Script" area:

prev.setIgnore()

it will instruct JMeter to not to report the step1 sampler to the Listeners and not to store it into the .jtl results file.

In the above code snippet prev stands for previous SampleResult, see the JavaDoc and Top 8 JMeter Java Classes You Should Be Using with Groovy article for more information.

Rajendra Prasad G

unread,
Jul 28, 2022, 5:51:21 AM7/28/22
to BlazeMeter Forum
Thank You Dmitri,

Will try.

How about in Runscope API monitoring?
I have similar test configuration. First step to get session ID and next API under test.
But in dashboard it shows combined response time.
How to consider only step2 response time?

Reply all
Reply to author
Forward
0 new messages