Skip to content

export the results as a json file #3089

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

Open
2 tasks done
kasir-barati opened this issue Apr 4, 2025 · 2 comments
Open
2 tasks done

export the results as a json file #3089

kasir-barati opened this issue Apr 4, 2025 · 2 comments

Comments

@kasir-barati
Copy link

kasir-barati commented Apr 4, 2025

Prerequisites

Description

Hi,

When I run locust --help I can see that we are allowed to pass --json as a flag to see the result of tests as a JSON, but what I need is to store that json in a file. Is it possible to implement this feature?

I know for csv you can pass a filename and it will store the result in that file but this is not the case for json which makes me wonder why not? It should be almost the same as csv IMO.

$ locust --help
# ...
Request statistics options:
  --csv <filename>      Store request stats to files in CSV format. Setting this option will generate three files: <filename>_stats.csv, <filename>_stats_history.csv and
                        <filename>_failures.csv. Any folders part of the prefix will be automatically created
  --csv-full-history    Store each stats entry in CSV format to _stats_history.csv file. You must also specify the '--csv' argument to enable this.
  --print-stats         Enable periodic printing of request stats in UI runs
  --only-summary        Disable periodic printing of request stats during --headless run
  --reset-stats         Reset statistics once spawning has been completed. Should be set on both master and workers when running in distributed mode
  --html <filename>     Store HTML report to file path specified. Able to parse certain tags - {u}, {r}, {t} and convert them to number of users, spawn rate and run time
                        respectively.
  --json                Prints the final stats in JSON format to stdout. Useful for parsing the results in other programs/scripts. Use together with --headless and --skip-log
                        for an output only with the json data.
# ...
@cyberw
Copy link
Collaborator

cyberw commented Apr 4, 2025

I guess we could support a filename there as well. But you can just do locust --json > myfile.json

@Cnoor0171
Copy link

It would nice to have the json argument accept a filename because redirecting the stdout to a json file requires that you use --skip-log to make sure the output is valid json. In a CICD pipeline, for example, you still want to show the relevant log statements, but then want to upload the final result file afterwards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants