We have a swagger API which outputs a JSON response that has status detail about the execution of our batchjob.
In my post execution script of HTTPMonitor of Dynatrace synthetics, I have this logic
responseObject = JSON.parse(response.getResponseBody());
responseObject.runs.forEach(x => {
if (x.success != true) {
api.fail(x.id + " failed");
}
});
Batch jobs runs once a day. Our swagger JSON response has status details of last 50executions in the JSON body. I’m only interested in the 0 response - which has the status info of basically today’s execution & ignore all the rest. The above logic works when last 50th execution has no “success :fail” in them
Anyone knows how to limit the search in post execution script of an HTTP Monitor to only look for 0 iteration, or , search first 20lines only & ignore rest of the JSON payload, and if you find “success :true” that means batch job ran successfully. Because first 20 lines has the last execution detail in it..

