---
name: azion-query-usage-data-from-applications
description: >-
  Read the requests, the bytes transferred, and the WAF-inspected requests of your applications from the workloadConsumptionMetrics GraphQL dataset.
---

# Query usage data from Applications

You can read the usage of your [applications](/en/documentation/platform/applications/) from the [`workloadConsumptionMetrics` dataset](/en/documentation/devtools/graphql/gql-consumption-fields/) of the GraphQL API, in the [GraphiQL Playground](/en/documentation/devtools/graphql/graphql-playground/). The dataset returns the requests your applications processed, the bytes they transferred, and the requests that Web Application Firewall (WAF) inspected. Image Processor and Tiered Cache report their usage under product IDs of their own. For those, refer to [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/).

The dataset holds aggregated data, and Azion keeps it for up to 24 months. You can move the results to a third-party platform to analyze them further.

---

## Prerequisites

- An Azion account, signed in, in the browser that opens the GraphiQL Playground. Without a session, the playground answers with an error. To sign in, refer to [Access Azion Console](/en/documentation/guides/platform/account-and-billing/how-to-access-azion-console/).
- The start and the end of the period you want to query.

---

## Query the requests and the data transferred

The `requests` metric counts the requests your applications received and processed. The `data_transferred_total` metric adds up the bytes they transferred. One query reads both, with these arguments of `workloadConsumptionMetrics`:

| Argument                          | Value                                                                                 | Effect                                                                                                                                                                         |
| --------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `filter` › `tsRange`              | `begin` and `end`, in the `YYYY-MM-DDTHH:mm:ss` format, such as `2024-04-11T00:00:00` | Sets the period the usage covers                                                                                                                                               |
| `filter` › `productId`            | `1441740010`                                                                          | Selects Applications                                                                                                                                                           |
| `filter` › `metricNameIn`         | `["requests", "data_transferred_total"]`                                              | Selects the two metrics                                                                                                                                                        |
| `filter` › `isEdgeFirewallActive` | `true`                                                                                | Optional. Keeps only the usage with Firewall active. The other filters of this kind are `isLoadBalancerActive`, `isImageProcessorActive`, and `isApplicationAcceleratorActive` |
| `aggregate` › `sum`               | `accounted`                                                                           | Adds up the usage accounted for the events that match the filters and the groups                                                                                               |
| `groupBy`                         | `[clientId, workloadId, productId, metricName]`                                       | Returns one total per workload and metric                                                                                                                                      |
| `limit`                           | Up to `10000`                                                                         | Caps the number of results                                                                                                                                                     |

The query asks for `clientId`, `workloadId`, `productId`, and `metricName`, and for the sum under the alias `total`.

To run the query:

1. **Open the GraphiQL Playground**

   In the browser where you are signed in to your Azion account, go to `https://api.azion.com/v4/consumption/graphql`.

2. **Write the query**

   Enter a `workloadConsumptionMetrics` query with the arguments and the fields that this section lists.

3. **Send the query**

The response holds one entry per workload and metric, with these fields:

| Field        | Content                                                                                                                   |
| ------------ | ------------------------------------------------------------------------------------------------------------------------- |
| `clientId`   | Your client identifier on Azion, such as `8437r`                                                                          |
| `workloadId` | The workload the usage belongs to, such as `4829301746`                                                                   |
| `productId`  | `1441740010`, the product ID of Applications                                                                              |
| `metricName` | `requests` or `data_transferred_total`                                                                                    |
| `total`      | For `data_transferred_total`, the bytes transferred, as a sum. For `requests`, the number of requests processed, as a sum |

You now have, for each workload, the requests your applications processed and the bytes they transferred in the period.

---

## Query the requests WAF inspected

The `waf_requests` metric counts the requests that Web Application Firewall (WAF) inspected. It is reported under the product ID of Applications. A query reads it with these arguments of `workloadConsumptionMetrics`:

| Argument                          | Value                                                                                 | Effect                                                                                                                                                                         |
| --------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `filter` › `tsRange`              | `begin` and `end`, in the `YYYY-MM-DDTHH:mm:ss` format, such as `2024-04-11T00:00:00` | Sets the period the usage covers                                                                                                                                               |
| `filter` › `productId`            | `1441740010`                                                                          | Selects Applications                                                                                                                                                           |
| `filter` › `metricName`           | `"waf_requests"`                                                                      | Selects the WAF metric                                                                                                                                                         |
| `filter` › `isEdgeFirewallActive` | `true`                                                                                | Optional. Keeps only the usage with Firewall active. The other filters of this kind are `isLoadBalancerActive`, `isImageProcessorActive`, and `isApplicationAcceleratorActive` |
| `aggregate` › `sum`               | `accounted`                                                                           | Adds up the usage accounted for the events that match the filters and the groups                                                                                               |
| `groupBy`                         | `[clientId, workloadId, productId, metricName]`                                       | Returns one total per workload                                                                                                                                                 |
| `limit`                           | Up to `10000`                                                                         | Caps the number of results                                                                                                                                                     |

The query asks for `clientId`, `workloadId`, `productId`, and `metricName`, and for the sum under the alias `total`.

To run the query:

1. **Open the GraphiQL Playground**

   In the browser where you are signed in to your Azion account, go to `https://api.azion.com/v4/consumption/graphql`.

2. **Write the query**

   Enter a `workloadConsumptionMetrics` query with the arguments and the fields that this section lists.

3. **Send the query**

The response holds one entry per workload, with these fields:

| Field        | Content                                                 |
| ------------ | ------------------------------------------------------- |
| `clientId`   | Your client identifier on Azion, such as `8437r`        |
| `workloadId` | The workload the usage belongs to, such as `4829301746` |
| `productId`  | `1441740010`, the product ID of Applications            |
| `metricName` | `waf_requests`                                          |
| `total`      | The number of requests WAF inspected, as a sum          |

You now have, for each workload, the number of requests WAF inspected in the period.

---

## Next steps

- [Query usage data from Image Processor](/en/documentation/guides/platform/observability/query-image-processor-usage-data-with-graphql.md): Count the images Image Processor transformed, from the same dataset.
- [Query usage data from Tiered Cache](/en/documentation/guides/platform/observability/query-tiered-cache-usage-data-with-graphql.md): Read the requests and the bytes that Tiered Cache served.
- [Real-Time Metrics](/en/documentation/platform/real-time-metrics/build-dashboards.md#applications): Follow the data transferred and the requests of your applications on charts in Azion Console.
- [Pricing](/en/documentation/fundamentals/pricing.md#workloads): The rates for requests and data transfer, which Azion bills per workload.
