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

site

doc

blog

success stories

Consulting aggregated data with the GraphQL API

Aggregated data can also be considered as structured data that have been clustered — they go through modifications to allow a better analytic processing seeking a segmented analysis.

To query the available aggregated data in the GraphQL API, you’ll need to go through two steps: creating a Personal Token and running your request on Postman. See the next sections and follow the presented steps.

  1. Creating Personal Tokens
  2. Consulting aggregated data with Postman

Creating Personal Tokens

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. Save your Personal Token in a safe location to use it in the next section.

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

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

Consulting aggregated data with Postman

After creating your Personal Token, you must go to Postman and follow the next steps:

  1. On Postman’s upper header Postman, click the + button to create a new request.
  2. On the Headers tab, click on Bulk Edit and add the following code, along with the Personal Token value created previously:
Authorization:Token [TOKEN VALUE]

After creating the Headers with your token, remain on Postman to create the request’s body:

  1. On the upper-left corner, click the GET option to open a dropdown list.
  2. Select the POST option.
  3. On the options row, select the Body tab > GraphQL option.
  4. On the QUERY box, add the following Aggregated Query:
query HttpQuery {
  httpMetrics(
    limit: 10,
    filter: {
      tsRange: {begin:"2022-03-21T10:10:10", end:"2022-06-23T10:10:10"}
    }
    aggregate: {sum: bytesSent}
    groupBy: [ts]
    orderBy: [ts_ASC]
  )
  {
    ts
    sum
  }
}

On the example above, you’ll query for an aggregated table of the HTTP dataset. Furthermore, the sum operator was used to request the aggregated data with information regarding the bytesSent field in a set range time period, informed through the tsRange field.

Lastly, the presented data were grouped and ordered through the ts (timestamp) field.

To query aggregated 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 ts and sum fields were used, in which sum represents the response of the bytesSent aggregation.

To aggregate information made available through the GraphQL API as in the presented example, there are a few options that you must inform through the aggregate field in your query. They are:

  • Count: used to determine the total value of records meeting a specific condition.
  • Sum: returns the sum of the entry values of a column or expression.
  • Max: returns the maximum value of a determined field of a table according to the established selection criteria.
  • Avg: calculates the arithmetic mean of a set of values in a specific field being consulted.

You can run a request with one of each of the available options—count, sum, max, e avg—, as long as each option is only used once and each operator aggregated only one dataset field at a time. See the following example:

aggregate: {
    count: rows, 
    sum: bytesSent, 
    avg: requestTime, 
    max: requestLength
}

Now that you’ve query 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 request URL field, add the GraphQL API URL being consulted: https://api.azionapi.net/metrics/graphql
  2. Click the Send button, located on the upper-right corner.

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

{
   "data": {
       "httpMetrics": [
           {
               "ts": "2022-06-09T21:33:13",
               "sum": 1471.0
           },
           {
               "ts": "2022-06-09T21:33:14",
               "sum": 1471.0
           },
           {
               "ts": "2022-06-09T21:33:15",
               "sum": 1471.0
           }
       ]
   }
}

The GraphQL API returned the aggregated data with the sum operator for the bytesSent field, 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.