Vantage Launches an API for Resource Costs

by Vantage Team


Vantage Launches an API for Resource Costs

Today, Vantage is launching the ability for customers to programmatically retrieve resource-level costs through the API. Customers can also create on-the-fly, Vantage-Query-Language-compatible Resource Reports with detailed filter criteria to return custom sets of resources. This allows customers to retrieve rolling 30-day resource-level costs for over 100 supported resources (e.g., EC2 instances, S3 buckets), across 8 different providers (e.g., AWS, Azure).

While Vantage previously had a robust API for accessing Cost Report-related data, it did not have resource-level APIs exposed. Users could programmatically create Cost Reports using the associated /cost_reports endpoint; however, they did not have the option to create additional reports, such as Resource Reports, via the API—only view access was available. This limited the set of data that was accessible via the API and resulted in manual effort for exporting data via CSV.

Now, customers can use the new /resource_reports API endpoint. Support is also available for this endpoint through the Vantage Terraform Provider. Users can navigate to the API Access Tokens page and generate an API Key. Using this API Key, users can now:

  • Access resource-level cost data from these reports or via ad-hoc VQL. Resources that fit the filter criteria in a Resource Report or supplied VQL can now be enumerated over, with 30-day trailing cost data available.
  • Manage Resource Reports programmatically without having to fall back on point-and-click maintenance via the console. This allows for creating new Resource Reports on the fly, as well as updating or maintaining existing Resource Reports.

These new endpoints are now available to all users, including users in the free tier. To get started with the API, see the API documentation. For more information about VQL and available fields, see the product documentation.

Frequently Asked Questions

1. What is being launched today?

Vantage is launching the ability to create, update, and delete Resource Reports via the API. Users can programmatically create multiple reports using Vantage Query Language—or VQL— to define report filter criteria. Once Resource Reports are created, customers can also access the resource-level cost data for every resource contained within a Resource Report.

2. Who is the customer?

The customer is anyone who would like to automate the setup and maintenance of their Vantage Resource Reports or access resource-level cost data programmatically.

3. How much does this cost?

There is no additional cost to the API. It is included in the cost of the Vantage subscription, including users in the free tier.

4. What is VQL?

VQL is a SQL-like syntax, used within the Vantage API, for filtering cloud cost data. It includes a normalized schema across cloud providers and basic filter syntax for creating complex filters. You can use VQL to construct the value for the filter parameter on a report’s Write API endpoint.

5. How do I create a Resource Report via the API?

Send the following API request to create a Resource Report using the /resource_reports endpoint:


curl --request POST \
     --url https://api.vantage.sh/v2/resource_reports \
     --header 'accept: application/json' \
     --header 'authorization: Bearer TOKEN' \
     --header 'content-type: application/json' \
     --data @- <<EOF
{
  "workspace_token": "wrkspc_1234",
  "title": "EC2 Instances",
  "filter": "(resources.provider = 'aws' AND resources.type = 'aws_instance')"
}
EOF

The following is returned in a successful 200 response:

{
  "token": "prvdr_rsrc_rprt_1234",
  "title": "EC2 Instances",
  "filter": "(resources.provider = 'aws' AND resources.type = 'aws_instance')",
  "created_at": "2024-10-08T12:20:27Z",
  "workspace_token": "wrkspc_1234",
  "user_token": "usr_1234",
  "created_by_token": "usr_1234"
}

6. What methods that are available with this endpoint?

The following methods are available for the /resource_reports endpoint. Links to associated documentation are also provided to view example requests and responses.

  • POST/PUT /resource_reports: Create or update one or more new Resource Reports.
  • GET /resource_reports: Retrieve a list of all existing Resource Reports.
  • GET /resource_reports/{resource_report_token}: Query resources associated with a Resource Report by providing a resource_report_token.
  • DELETE /resource_reports/{resource_report_token}: Delete a specific Resource Report.
  • GET /resources: Return resources within a Resource Report.
    • GET /resources?filter=resources.provider%20%3D%20'aws': Return a filtered set of resources within a Resource Report.
    • GET /resources/<resource uuid (e.g., AWS ARN)>: Return specific resources.
  • GET /resources/{resource_token}: Return data for a single resource.
    • GET /resources/{resource_token}?include_cost=true: You can also include costs in both the specific resource or list of resources response with include_cost=true. The costs field is then populated with an array of category costs for the resource for the previous 30 days.

7. Who has permission to use the API?

All users can generate Read API keys. You need to have the Editor role or above to modify resources with Write API keys.

8. How do I authenticate with the API?

The Vantage API uses API tokens for authentication. You can create both user and service tokens in the console. An API key can be assigned Read and Write scopes. See the API documentation for details on how to get started with API keys.

9. Are there API rate limits?

Yes, individual API keys are limited to 20 requests per minute. Rate limiting status is available in the headers of each API response. See the API documentation for details.

10. I have multiple workspaces, how do I ensure a resource report is created in the correct one?

When you create a report, you can pass in a workspace_token as a parameter to specify which workspace the resource is created under. (See the documentation for the /workspaces endpoint for details on how to fetch a list of workspace tokens.)

If you have only one workspace, you do not need to pass a workspace_token when creating resources.

11. After I update a Resource Report via the API, how long does it take for the report to update in the console?

After you update a report via the API, the updates are immediately available within the console. If a report needs costs regenerated, that process will begin immediately. Any modified filters are also immediately available in the console.

12. Is Terraform support available for this endpoint?

Terraform support is available via the following Terraform resource and data source:

13. Can I view the VQL for an existing report in the UI?

Yes, in the Filters menu on a Resource Report, click the View as VQL button to view the VQL representation of the filter criteria.

14. What other report types does Vantage plan to support creating via the API?

We plan to add support for creating the following report types via the API in a future release:

  • Network Flow Reports
  • Financial Commitment Reports (currently support deleting and fetching)
  • Kubernetes Efficiency Reports (currently support deleting and fetching)

15. What are some resources I can use to get started with the API?

Vantage provides multiple resources for getting started with the API: