How to query the top URLs impacted by bots with GraphQL API

The botManagerBreakdownMetrics dataset provides access to real-time aggregated data from Azion Bot Manager activity, related to requests classified as bots and bad bots across your applications, as well as the URLs most impacted by bots access. This dataset is part of the Real-Time Metrics GraphQL API and is generated from the requests analyzed and identified as bots and bad bots.

This information can be accessed through the GraphQL API. Additionally, this data is retained and available for up to 60 days.

This guide explains how to query the top 5 URLs impacted by bot activity.


Querying data

To query the top 5 URLs impacted by bot activity, proceed as follows:

  1. Access the GraphiQL playground in this link: https://manager.azion.com/metrics/graphql.
    • You must be logged in to your Azion account. Otherwise, you’ll receive an error message.
  2. Send a query following this format:
query {
botManagerBreakdownMetrics (
filter: {
tsRange: {
begin: "2024-10-01T00:00:00"
end: "2024-10-03T00:00:00"
}
}
aggregate: {
sum: botRequests
}
groupBy: [requestUrl]
orderBy: [sum_DESC]
limit: 5
) {
requestUrl
sum
}
}

Where:

FieldDescription
filterDefines the criteria used to filter the data returned by the query
tsRangeA subfield of filter. Specifies a time range for filtering data. It includes begin and end fields to define the start and end timestamps. Format: "YYYY-MM-DDTHH:mm:ss"; example: "2024-04-11T00:00:00"
sum: botRequestsReturns the total number of requests classified as bots within the specified time range, after applying any filters
orderBySpecifies the order in which the results should be returned. Examples: [sum_DESC], for descending order, and [sum_ASC], for ascending order
groupBySpecifies the fields by which the query results should be grouped. Example: [requestUrl] to group by URL
limitSpecifies the maximum number of results to return. In this case, 5
  1. You’ll receive a response similar to this:
{
"data": {
"botManagerBreakdownMetrics": [
{
"requestUrl": "example-host1.com/api/v1/resource",
"sum": 333543
},
{
"requestUrl": "example-host2.net/api/v2/data",
"sum": 107281
},
{
"requestUrl": "example-host3.org/api/v3/info",
"sum": 103363
},
{
"requestUrl": "example-host4.io/api/v4/details",
"sum": 89668
},
{
"requestUrl": "example-host5.co/api/v5/summary",
"sum": 64060
}
]
}
}

Where:

FieldDescription
requestUrlURL impacted by bot activity. Example: example-host5.co/api/v5/summary
sumTotal requests involving bot activity received by the URL. This field is the result of a sum. Example: 333543

Contributors