Skip to content

Instantly share code, notes, and snippets.

@robertgzr
Created March 2, 2023 13:32
Show Gist options
  • Save robertgzr/590e683a0a814e63621fd09c8959bbd6 to your computer and use it in GitHub Desktop.
Save robertgzr/590e683a0a814e63621fd09c8959bbd6 to your computer and use it in GitHub Desktop.
circleci insights to csv
export CIRCLE_TOKEN={apitoken}
export START_DATE=2022-12-01T12:00:00Z
export END_DATE=2023-03-01T12:00:00Z
#!/bin/sh
set -ex
curl -sS --header "Circle-Token: ${CIRCLE_TOKEN:?}" \
"https://circleci.com/api/v2/insights/gh/postmanlabs/starship-next/branches?workflow-name=starship" |
tee /dev/stderr |
jq '.branches[]' -r |
tee /dev/stderr |
xargs -I{} curl -sS --header "Circle-Token: ${CIRCLE_TOKEN:?}" \
"https://circleci.com/api/v2/insights/time-series/gh/postmanlabs/starship-next/workflows/starship/jobs?timeseries-granularity=hourly&start-date=${START_DATE:?}&end-date=${END_DATE:?}&branch={}" |
tee /dev/stderr |
jq '.items[] | select(.name?=="debug-macos-x64-standalone") | [.timestamp,.metrics.median_credits_used,.metrics.duration_metrics.p95]|@csv' -r |
sort
#!/bin/sh
set -ex
curl -sS --header "Circle-Token: ${CIRCLE_TOKEN:?}" \
"https://circleci.com/api/v2/insights/gh/postmanlabs/starship/branches?workflow-name=starship" |
tee /dev/stderr |
jq '.branches[]' -r |
tee /dev/stderr |
xargs -I{} curl -sS --header "Circle-Token: ${CIRCLE_TOKEN:?}" \
"https://circleci.com/api/v2/insights/time-series/gh/postmanlabs/starship/workflows/starship/jobs?timeseries-granularity=hourly&start-date=${START_DATE:?}&end-date=${END_DATE:?}&branch={}" |
tee /dev/stderr |
jq '.items[] | select(.name?=="dev-build-macos-x64") | [.timestamp,.metrics.median_credits_used,.metrics.duration_metrics.p95]|@csv' -r |
sort
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment