Last active
March 16, 2024 20:54
-
-
Save eidam/942cee25e3ec6ef8de61cc14823293b2 to your computer and use it in GitHub Desktop.
A Cloudflare GQL API request to get health checks RTT (round-trip time), grouped by region.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// GQL API docs => https://developers.cloudflare.com/analytics/graphql-api/ | |
// tldr; => POST https://api.cloudflare.com/client/v4/graphql | |
const requestBody = { | |
query: ` | |
query RequestsAndDataTransferByHostname($zoneTag: string, $filter: filter) { | |
viewer { | |
zones(filter: {zoneTag: $zoneTag}) { | |
healthCheckEventsAdaptiveGroups(limit: 10000, filter: $filter) { | |
dimensions { | |
healthCheckName | |
datetimeFiveMinutes | |
region | |
} | |
avg { | |
rttMs | |
} | |
} | |
} | |
} | |
}`, | |
variables: { | |
zoneTag, // Health Checks' Cloudflare Zone ID | |
filter: { | |
datetime_geq: new Date(Date.now() - 60 * 60 * 24 * 1000).toISOString(), | |
rttMs_lt: 1000, | |
OR: [ | |
{ healthCheckName: "rlimit-com-cf-proxied" }, | |
{ healthCheckName: "rlimit-com-direct" }, | |
], | |
}, | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment