Learn how to use VQL when querying Cost Reports in the API or using the Terraform Provider.
costs
and tags
, which represent the available filters on Cost Reports in the Vantage console. To reference a filter, use the following syntax: namespace.field
(e.g., costs.provider
or tags.name
).
Namespace | Field | VQL Example |
---|---|---|
costs | provider | Providers example |
costs | allocation | Cost allocation example |
costs | region | Region example |
costs | marketplace | Marketplace example |
costs | account_id | Account ID example |
costs | provider_account_id | Provider account ID example |
costs | service | Service example |
costs | category | Category example |
costs | subcategory | Subcategory example |
costs | resource_id | Resource example |
costs | charge_type | Charge Type example |
tags | name | Tags name/value example |
tags | value | Untagged example |
Keyword | Description | VQL Sample | Explanation |
---|---|---|---|
AND | Logical AND operator | costs.provider = 'aws' AND costs.service = 'EC2' | This example filters AWS costs for the EC2 service, where both conditions must be true. |
OR | Logical OR operator | costs.provider = 'azure' OR costs.provider = 'aws' | This example retrieves costs from either Azure or AWS. At least one condition must be true. |
IN | Used to compare against an array list | costs.provider = 'azure' AND costs.account_id IN ('account-1', 'account-2') | This example filters based on a list of account IDs, returning data for the specified accounts You can also use IN along with a special syntax for filtering by multiple tags. See Filter by Multiple Tags for details. |
LIKE | Performs string comparisons | costs.provider = 'gcp' AND tags.name = 'environment' AND tags.value LIKE '%prod%' | This example selects data where the tag value contains prod , such as production-1 . Note that at this time, LIKE is not compatible with costs.account_id , costs.provider_account_id , costs.region , and costs.service . |
NOT | Represents negation | costs.provider = 'aws' AND costs.region NOT IN ('us-east-1', 'us-east-2') | This example filters out data from both specified regions, providing all AWS costs not in these regions. Use NOT IN to specify a list of single or multiple values. You can also use the != or <> operators for “is not.” costs.provider = 'aws' AND costs.region != 'us-east-1' < br />You can use NOT LIKE to perform string comparisons: costs.provider = 'gcp' AND tags.name = 'environment' AND tags.value NOT LIKE '%prod%' |
~* | Flexible match operator for tag values | costs.provider = 'aws' AND (tags.name = 'teams' AND tags.value ~* 'Team A') | Searches for all items where the tag value loosely matches Team A , ignoring case, whitespace, hyphens, and punctuation. |
!~* | Does not flexible match operator for tag values | costs.provider = 'aws' AND (tags.name = 'teams' AND tags.value !~* 'Team A') | Filters out all items where the tag value loosely matches Team A , ignoring case, whitespace, hyphens, and punctuation. |
WHERE
clause of a SQL query. By combining the schema and keywords above with parentheses, you can form complex filter operations, such as:
custom_provider:accss_crdntl_123a45bfdaf38765
).0.5
.
us-east-1
in the case of AWS, or AWS_US_EAST_1
in the case of Snowflake, below.
provider
and service
in addition to the resource_id
.
provider
and service
as well as category
.
provider
and service
as well as subcategory
.
environment
, with the value production
, in AWS.
team
tag of mobile
and data
), use the below syntax.
environment
tag with a value of staging
as well as the team
tag with a value of engineering
. This filter is the same as creating the following manual filter in the console.
LIKE
TeamA
, team-a
, and team_a
to a single Team A
tag value. See the Flexible Match documentation for details.
Click to view examples
AND
and OR
are not supported together in a single “query group.”Click to view examples
costs.provider
field is required on every call.Click to view examples
Click to view examples
Click to view examples