Query usage data from Applications
Read the requests, the bytes transferred, and the WAF-inspected requests of your applications from the workloadConsumptionMetrics GraphQL dataset.
You can read the usage of your applications from the workloadConsumptionMetrics dataset of the GraphQL API, in the GraphiQL 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 and Query usage data from Tiered Cache.
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.
- 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:
In the browser where you are signed in to your Azion account, go to https://api.azion.com/v4/consumption/graphql.
Enter a workloadConsumptionMetrics query with the arguments and the fields that this section lists.
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:
In the browser where you are signed in to your Azion account, go to https://api.azion.com/v4/consumption/graphql.
Enter a workloadConsumptionMetrics query with the arguments and the fields that this section lists.
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.