# How to query usage data from Tiered Cache

The **workloadConsumptionMetrics** dataset lets you get real-time aggregated data related to consumption and usage of Azion Products, including Tiered Cache.

The information can be accessed through the GraphQL API, allowing you to transfer this data to a third-party platform, and enabling you to further analyze and review it. Additionally, the data is available for up to *24 months*.

This guide explains how to query the total data transferred by Tiered Cache using the [GraphiQL Playground](/en/documentation/products/devtools/graphql-playground/).

--- 

## Querying total transferred data

To query the total data transferred by Tiered Cache, proceed as follows:

1. Access the GraphiQL Playground at the following link: `https://api.azion.com/v4/consumption/graphql`.
    - You must be logged in to your Azion account. Otherwise, you'll receive an error message.
2. Send a query following this format:

```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
  }
}
```

Where:

| Field | Description |
|----------|----------|
| `filter` | Defines the criteria used to filter the data returned by the query. |
| `tsRange` | A subfield of `filter`. Specifies a time range for filtering data. It includes `begin` and `end` fields to define the start and end timestamps. Format: `"YYYY-MM-DDTHH:mm:ss"`; example: `"2024-04-11T00:00:00"`. |
| `sum: accounted` | As a subfield of `aggregate`, calculates the total accounted usage for events matching the query’s filters and groups. |
| `limit` | Specifies the maximum number of results to return. System maximum: `10000`. |
| `groupBy` | Specifies the fields by which the query results should be grouped. Example: `[clientId, metricName]`. |
| `productId` | Unique identifier of the product being used. In this case, `1564082375` for Tiered Cache. |
| `metricName` | Name of the calculated metric for analytics. In this case, `data_transferred_total` and `requests`. |

:::note
This example retrieves data for the total number of requests processed and data transferred by Tiered Cache. The results are grouped by `clientId` and `workloadId`. To learn more about the available fields, check the [Consumption GraphQL API Fields](/en/documentation/devtools/graphql-api/features/gql-consumption-fields/) documentation.
:::

3. You'll receive a JSON response similar to this:

```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
      }
    ]
  }
}
```

Where:

| Field | Description |
|----------|----------|
| `clientId` | Client unique identifier on Azion. Example: `8437r`. |
| `workloadId` | Identifier for the workload associated with the usage. Example: `4829301746`. |
| `productId` | Unique identifier of the product being used. In this case, `1564082375` for Tiered Cache. |
| `metricName` | Name of the measured metric for analytics. Example: `data_transferred_total` and `requests`.  |
| `total` | For `data_transferred_total`, total number of data transferred by Tiered Cache. This field is the result of a sum, in bytes. Example: `268675`. <br/> For `requests`: total number of requests processed. This field is the result of a sum. Example: `1112`. |

:::tip
To know more about the available fields, check the [Consumption GraphQL API Fields](/en/documentation/devtools/graphql-api/features/gql-consumption-fields/) documentation.
:::