Skip to content

Instantly share code, notes, and snippets.

@tellison
Created November 15, 2024 10:20
Show Gist options
  • Select an option

  • Save tellison/e2736c65cf74c8f9c82d2b83f43ade16 to your computer and use it in GitHub Desktop.

Select an option

Save tellison/e2736c65cf74c8f9c82d2b83f43ade16 to your computer and use it in GitHub Desktop.
CloudFlare GraphQL query for Adoptium packages
{
viewer {
zones(
# Filter by adoptium.net zone.
## Replace <ZONE-TAG> with actual value
filter: {zoneTag: "<ZONE-TAG>"}
)
{
httpRequestsAdaptiveGroups(
# Limit number of results, and order by ascending date.
limit: 1000,
orderBy: [date_ASC],
filter: {
# Filter by date.
date_geq: "2024-10-01",
date_leq: "2024-10-31",
# Filter by host
clientRequestHTTPHost: "packages.adoptium.net",
# Filter by name, looking for .deb, .rpm, .apk packages.
OR: [
{
AND: [
{clientRequestPath_like: "%.deb"},
{clientRequestPath_notlike: "%/adoptium-ca-certificates%"}
]
},
{clientRequestPath_like: "%.rpm"},
{clientRequestPath_like: "%.apk"}
],
# Filter by successful requests.
originResponseStatus: 200
}
)
{
# Return total matching count.
count
# Group results by date and path.
dimensions {
date
# clientRequestPath
}
}
}
}
}
@tellison
Copy link
Author

Endpoint is https://api.cloudflare.com/client/v4/graphql. Note that rate limits apply.

Auth via HTTP request header (replace <TOKEN> with actual API token value.):

{
  "Authorization": "Bearer <TOKEN>"
}

@tellison
Copy link
Author

Example output based on above, but using filter dates between Nov 1 to Nov 7.

These are the daily counts for all .deb, .rpm, and .apk packages:

{
  "data": {
    "viewer": {
      "zones": [
        {
          "httpRequestsAdaptiveGroups": [
            {
              "count": 20491,
              "dimensions": {
                "date": "2024-11-01"
              }
            },
            {
              "count": 9810,
              "dimensions": {
                "date": "2024-11-02"
              }
            },
            {
              "count": 9907,
              "dimensions": {
                "date": "2024-11-03"
              }
            },
            {
              "count": 23683,
              "dimensions": {
                "date": "2024-11-04"
              }
            },
            {
              "count": 19257,
              "dimensions": {
                "date": "2024-11-05"
              }
            },
            {
              "count": 18045,
              "dimensions": {
                "date": "2024-11-06"
              }
            },
            {
              "count": 19508,
              "dimensions": {
                "date": "2024-11-07"
              }
            }
          ]
        }
      ]
    }
  },
  "errors": null
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment