-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSON Output is Formatted Incorrectly #737
Comments
jq is so good at handling this type of output that I hadn't noticed until now 😅 |
Having the output as separate chunks of JSON makes it a bit easier to process the file a line at a time. Sometimes the output files are quite large. |
I'd like to second this as an issue. Although @MichaelWeirWeather is correct if you are following output, it makes it difficult to parse it into JS out of the box. If you're dealing with the outputted file, you still need to load in the file and then navigate by line. For example, if you want to use the output in the browser either you do some post-processing on the created file, or load in the file using |
Re-reading this issue, I think this would be better implemented as an optional configuration in the current JSON metrics collector. That way we won't have to make a braking change and users who depend on the current output (which in some instances would be easier to parse than the full-array one) won't be affected. But if you want to output proper JSON arrays, you should just be able to set a flag and have the output that way. Implementation wise, it would be best to do this after #587 is done, but we can also probably do it as a quick fix before that and have it accessible from an environment variable like |
JSON array would be great, I can't process the result without pre-processing via jq |
Hi, since no one mentioned it. This is not a bug. The format is well know as newline delimited JSON. It is used in two cases. First you want to process that data before it is complete. Aka streaming data. Same use case as partitioning. All this is working pretty nice with command line tools. If we use this format. It's kind of the same use case. But once the file is huge enough, like you are running a high performance test for 2 hours, it can become difficult to parse the whole file at once. The best way is to use one of the tools from above. |
@enc is right and this is not a bug, seems we have just forgotten to remove the label. Because of the reasons he mentioned and also because we don't want to make breaking changes, we are not going to change the current default behavior. That said, I think having the option to generate well-formed JSON arrays may be useful to some people. 🤷♂️ It will be easy to implement and I imagine that some streaming JSON parsers might not support newline delimited JSON. The only reason we haven't implemented that option so far is that the JSON output currently doesn't have support for any options... 😅 That should be easy to add after the recent output refactoring (#1869), and we want to make other things configurable anyway: Lines 36 to 37 in a33b054
|
Hey, let's keep this open - as I mentioned, while it's not a bug, it's probably still a minor improvement if we add an option to output well-formed JSON arrays 🙂 |
The maintainers' team has discussed this and agreed to close it in favor of grafana/k6-docs#1191. The JSON output behaves as intended by using the JSON Lines format, but it is not well enough documented, and we want to address that instead 🙇🏻 |
Expected Behavior
results.json
file should have valid JSON formatting like this:Actual Behavior
results.json
is invalid as seen below. it is not an array of objects...just simply lines of objectsSteps to Reproduce the Problem
k6 run -r json=results.json github.com/loadimpact/k6/samples/http_get.js
results.json
Specifications
The text was updated successfully, but these errors were encountered: