Capture K6 Browser réponse times for specific events

I would like to use K6 Browser to capture response times for specific events. For example I would like to know exactly how long it takes to log on and how long for the search to complete. What is the best way to do this so that the metrics can be sent to grafana.

Logon_transaction
wait for logon
Logon_transaction

Search_transaction
Wait for Search
Search_transaction

I could do the following but this information is not sent to the summary or grafana by default:

const requestDate = new Date();
// your request: await request …
const responseDate = new Date();
console.log(responseDate - requestDate)

Hi @pbains1 ,

You can define a custom k6 metric to measure this time. See the documentation here.
Also see this post which gives an example on how to do exactly what you are trying to achieve.

Let me know if that helps!

2 Likes

Thanks, thats exactly what i was looking for.