Is there any way to customise the metrics output with --out json=test_results.json flag?

Hello,

We’re running some longer tests and as expected, they produce a lot of metrics. I’m wondering if it is possible to customise what is output as part of the --out flag, to just include http_req_failed, http_req_duration and http_reqs to reduce the file size down a little?

Thanks.

Hi @mto ,

This is not supported and likely will fall under explicit tracking and ignroing of metrics that has not been picked up. And there doesn’t seem to be enough of an interest at this point and we do not have aggreement on how it will work and look.

In the past I have proposed that people can make a fifo file and output metrics to it while runnign grep or some other tool reading from the fifo outputing just what they want.

in one terminal:

mkfifo test.fifo
cat < test.fifo  | grep 'http_reqs' > result.json 
// the cat here is used instead of tail due to https://stackoverflow.com/a/41059622/5427244
// it also happens to exit after a run which might also be desired

in another

k6 run script.js  -i 100 -o json=test.fifo -u 100 

That definitely does work - I have done it and it is fairly performant as I didn’t see any problems while doing it.

But I have no idea if it will work on Windows.

It is also of note that you can add .gz to the end of the file and it will be gzipped which usually has incredibly good compression on the json output

380K	test.json
16K	test.json.gz

Almost 24x compression

Hope this helps you!

1 Like

Thanks @mstoykov, an interesting approach that I will keep in mind. We’re running the tests on a Linux server so that is fine, for now I was just going to do some post processing using Python and JQ, but should take advantage of the gzip compression, our tests from yesterday generated about 11gb of output.

Thanks again.

1 Like