How to query aggregated data with 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, follow the steps described on How to query GraphQL requests on Postman using the https://api.azionapi.net/metrics/graphql URL.

Then, on Postman’s GraphQL request code box, add the following Aggregated Query, modifying the tsRange to fit the time interval you want:

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 of time periods, informed through the tsRange field.

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


Send your request. You’ll receive a response similar to this:

{
"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.


Contributors