VQL (Vantage Query Language)
The Vantage Query Language (VQL) is a SQL-like language for filtering cloud cost data. It includes a normalized schema across cloud providers and basic filter syntax for creating complex filters. VQL is currently available as part of the Vantage API as well as within the Vantage Terraform provider.
On Cost, Resource, and Kubernetes Efficiency Reports, you can create a filter and click View as VQL to see the filter represented in VQL.
- API. On supported endpoints, such as
/cost_reports
and/resource_reports
, you can use VQL in thefilter
parameter to programmatically create and fetch Cost Reports. - Terraform provider. In supported Terraform resources, such as
vantage_saved_filter
orvantage_cost_report
, you can use VQL for thefilter
argument to create filtered Cost Reports or saved filters.
The below examples show how to use VQL on both the API and the Terraform provider. This example creates a saved filter in your Vantage account using VQL.
- API
- Terraform Provider
curl --request POST \
--url https://api.vantage.sh/v2/saved_filters \
--header 'content-type: application/json' \
--header 'authorization: Bearer <ACCESS_TOKEN>' \
--data @- <<EOF
{
"filter": "(costs.provider = 'aws' AND costs.service = 'Amazon Relational Database Service') OR (costs.provider = 'kubernetes')",
"title": "RDS and Kubernetes",
"workspace_token": "wrkspc_abcde12345"
}
EOF
resource "vantage_saved_filter" "rds_kubernetes" {
title = "RDS and Kubernetes"
filter = "(costs.provider = 'aws' AND costs.service = 'Amazon Relational Database Service') OR (costs.provider = 'kubernetes')"
workspace_token = "wrkspc_abcde1234"
}
Key Concepts
VQL is based on the following key concepts, further described in subsequent sections.
- Schema
- Keywords
- Syntax
VQL uses a schema that organizes filters into namespaces. These namespaces comprise various fields that you can leverage to filter and retrieve specific cost-related data.
VQL includes keywords, like AND
, OR
, IN
, LIKE
, and NOT
, to create complex and precise filter conditions. These keywords vary per report type/scope.
VQL syntax closely resembles the WHERE
clause of a SQL query. You can construct filter operations to extract desired cost insights.
Scopes
VQL has a separate scope for each type of report—meaning that you cannot use VQL statements for Cost Reports when querying Resource Reports. See the following pages below to learn more about each VQL scope.