Queries
Look up how to query raw, aggregated, financial, and usage data with the GraphQL API, the aggregate functions, and a response for each query shape.
A GraphQL API query names one dataset, the arguments that filter, group, and sort it, and the fields to return. The API answers with a JSON object whose data key holds one array per dataset, with one object per row and only the fields the query selected. The query shape, and the endpoint it goes to, depend on the data you read: raw, aggregated, financial, or usage.
Query shapes
Each shape reads its data from one endpoint. Send the query in a POST request to that endpoint, with the header Authorization: Token [TOKEN VALUE]:
| Shape | Data | Endpoint | Example dataset | Time filter |
|---|---|---|---|---|
| Raw | One record per request, with no processing | https://api.azion.com/v4/events/graphql | workloadEvents | tsRange, or tsGt and tsLt; required |
| Aggregated | Requests grouped into time buckets | https://api.azion.com/v4/metrics/graphql | workloadMetrics | tsRange, or tsGt and tsLt; required |
| Financial, accounted | Accounted amounts per period | https://api.azion.com/v4/accounting/graphql | accountingDetail | periodFrom and periodTo; optional |
| Financial, billed | Billed amounts per period | https://api.azion.com/v4/billing/graphql | billDetail | periodFromRange |
| Usage | Accounted usage per workload and product | https://api.azion.com/v4/consumption/graphql | workloadConsumptionMetrics | tsRange |
A time filter goes in the filter argument. Without a required one, the API returns 400 with To execute queries it is mandatory to provide the desired time interval. The datasets of each endpoint, and the arguments every query accepts, are on Datasets and query arguments.
Raw data
Raw data is the record of each request as Azion logged it, with no processing. Use it to investigate individual requests. Raw datasets, such as workloadEvents, are served by the events endpoint, https://api.azion.com/v4/events/graphql.
This query returns the time, client address, URI, and stack trace of the requests in a one-hour window, oldest first:
The response holds one object per request in the window:
A raw query carries two things:
- A time window, in
tsRangeor intsGtandtsLt. - The fields to return. The response carries no field the query did not select.
Excluded matches
The not filter excludes the records that match the filter inside it. With Like, which is case-sensitive, or Ilike, which is not, not excludes every URI that matches a pattern. A raw dataset also accepts aggregate and groupBy. This query counts the requests per host whose URI does not contain /_astro/, highest count first:
The response holds one row per host:
Every filter operator, with the field types each one applies to, is on Datasets and query arguments.
Aggregated data
Aggregated data is request data that the metrics endpoint, https://api.azion.com/v4/metrics/graphql, stores grouped into time buckets. Use it to read totals and trends over long periods. The bucket size, a minute, an hour, or a day, follows the length of the window, as How it works describes.
This query sums the requests of a 48-hour window per time bucket, latest first:
The response holds one row per bucket, and the result of the function comes back in a field named after it, sum:
An aggregated query follows these rules:
- A time window is required, in
tsRangeor intsGtandtsLt. aggregatenames a function and the field it reads, such assum: requests.groupByis optional. With it, the response holds one row per combination of the listed fields. Without it, the response holds one row with the total.- A measure field, such as
requests, is selected only throughaggregate. Selected directly, it returns400withThe query includes fields that require grouping. Please ensure all non-aggregated fields are included in groupBy argument. orderBysorts on the function output with a direction suffix, such assum_DESCorcount_DESC.- An alias renames an output field. With
total: sumin the selection, the response carriestotalinstead ofsum.
The datasets httpMetrics and httpBreakdownMetrics are deprecated; use workloadMetrics and workloadBreakdownMetrics. For more examples, refer to Query aggregated data.
Aggregate functions
The aggregate argument takes the functions below, each at most once per query and each on one field. Every dataset accepts the first five, and one query can combine them:
| Function | Returns | Datasets |
|---|---|---|
count | The number of records. Takes rows or a field. | Every dataset |
sum | The sum of the field values. | Every dataset |
avg | The arithmetic mean of the field values. | Every dataset |
max | The largest field value. | Every dataset |
min | The smallest field value. | Every dataset |
rate | A rate of the field. On imagesProcessedMetrics, the images processed per second. | imagesProcessedMetrics and workloadConsumptionMetrics only |
A function accepts only the fields the dataset lists for aggregation in its schema. A computed field such as missedData returns 400, and so does rate on any other dataset. This query runs five functions on workloadMetrics, one row per host, highest count first:
Each row carries one field per function:
Financial data
Financial data holds two kinds of amounts. Accounted data comes from accountingDetail, on the accounting endpoint, https://api.azion.com/v4/accounting/graphql. Billed data comes from billDetail, on the billing endpoint, https://api.azion.com/v4/billing/graphql, which takes a period in periodFromRange. An accountingDetail query needs no time window: without a filter, it returns rows. To read one period, filter by periodFrom and periodTo.
This query returns the accounted amounts of September 2026, per product, metric, and region:
The response holds five rows, cut here after the third:
The fields of each dataset are on Accounting fields and Billing fields.
Usage data
Usage data is the usage Azion accounted for each workload and product, in the accounted field of workloadConsumptionMetrics. The dataset is served by the consumption endpoint, https://api.azion.com/v4/consumption/graphql, and a query sets its time window in tsRange.
This query sums the accounted usage of a seven-day window per product and metric, highest first:
The response is cut after the third row:
To narrow the result to one product and metric, add productId and metricName to the filter. To read the usage of Image Processor, refer to Query usage data from Image Processor. The fields of the dataset are on Consumption fields.
Example repository
Azion keeps a repository of GraphQL API query examples at aziontech/azion-queries. It groups the examples by Data Stream, Applications, Top X queries, and Functions. You can submit changes to the repository.