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

-j doesn't always output JSON #213

Open
SJrX opened this issue Oct 4, 2022 · 5 comments
Open

-j doesn't always output JSON #213

SJrX opened this issue Oct 4, 2022 · 5 comments

Comments

@SJrX
Copy link

SJrX commented Oct 4, 2022

This might be user error but in my opinion if you support outputting things in json you should be guaranteed that there is JSON output. In many cases having a log file or if it creates the /root/.siege file it will output to standard out, which means that it's much harder to do anything with the json output.

In a program I have written (that always outputs JSON), anything that is not the JSON response goes to stderr, not standard out. Another option would be to create a new option that lets me specify a file name that will write the JSON report to.

@JoeDog
Copy link
Owner

JoeDog commented Oct 4, 2022 via email

@SJrX
Copy link
Author

SJrX commented Oct 4, 2022

With this Dockerfile

FROM ubuntu:22.04

RUN apt-get update && apt-get install -y siege jq

Build it and start a new shell

docker build -t siege-test  .
docker run -it --rm siege-test /bin/bash

Then run the following commands.

# siege -c 1 -r 1 -j www.google.ca > report.json
# cat report.json | jq
parse error: Invalid numeric literal at line 1, column 4
# cat report.json
New configuration template added to /root/.siege
Run siege -C to view the current settings in that file
{       "transactions":                            2,
        "availability":                       100.00,
        "elapsed_time":                         0.26,
        "data_transferred":                     0.02,
        "response_time":                        0.13,
        "transaction_rate":                     7.69,
        "throughput":                           0.08,
        "concurrency":                          1.00,
        "successful_transactions":                 2,
        "failed_transactions":                     0,
        "longest_transaction":                  0.21,
        "shortest_transaction":                 0.05
}

If you run it again, it will pass.

Another example is.

#siege -c 1 -r 1 --log=./siege_log.txt -j www.google.ca  > file.json
cat file.txt | jq
{
  "transactions": 2,
  "availability": 100,
  "elapsed_time": 0.18,
  "data_transferred": 0.02,
  "response_time": 0.09,
  "transaction_rate": 11.11,
  "throughput": 0.12,
  "concurrency": 1,
  "successful_transactions": 2,
  "failed_transactions": 0,
  "longest_transaction": 0.13,
  "shortest_transaction": 0.05
}
parse error: Invalid numeric literal at line 14, column 4

#cat file.json
{       "transactions":                            2,
        "availability":                       100.00,
        "elapsed_time":                         0.18,
        "data_transferred":                     0.02,
        "response_time":                        0.09,
        "transaction_rate":                    11.11,
        "throughput":                           0.12,
        "concurrency":                          1.00,
        "successful_transactions":                 2,
        "failed_transactions":                     0,
        "longest_transaction":                  0.13,
        "shortest_transaction":                 0.05
}
LOG FILE: ./siege_log.txt
You can disable this log file notification by editing
/root/.siege/siege.conf and changing 'show-logfile' to false.

In these cases the benefits of having a json formatted output is lost in my opinion, because other output means it can't really be handled programmatically easily.

@JoeDog
Copy link
Owner

JoeDog commented Oct 4, 2022 via email

@JoeDog
Copy link
Owner

JoeDog commented Oct 4, 2022 via email

@SJrX
Copy link
Author

SJrX commented Oct 5, 2022

Thank you.

That will go to stderr now. There's not much I can do to help you with
running siege.config. It's a shell script. You can edit it.

This part I didn't understand.

I think maybe the safest thing would be to have a way of just putting the JSON file output somewhere specific. I think that if you have a flag that says output will be json, all output should be json. I'm kind of leary about putting on logging or verbosity with the -j flag. I'm not sure what can handle JSON with non JSON.

But I found a way around this now :) Thanks again.

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

No branches or pull requests

2 participants