“Hello everyone, I’m looking for a way to consume (read) k6 events such as start, stop, error, and complete. Currently, I’m overriding the export function handleSummary(data) {} to get the data and then calling a remote server to save it. Is there any other method or way to directly read these events in k6? Any insights or suggestions would be greatly appreciated. Thank you!”
Hi @saik6 , Welcome to the community forum!
You can subscribe some type of events (k6/event/type.go at 47c5bb0f5608897f6961b9cb2260357a824acbfe · grafana/k6 · GitHub) in a custom k6 extension, but I don’t think you can do it in the test javascript script only.
If you want to send the test metrics to a remote server, you have some options:
- there are already a couple of extensions for it: k6 Extensions (look for the ones starting with xk6-output-)
- you can export the metrics into a csv or json file and process it after the test run (Real time)
- you can write your own output extension in go (Output Extensions)
- or you can write a plugin for GitHub - szkiba/xk6-output-plugin: Write k6 output extension as a dynamically loadable plugin using your favorite programming language
I hope my answer helps.