1 of 20
2 of 20
3 of 20
4 of 20
5 of 20
6 of 20
7 of 20
8 of 20
9 of 20
10 of 20
11 of 20
12 of 20
13 of 20
14 of 20
15 of 20
16 of 20
17 of 20
18 of 20
19 of 20
20 of 20


How to select Top X queries with GraphQL API

Top X queries are mainly used for performing queries and analysis on data. They help visualize how resources and tools are being used and provide a more detailed analysis of certain conditions that are either more or less commonly used.

To query Top X queries through the GraphQL API, you need to go through two steps: create a personal token and run your request on Postman. See the next sections and follow the presented steps.

  1. Creating a personal token
  2. Querying Top X data with Postman

Creating a personal token

Before running your requests with the GraphQL API, you first need to create a personal token to validate your access.

  1. On Real-Time Manager (RTM), select Account menu > Personal Tokens.
  2. Fill the fields to configure the personal token and click the Create Token button.
  3. Copy and save your token in a safe location to use it in the next section.

See the Personal Tokens documentation for more information on how to create one.

As an alternative, you can create a short-duration token through the Azion API.

Querying Top X data with Postman

After creating your personal token, go to Postman and follow the next steps:

  1. On the header, click the + button to create a new request.
  2. On the Headers tab, click on Bulk Edit and add the following code, replacing [TOKEN VALUE] with the personal token value you created:
Authorization:Token [TOKEN VALUE]

Remain on Postman and create the request’s body:

  1. Select the Body tab.
  2. On the upper-left corner, click the GET option to open a dropdown menu.
  3. Select the POST option.
  4. On the options row, select the GraphQL option.
  5. On the QUERY box, add the following Top X Query:
query EventsTopUri {
   limit: 5,
   filter: {
     tsRange: {begin:"2022-11-20T10:10:10", end:"2022-11-27T10:10:10"}
   aggregate: {count: requestUri}
   groupBy: [requestUri]
   orderBy: [count_DESC]

The example queries the Events app for raw data with the HTTP dataset. In addition, the count operator requests data aggregation with information from the requestUri field during a set period of time, informed through the tsRange field. The API response was also limited to 5 registers by using the limit field.

Lastly, data were aggregated (groupBy) by the requestUri field and sorted (orderBy) by the return of the count operator in a descending (DESC) order. That way, the largest amount of aggregation responses is shown first.

To query aggregating data, it’s mandatory to inform:

  • A time range interval for queries, using either tsRange or tsGt + tsLt.
  • The fields whose information you want to group, using groupBy.
  • Which consulted data should be exhibited. On the presented example, the requestUri and count fields were used, in which count represents the response of the requestUri aggregation.

Now that you’ve queried your request, you can send it to the GraphQL API and receive a response with the data. To send it to the API:

  1. On the Enter URL or paste text field, add the URL being queried: https://api.azionapi.net/metrics/graphql
  2. Click the Send button on the upper-right corner.

You’ll receive a response with the requested data, as in the following example:

   "data": {
       "httpEvents": [
               "requestUri": "/requests/images",
               "count": 610081
               "requestUri": "/path/to/file/document",
               "count": 6270
               "requestUri": "/send/stock",
               "count": 3568

The GraphQL API returned the Top RequestUri query data according to the query informed in the request.

For more information on aggregating data with the GraphQL API, visit the datasets documentation page.

Didn’t find what you were looking for? Open a support ticket.