# Consumption fields

The `workloadConsumptionMetrics` dataset of the GraphQL API holds the usage Azion accounted for each workload, product, and metric, one record per hour. Send queries for it to `https://api.azion.com/v4/consumption/graphql`, with the window to read in the `tsRange` filter. Azion keeps consumption data for up to 24 months, and a group or reseller account can query the consumption of every client account under it.

---

## workloadConsumptionMetrics

The `workloadConsumptionMetrics` dataset returns the fields below. The arguments it accepts, such as `filter`, `groupBy`, and `limit`, are on [Datasets and query arguments](/en/documentation/devtools/graphql/features/).

| Field            | Type             | Description                                                                                                                                                                                                           |
| ---------------- | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `accounted`      | `Decimal`        | Total amount of product usage accounted for the client. A row read without `aggregate` returns the value as a string, such as `"3578"`. With `sum: accounted`, the sum comes back as a number, such as `442444116.0`. |
| `clientId`       | `String`         | Unique identifier of the client on Azion. Example: `1234u`.                                                                                                                                                           |
| `countryCode`    | `String`         | Code of the country where Azion processed the usage, not the country the user accessed the service from. Example: `BR`.                                                                                               |
| `metricName`     | `String`         | Name of the measured metric. Example: `data_transferred_total`.                                                                                                                                                       |
| `modulesBitwise` | `Int`            | An integer returned on every usage record. Example: `8`.                                                                                                                                                              |
| `productId`      | `Int`            | Unique identifier of the product the usage belongs to. Example: `1441740010`.                                                                                                                                         |
| `region`         | `String`         | Region where Azion processed the usage, not the region the user accessed the service from. Example: `United States`.                                                                                                  |
| `ts`             | `CustomDateTime` | Timestamp of the usage record, in UTC. The dataset holds one record per hour, so the value falls on the hour. Example: `2026-10-03T03:00:00Z`.                                                                        |
| `workloadId`     | `Int`            | Identifier of the workload associated with the usage. Example: `1234567904`.                                                                                                                                          |

The dataset also returns the aggregate outputs `count`, `sum`, `max`, `min`, `avg`, and `rate`, each one selected through the `aggregate` argument. Only `workloadConsumptionMetrics` and `imagesProcessedMetrics` return `rate`.

---

## Example query

This query reads every field of the three latest usage records in a seven-day window of `workloadConsumptionMetrics`:

```graphql
query {
  workloadConsumptionMetrics(limit: 3, filter: { tsRange: {begin: "2026-09-26T14:00:00", end: "2026-10-03T14:00:00"} }, orderBy: [ts_DESC]) {
    ts
    clientId
    workloadId
    countryCode
    region
    productId
    metricName
    modulesBitwise
    accounted
  }
}
```

The response holds one object per usage record. The `accounted` value of each record comes back as a string:

```json
{
  "data": {
    "workloadConsumptionMetrics": [
      {
        "ts": "2026-10-03T03:00:00Z",
        "clientId": "1234u",
        "workloadId": 1234567904,
        "countryCode": "US",
        "region": "United States",
        "productId": 1441740010,
        "metricName": "data_transferred_total",
        "modulesBitwise": 8,
        "accounted": "3578"
      },
      {
        "ts": "2026-10-03T03:00:00Z",
        "clientId": "1234u",
        "workloadId": 1234567904,
        "countryCode": "US",
        "region": "United States",
        "productId": 1441740010,
        "metricName": "requests",
        "modulesBitwise": 8,
        "accounted": "2"
      },
      {
        "ts": "2026-10-02T20:00:00Z",
        "clientId": "1234u",
        "workloadId": 1234567890,
        "countryCode": "BR",
        "region": "Brazil",
        "productId": 1441740010,
        "metricName": "data_transferred_total",
        "modulesBitwise": 8,
        "accounted": "1939900"
      }
    ]
  }
}
```

---

## Product IDs and metric names

A `workloadConsumptionMetrics` record names its product in `productId` and its metric in `metricName`. Filter by both to read the usage of one product and metric:

| Product                                                                              | Product ID   | Metric name              | What the metric counts                                 |
| ------------------------------------------------------------------------------------ | ------------ | ------------------------ | ------------------------------------------------------ |
| [Data Stream](/en/documentation/platform/data-stream/)                               | `1498670028` | `data_streamed`          | Total volume of data streamed through Data Stream.     |
| Data Stream                                                                          | `1498670028` | `requests`               | Total number of requests Data Stream processed.        |
| [Applications](/en/documentation/platform/applications/)                             | `1441740010` | `data_transferred_total` | Total amount of data transferred through Applications. |
| Applications                                                                         | `1441740010` | `requests`               | Total number of requests Applications received.        |
| Applications                                                                         | `1441740010` | `waf_requests`           | Total number of requests WAF inspected.                |
| [Functions](/en/documentation/platform/functions/)                                   | `1531930033` | `compute_time`           | Total execution time of Functions, in milliseconds.    |
| Functions                                                                            | `1531930033` | `invocations`            | Total number of times a function ran.                  |
| [Image Processor](/en/documentation/platform/applications/image-processor/settings/) | `1441110021` | `images_processed`       | Total number of images Image Processor processed.      |
| [Tiered Cache](/en/documentation/platform/applications/cache/tiered-cache/)          | `1564082375` | `data_transferred_total` | Total amount of data transferred through Tiered Cache. |
| Tiered Cache                                                                         | `1564082375` | `requests`               | Total number of cache requests Tiered Cache processed. |

Each product has a guide with a complete usage query. For more information, refer to [Query Data Stream usage data](/en/documentation/guides/platform/observability/query-data-stream-usage-data-with-graphql/), [Query usage data from Applications](/en/documentation/guides/platform/observability/query-applications-usage-data-with-graphql/), [Query usage data from Functions](/en/documentation/guides/platform/observability/query-functions-usage-data-with-graphql/), [Query usage data from Image Processor](/en/documentation/guides/platform/observability/query-image-processor-usage-data-with-graphql/), and [Query usage data from Tiered Cache](/en/documentation/guides/platform/observability/query-tiered-cache-usage-data-with-graphql/).

---

## Regions and countries

The `countryCode` and `region` fields of `workloadConsumptionMetrics` name the place where Azion processed the usage. Network architecture and routing determine that place, so it can differ from the location the user accessed the service from and from the origin of the data.

`workloadConsumptionMetrics` groups countries into these regions:

| Region            | Countries                                                                                |
| ----------------- | ---------------------------------------------------------------------------------------- |
| All Other Regions | Angola, South Africa                                                                     |
| Brazil            | Brazil                                                                                   |
| Canada            | Canada                                                                                   |
| Europe            | Deutschland, Spain, France, Great Britain, Italy, Netherlands, United Kingdom            |
| Latam             | Argentina, Bolivia, Chile, Colombia, Ecuador, Mexico, Peru, Paraguay, Uruguay, Venezuela |
| No Region         | No Region                                                                                |
| North America     | Canada, United States                                                                    |
| United States     | United States                                                                            |

---

## Related resources

- [Queries](/en/documentation/devtools/graphql/queries.md): The query shape for usage data, with a sum of accounted usage per product and metric.
- [Datasets and query arguments](/en/documentation/devtools/graphql/features.md): The filter operators, grouping, sorting, and pagination a usage query can combine.
- [Accounting fields](/en/documentation/devtools/graphql/gql-accounting-fields.md): The fields of the accounted amounts per period, product, metric, and region.
- [GraphQL API limits](/en/documentation/devtools/graphql/limits.md): The maximum rows and selected fields one usage query can return.
