---
name: azion-query-usage-data-from-tiered-cache
description: >-
  Read the requests Tiered Cache processed and the data it transferred, with a consumption query in the GraphiQL Playground.
---

# Query usage data from Tiered Cache

The `workloadConsumptionMetrics` dataset returns aggregated consumption data for Azion products, including [Tiered Cache](/en/documentation/platform/applications/cache/tiered-cache/). You query it through the GraphQL API, and the data is available for up to 24 months.

This guide runs the query in the GraphiQL Playground. The same query works from any GraphQL client that sends your credentials.

---

## Prerequisites

- An Azion account, signed in. The Playground returns an error message for a request that carries no session.
- Access to the [GraphiQL Playground](/en/documentation/devtools/graphql/graphql-playground/).

---

## Query the requests and the data transferred

The query filters the dataset by product and by a time range, then sums the accounted usage per metric. To run it:

1. **Open the Playground**

   Go to `https://api.azion.com/v4/consumption/graphql`.

2. **Enter the query**

   The `productId` `1564082375` is Tiered Cache. Adjust `begin` and `end` to the period you want to read:

   ```graphql
   query {
     workloadConsumptionMetrics(
       filter: {
         tsRange: {
           begin: "2025-02-01T00:00:00",
           end: "2025-03-01T00:00:00",
         }
         productId: 1564082375
         metricNameIn: ["data_transferred_total", "requests"]
       }
       aggregate: {
         sum: accounted
       }
       limit: 10000
       groupBy: [clientId, workloadId, productId, metricName]
     ) {
       clientId
       workloadId
       productId
       metricName
       total: sum
     }
   }
   ```

3. **Run the query and read the response**

   The response carries one object per group, with the summed usage in `total`:

   ```json
   {
     "data": {
       "workloadConsumptionMetrics": [
         {
           "clientId": "0000z",
           "workloadId": 7584931026,
           "productId": 1564082375,
           "metricName": "requests",
           "total": 7
         },
         {
           "clientId": "0000z",
           "workloadId": 7584931026,
           "productId": 1564082375,
           "metricName": "data_transferred_total",
           "total": 35677128
         },
         {
           "clientId": "0000z",
           "workloadId": 1938475620,
           "productId": 1564082375,
           "metricName": "data_transferred_total",
           "total": 62854832
         },
         {
           "clientId": "0000z",
           "workloadId": 1938475620,
           "productId": 1564082375,
           "metricName": "requests",
           "total": 8748041
         },
         {
           "clientId": "0000z",
           "workloadId": 4829103746,
           "productId": 1564082375,
           "metricName": "requests",
           "total": 797683
         }
       ]
     }
   }
   ```

You now have the requests Tiered Cache processed and the bytes it transferred in the period, per workload.

---

## Query fields

| Field          | What it carries                                                                                   |
| -------------- | ------------------------------------------------------------------------------------------------- |
| `filter`       | The criteria that narrow the returned data                                                        |
| `tsRange`      | A subfield of `filter`, with a `begin` and an `end` timestamp in the format `YYYY-MM-DDTHH:mm:ss` |
| `productId`    | The product the rows belong to. Tiered Cache is `1564082375`                                      |
| `metricNameIn` | The metrics to return. This query reads `data_transferred_total` and `requests`                   |
| `aggregate`    | With `sum: accounted`, the accounted usage of every event matching the filters and the groups     |
| `limit`        | The maximum number of results. The system maximum is `10000`                                      |
| `groupBy`      | The fields the results are grouped by                                                             |

## Response fields

| Field        | What it carries                                                                                                                             |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------- |
| `clientId`   | The unique identifier of the client on Azion. For example: `8437r`                                                                          |
| `workloadId` | The identifier of the workload the usage belongs to. For example: `4829103746`                                                              |
| `productId`  | The product the row belongs to                                                                                                              |
| `metricName` | The metric the row reports                                                                                                                  |
| `total`      | The summed value of the metric. For `data_transferred_total`, the bytes Tiered Cache transferred. For `requests`, the requests it processed |

For every field of the dataset, refer to [Consumption GraphQL API fields](/en/documentation/devtools/graphql/gql-consumption-fields/).

---

## Next steps

- [Tiered Cache](/en/documentation/platform/applications/cache/tiered-cache.md): The second cache layer this data measures, with its topologies and its TTL floor.
- [Applications limits](/en/documentation/platform/applications/limits.md#cache): The purges and the data transfer each service plan includes every month.
- [Real-Time Metrics](/en/documentation/platform/real-time-metrics.md): The Tiered Cache dataset, read from the Console instead of a query.
- [GraphiQL Playground](/en/documentation/devtools/graphql/graphql-playground.md): How to authenticate and run any other query against the GraphQL API.
