Hmm.
Are you getting duration values for events where start or end is null? If not, do this.
| stats min(eval(if(match(lower(_raw), "security gate check"), _time, null()))) as start, max(eval(if(match(lower(_raw), "found valid consumer for identity"), _time, null()))) as end by trace
| eval duration = end-start | search duration=*
| stats avg(duration) as Average_Response_Time, count as total
... View more