---
name: azion-query-usage-data-from-image-processor
description: >-
  Query the Consumption dataset from the GraphiQL Playground for the count of images Image Processor transformed.
---

# Query usage data from Image Processor

Query the total number of images processed by Image Processor from the [GraphiQL Playground](/en/documentation/devtools/graphql/graphql-playground/), using the **workloadConsumptionMetrics** dataset.

Azion retains this data for up to 24 months, and you can export the results to a third-party platform for further analysis.

---

## Prerequisites

- An Azion account, signed in. The consumption endpoint returns an error to an unauthenticated request.

---

## Query the total images processed

To retrieve the count for a specific time range:

1. **Open the GraphiQL Playground**

   Access `https://api.azion.com/v4/consumption/graphql`.

2. **Send the query**

   Send a query in this format:

   ```graphql
   query {
     workloadConsumptionMetrics(
       filter: {
         tsRange: { 
           begin: "2025-02-01T00:00:00",
           end: "2025-03-01T00:00:00",
         }
         productId: 1441110021
         metricName: "images_processed"
       }
       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, `1441110021` for Image Processor.                                                                                                                       |
   | `metricName`     | Name of the calculated metric for analytics. In this case, `images_processed`.                                                                                                                                     |

   > **Note**
   >
   > This query sums the images Image Processor processed and groups the total by `clientId` and `workloadId`. For more information, refer to [Consumption GraphQL API Fields](/en/documentation/devtools/graphql/gql-consumption-fields/).

3. **Review the response**

   ```json
   {
     "data": {
       "workloadConsumptionMetrics": [
         {
           "clientId": "0000z",
           "workloadId": 4829103746,
           "productId": 1441110021,
           "metricName": "images_processed",
           "total": 32
         },
         {
           "clientId": "0000z",
           "workloadId": 1938475620,
           "productId": 1441110021,
           "metricName": "images_processed",
           "total": 19478
         },
         {
           "clientId": "0000z",
           "workloadId": 7584931026,
           "productId": 1441110021,
           "metricName": "images_processed",
           "total": 299612
         },
         {
           "clientId": "0000z",
           "workloadId": 6203849175,
           "productId": 1441110021,
           "metricName": "images_processed",
           "total": 1432
         },
         {
           "clientId": "0000z",
           "workloadId": 3948571023,
           "productId": 1441110021,
           "metricName": "images_processed",
           "total": 268675
         }
       ]
     }
   }
   ```

   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, `1441110021` for Image Processor.               |
   | `metricName` | Name of the measured metric for analytics. Example: `images_processed`.                                    |
   | `total`      | Total number of images processed by Image Processor. This field is the result of a sum. Example: `268675`. |

The response returns the total number of images processed for each client and workload in the queried period.

---

## Next steps

- [Applications limits](/en/documentation/platform/applications/limits/#image-processor) - Check the maximum values this usage counts against.
- [Image Processor settings](/en/documentation/platform/applications/image-processor/settings/) - Find the other places this usage data surfaces in Console.
- [Consumption GraphQL API Fields](/en/documentation/devtools/graphql/gql-consumption-fields/) - Explore every field the consumption dataset exposes.
