You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is not a bug, we are intentionally putting one JSON object per line. If we want to be technically correct, the output should have been called jsonl, since this type of file is called "JSON Lines", see https://jsonlines.org/
We do it like this because, for big k6 tests, this file could grow to be several gigabytes of data. When every object is on a separate line, it's much easier to process that data in a streaming fashion, without loading the whole file in memory.
For example, the easiest way to do that is probably a tool like jq, though it can also be done in any programming language you may want to use. True, people could have used a streaming JSON parser even if it was all one big JSON array, but you can also do that now, or read the file line by line and use a regular JSON parser. We have some example of how you can use jq to process the file in our docs, see https://k6.io/docs/results-output/real-time/json/#processing-json-output
And, if you really want an array, you can use jq to transform our format to that too, simply run jq -s '.' results-jsonlines.json > results-array.json (copied from this StackOverflow topic).
Finally, we have another open issue that is about adding an option to the k6 json output to emit a well-formed JSON array, see #737. I'll close this issue, since it's a duplicate, but please 👍 the other issue. We'd probably also accept a quality PR with the functionality, if you or someone else is willing to contribute that!
Brief summary
image: "grafana/k6"
command: "k6 run --out json=test.json /app/smoke.js"
version: "k6 v0.43.1 (2023-02-27T10:52:44+0000/v0.43.1-0-gaf3a0b89, go1.19.6, linux/amd64)"
Using the sample script in "https://k6.io/docs/test-types/smoke-testing/" the output is a non valid json file
k6 version
k6 v0.43.1 (2023-02-27T10:52:44+0000/v0.43.1-0-gaf3a0b89, go1.19.6, linux/amd64)
OS
linux
Docker version and image (if applicable)
grafana/k6
Steps to reproduce the problem
Run the sample script with "--out json=some-file.json"
Expected behaviour
Should be, at least, a valid json.
Nice to have is to join nodes under metric types or similar to allow parsing it
Actual behaviour
The json file is not valid
The text was updated successfully, but these errors were encountered: