buildkite-job-dispatcher: replace graphql request with https://agent.buildkite.com/v3/metrics
Created by: bobheadxi
TIL about this endpoint https://buildkite.com/docs/apis/agent-api/metrics which possibly gives us what we need for buildkite-job-dispatcher
to make scaling decisions, in a nice condensed format, while bypassing the buggy and unreliable GraphQL API
curl -H "Authorization: Token $TOKEN" "https://agent.buildkite.com/v3/metrics" | jq
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 408 0 408 0 0 791 0 --:--:-- --:--:-- --:--:-- 804
{
"agents": {
"idle": 36,
"busy": 1,
"total": 37,
"queues": {
"baremetal": {
"idle": 1,
"busy": 0,
"total": 1
},
"stateless": {
"idle": 25,
"busy": 1,
"total": 26
},
"vagrant": {
"idle": 10,
"busy": 0,
"total": 10
}
}
},
"jobs": {
"scheduled": 0,
"running": 2,
"waiting": 4,
"total": 6,
"queues": {
"default": {
"scheduled": 0,
"running": 0,
"waiting": 4,
"total": 4
},
"standard": {
"scheduled": 0,
"running": 2,
"waiting": 0,
"total": 2
}
}
},
"organization": {
"slug": "sourcegraph"
}
}