Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Nooshu
Created October 7, 2020 22:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nooshu/f8b1eee5a805657fdcd71aff6b2d88eb to your computer and use it in GitHub Desktop.
Save Nooshu/f8b1eee5a805657fdcd71aff6b2d88eb to your computer and use it in GitHub Desktop.
Extract connection information from the WebPageTest API and format as a CSV
#!/usr/bin/env jq -rMf
# Filter to extract DNS, Connect, SSL metrics from WebPageTest run JSON
# Headers for resulting CSV
["DNS", "Connect", "SSL"],
# drill down into the runs data
(
.data.runs
# convert the run data into an object and drill down into the run request data
| to_entries[].value.firstView.requests[]
# only select the request that corresponds to the HTML page (so it has DNS,Connect,SSL data)
| select(.final_base_page == true)
# build an array of the resulting data we want in the CSV
| [(.dns_end - .dns_start), (.connect_end - .connect_start), (.ssl_end - .ssl_start)]
)
# pass to the CSV formatter
| @csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment