Skip to content
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

Add option to output the final stats in JSON to stdout #167

Closed
wants to merge 3 commits into from

Conversation

bbakersmith
Copy link
Contributor

I would like to run Siege and interpret the results programmatically, particularly in an automated CI environment. Having the option to print the results as JSON to stdout would make Siege easier to integrate with other scripts and tools.

This PR addresses feature request #151

@JoeDog
Copy link
Owner

JoeDog commented Feb 9, 2020

What is your expected output? This is what I get with -j

Eniac $ siege -j -c2 -r2 https://www.joedog.org/
Verbose mode is disabled for JSON output.
** SIEGE 4.0.4rc3
** Preparing 2 concurrent users for battle.
The server is now under siege...
Transactions: 124 hits
Availability: 100.00 %
Elapsed time: 9.35 secs
Data transferred: 3.76 MB
Response time: 0.15 secs
Transaction rate: 13.26 trans/sec
Throughput: 0.40 MB/sec
Concurrency: 1.98
Successful transactions: 124
Failed transactions: 0
Longest transaction: 0.83
Shortest transaction: 0.10

{ "transactions": 124,
"availability": 100.00,
"elapsed_time": 9.35,
"data_transferred": 3.76,
"response_time": 0.15,
"transaction_rate": 13.26,
"throughput": 0.40,
"concurrency": 1.98,
"successful_transactions": 124,
"failed_transactions": 0,
"longest_transaction": 0.83,
"shortest_transaction": 0.10
}

I would suggest forcing it into quiet mode like thisL

Eniac $ siege -q -j -c2 -r2 https://www.joedog.org/

{ "transactions": 124,
"availability": 100.00,
"elapsed_time": 9.43,
"data_transferred": 3.76,
"response_time": 0.15,
"transaction_rate": 13.15,
"throughput": 0.40,
"concurrency": 1.97,
"successful_transactions": 124,
"failed_transactions": 0,
"longest_transaction": 0.85,
"shortest_transaction": 0.09
}

@bbakersmith
Copy link
Contributor Author

Forcing quiet mode is a fine approach. I considered that but figured I'd make the smallest change possible to existing functionality, and all the non-JSON output (besides verbose and debug which I disabled for json_output) goes to stderr, so it looks a little goofy in your first example but doesn't interfere with piping or redirecting stdout.

I just pushed a change to the PR that sets quiet mode instead.

@bbakersmith
Copy link
Contributor Author

To test for valid JSON output I've been using jq

$ siege -j -c2 https://www.joedog.org/ | jq

And to extract a specific value

$ siege -j -c2 https://www.joedog.org/ | jq .transactions

@bbakersmith
Copy link
Contributor Author

This still prints Lifting the server siege... in addition to the JSON output. That's not a problem functionally because it goes to stderr, but do you think it should be silenced too? And if so do you think it should be silenced for quiet mode generally or just json_output?

@JoeDog
Copy link
Owner

JoeDog commented Feb 10, 2020 via email

@bbakersmith
Copy link
Contributor Author

This was merged in manually today, closing the PR.

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

Successfully merging this pull request may close these issues.

2 participants