Search code examples
httpcommand-line-interfaceload-testingvegeta

Json output from Vegeta HTTP load testing


I am using Vegeta to make some stress test but I am having some trouble while generating a json report. Running the following command I am able to see text results:

vegeta attack -targets="./vegeta_sagemaker_True.txt" -rate=10 -duration=2s | vegeta report -output="attack.json" -type=text

Requests      [total, rate]            20, 10.52
Duration      [total, attack, wait]    2.403464884s, 1.901136s, 502.328884ms
Latencies     [mean, 50, 95, 99, max]  945.385864ms, 984.768025ms, 1.368113304s, 1.424427549s, 1.424427549s
Bytes In      [total, mean]            5919, 295.95
Bytes Out     [total, mean]            7104, 355.20
Success       [ratio]                  95.00%
Status Codes  [code:count]             200:19  400:1  
Error Set:
400 

When I run the same command changing -type-text to -type=json I receive really weird numbers ad they don't make sense for me:

{
  "latencies": {
    "total": 19853536952,
    "mean": 992676847,
    "50th": 972074984,
    "95th": 1438787021,
    "99th": 1636579198,
    "max": 1636579198
  },
  "bytes_in": {
    "total": 5919,
    "mean": 295.95
  },
  "bytes_out": {
    "total": 7104,
    "mean": 355.2
  },
  "earliest": "2019-04-24T14:32:23.099072+02:00",
  "latest": "2019-04-24T14:32:25.00025+02:00",
  "end": "2019-04-24T14:32:25.761337546+02:00",
  "duration": 1901178000,
  "wait": 761087546,
  "requests": 20,
  "rate": 10.519793517492838,
  "success": 0.95,
  "status_codes": {
    "200": 19,
    "400": 1
  },
  "errors": [
    "400 "
  ]
}

Does anyone know why this should be happening?

Thanks!


Solution

  • These numbers are nanoseconds -- the internal representation of time.Duration in Go.

    For example, the latencies.mean in the JSON is 992676847, which means 992676847 nanoseconds, that is 992676847/1000/1000 = 992.676847ms.

    Actually, in vegeta, if you declare type as text (-type=text), it will use NewTextReporter, and print the time.Duration as a user-friendly string. If you declare type as json (-type=json), it will use NewJSONReporter and return time.Duration's internal representation:

    A Duration represents the elapsed time between two instants as an int64 nanosecond count. The representation limits the largest representable duration to approximately 290 years.