How to query usage data from Edge Functions
The workloadConsumptionMetrics dataset lets you get real-time aggregated data related to consumption and usage of Azion products, including Edge Functions.
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. Additionally, the data is available for up to 24 months.
This guide explains how to query Edge Functions’ compute time and invocations metrics using the GraphiQL Playground.
Querying Edge Functions’ usage data
To query Edge Functions’ compute time and invocations, proceed as follows:
- Access the GraphiQL Playground by going to 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.
- Send a query following this format:
query { workloadConsumptionMetrics( filter: { tsRange: { begin: "2025-02-01T00:00:00", end: "2025-03-01T00:00:00", } productId: 1531930033 metricNameIn: ["invocations", "compute_time"] } aggregate: { sum: accounted } limit: 10000 groupBy: [clientId, workloadId, productId, metricName, region] ) { clientId workloadId productId metricName region 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, 1531930033 for Edge Functions. |
metricName | Name of the calculated metric for analytics. Example: invocations or compute_time . |
- You’ll receive a JSON response similar to this:
{ "data": { "workloadConsumptionMetrics": [ { "clientId": "12345a", "workloadId": 1234567890, "productId": 1531930033, "metricName": "invocations", "region": "United States", "Total": 816931 }, { "clientId": "67890a", "workloadId": 1987654321, "productId": 1531930033, "metricName": "invocations", "region": "Europe", "Total": 33134 }, { "clientId": "111111b", "workloadId": 1231231230, "productId": 1531930033, "metricName": "compute_time", "region": "All Other Regions", "Total": 436363.41 } ] }}
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, 1531930033 for Edge Functions. |
metricName | Name of the measured metric for analytics. Example: invocations or compute_time . |
region | Geographical region where the usage was recorded. Example: Europe . |
total | This field is the result of a sum. When querying compute_time : total execution time for Edge Functions, measured in seconds. Example: 436363.41 . When querying invocations : total number of function invocations. Example: 33134 . |
Contributors