Post results both summary and timeseries data to an HTTP endpoint

Is there a way to have k6 do an HTTPS POST to an external endpoint that essentially uploads the summary and detailed timeseries data files?

It would be great if it could be specified as a parameter to the test or a way to provide a simple url as the output POST with fileUpload parameters.

This would be done at the end of the test when the Summary and Detailed TimeSeries data file (JSON) are ready. I think I can do this with the summary in the handleSummary() method but I am not sure if it allows access to the file since it is not part of the init , but rather is an output by k6 tool.

Hi @robdgeorge, Welcome to the community forum :tada:

What do you mean by detailed timeseries data files ?

Do you mean an output like the JSON one

Hi mstoykov,

Yes, the actual test results with the detailed data available at the end of the test, in JSON format from the output. I have a custom reporting I am trying to do that would take in both the summary and the detailed data that you get from:
k6 run --out json=my_test_result.json script.js

What I want to get is something like how the --out parameter works in the case of influxdb where you can provide the url to send results to:
–out influxdb=http://localhost:8086/k6

So is there a way to do something like this in json format:
–out myhost=http://hostx/k6testresultsprocessor

So, from what I have learned, it appaears handleSummary(data) provides the summary data, but not the detailed data like what you see in the --out json=x.json. I don’t think k6 will let me read that json file, is that a correct assumption? If it can then I could just open the json file and post the contents to my endpoint.

I would recommend just running a simple curl command (or similar) after k6 finishes.

Even if we let you load the file it will be pretty big, which will likely mean you will run out of memory. Also k6 might not have flushed all that data so again … not a great idea IMO.

Especially if you are going to be doing this in CI - having one more step which is uploading the final JSON seems like a perfectly fine solution to me.

Hope this helps you

Okay, yes, that does make sense, k6 does not need to be the processor of thst data. Thanks for the quick response.