Newsletter
TechAnV Blog
Get updates on security engineering, Rust, eBPF, and DevSecOps. No spam, unsubscribe anytime.
Check your inbox and click the confirmation link to complete your subscription.
Using the undocumented Fly GraphQL API#
Fly has a GraphQL API which is used by some of their own tools - I found it while browsing around their code on GitHub.
It’s very much undocumented, which means you would be very foolish to write any software against it and expect it to continue to work as Fly make changes.
Only it is kind of documented, because GraphQL introspection provides decent documentation.
(Also it’s used by example code published by Fly, so maybe it’s more supported than I initially thought.)
The endpoint is https://api.fly.io/graphql - you need a Authorization: Bearer xxx HTTP header to access it, where you can get the xxx token by running flyctl auth token.
Or, you can point your browser directly at https://api.fly.io/graphql - they are running a copy of GraphiQL there which provides an interactive explorer plus documentation and schema tabs.
And if you’re signed in to the Fly web interface it will use your .fly.io cookies to authenticate your GraphQL requests - so no need to worry about that Authorization header.
Here’s a query I used to answer the question “what volumes do I have attached, across all of my instances?”
1{2 apps {3 nodes {4 name5 volumes {6 nodes {7 name8 }9 }10 }11 }12}Here’s a much more fun query:
1{2 # Your user account:3 viewer {4 avatarUrl5 createdAt6 email7 # This returned the following for me:8 # ["backend_wordpress", "response_headers_middleware", "firecracker", "dashboard_logs"]9 featureFlags10 }11 nearestRegion {12 # This returned "sjc"13 code14 }15 personalOrganization {16 name17 creditBalance18 creditBalanceFormatted19 # Not sure what these are but they look interesting - I have 720 loggedCertificates {21 totalCount22 nodes {23 cert24 id25 root26 }27 }28 isCreditCardSaved29 wireGuardPeers {30 # Returned one entry for me, with name:31 # interactive-Simons-MacBook-Pro-swillison-gmail-com-2632 # Presumably the flyctl CLI command set this up33 totalCount34 nodes {35 name36 network37 peerip38 pubkey39 region40 }41 }42 }43}This one returns recent logs (only for the past hour / max of 50 values - those are the highest numbers that can be used for those parameters):
1{2 apps {3 nodes {4 name5 vms {6 totalCount7 nodes {8 recentLogs(limit: 50, range: 3600) {9 id10 region11 message12 timestamp13 }14 }15 }16 }17 }18}And another one which digs into the details of attached volumes:
1{2 apps {3 nodes {4 name5 services {6 checks {7 httpPath8 httpMethod9 name10 }11 description12 }13 volumes {14 nodes {15 id16 name17 createdAt18 host {19 id20 }21 sizeGb22 status23 usedBytes24 region25 app {26 name27 }28 attachedAllocation {29 privateIP30 # Not sure why attachedAllocation on a volume gives app HTTP traffic logs:31 recentLogs {32 id33 message34 timestamp35 }36 canary37 events {38 message39 timestamp40 }41 }42 }43 }44 }45 }46}