4 ms·
Yup. Not too hard. This outputs the current bandwidth in gigabytes when you pass your app name. #!/usr/bin/env bash set -euo pipefail QUERY=$(cat <<EOF
by TJSomething 4y ago
Yup. Not too hard. This outputs the current bandwidth in gigabytes when you pass your app name.
#!/usr/bin/env bash
set -euo pipefail
QUERY=$(cat <<EOF
{
"variables":{
"app":"$1",
"start":"$(date +%Y-%m)",
"end":"$(date -d "$(date +%Y%m01) +1 month -1 day" +%Y-%m-%d)"
},
"query":"query (\$app: String!, \$start: ISO8601DateTime!, \$end: ISO8601DateTime!) { app(name: \$app) { organization { billables(startDate: \$start, endDate: \$end) { edges { node { app { id } category quantity } } } } } } "
}
EOF
)
curl https://api.fly.io/graphql \
-H "Authorization: Bearer $(fly auth token)" \
-H 'content-type: application/json' \
--compressed \
-X POST \
--data-raw "$QUERY" \
--silent |
jq '[.data.app.organization.billables.edges[].node | select(.app.id == "'"$1"'" and .category == "data_out") | .quantity] | add'