Query usage data from Functions
Query the Consumption dataset from the GraphiQL Playground for the compute time and the invocations a function consumed.
The workloadConsumptionMetrics dataset lets you get real-time aggregated data related to consumption and usage of Azion products, including 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.
You read the compute time and the invocations of Functions from the GraphiQL Playground.
Query the compute time and invocations
To read both metrics for a period:
- 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, the endpoint returns an error message.
- Send a query following this format:
GraphQL
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 Functions. |
metricName | Name of the calculated metric for analytics. Example: invocations or compute_time. |
- The response carries a JSON object similar to this:
JSON
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 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 | The result of the sum. For compute_time, the total execution time of Functions in seconds, such as 436363.41. For invocations, the total number of invocations, such as 33134. |