While this isn’t the fabled AWS Billing API that no doubt is on the way, what we do with your Cloud cost and usage data is mine it for insights that help you reduce cost, forecast and manage budget, and control ‘who does what’. With that in mind, today we are announcing availability of the CloudVertical API, which will allow you extract data into your own tools or reports.
The CloudVertical app is built on top of this API – so it’s extremely powerful and detailed – and we’re ‘eating our own dogfood’. We’re really excited to see what mashups and new tools get built with this!
The API allows you to access resources via JSON requests over HTTP, using GET verb. The data is returned in JSON. A list of all the available requests are on the API Documentation.
Getting Started
All of the API requests are authenticated via an existing user account – so if you don’t have one – signup now! Every request must include your API key, which you can find in Settings –> Account Details tab.
The API key allows us to authenticate your calls and give an access to your resources – so keep it safe! You can of course regenerate it anytime in Settings –>Account Details tab. In order to maintain security always use SSL by beginning the requests with ‘https’.
API URL starts with
https://resource.cloudvertical.com/
Mostly in every call you should be using time range parameters
from: Time in UTC to: Time in UTC
Common Use Examples
1. Month to date cost with cost projection by end of month
2. EC2 cost for certain time frame and tags
3. S3 buckets with cost
Month to date cost with cost projection by end of month
API_URL/v01/statements/overview/cost_summary?api_key=uqisoauiiqo&from=2012-09-01&to=2012-09-27
optionally if you have few cloud connections you can add parameter cloud_connection_id to the request so the data returned by API would be just narrowed to that cloud connection.
API_URL/v01/statements/overview/cost_summary?api_key=uqisoauiiqo&from=2012-09-01&to=2012-09-27&cloud_connection_id=78819
Response from server would look like something like this:
{
"cue": {
"previous":"0.2:1",
"current": "0.0:1"
},
"total_cost": {
"previous": 1755.6899999999991,
"current": 2817.2300000000027
},
"avg_daily_cost": {
"previous": 65.02555555555553,
"current": 104.34185185185196
},
"end_of_month_estimated_cost": {
"previous": 1817.5599999999993,
"current": 3181.65743545413
},
"reservations_amortised": {
"previous": 0,
"current": 1.016883666666649
}
}
let me explain what data you get:
cue: is a Cloud Usage Efficiency metric introduced by us which tells you how are you doing in terms of usage/spend efficiency
total_cost: your total cost for current time-range and the previous analogical period
avg_daily_cost: your avg daily spent in selected time frame and for the previous period
end_of_month_estimated_cost: it’s cost projected by end of month for current month and the total spent from last month,
reservations_amortised: if you purchased the ReservedInstances we would show you what’s the amortization cost for selected timeframe and the previous period.
That call works if you’ve provided either full AWS console access or IAM billing access or programmatic billing.
If you have not – not a problem we have something for you as well, the cost summary calculated by us based on data pulled from the AWS API (it would be slightly different that AWS statement especially if you have consolidated billing and you’ve provided only API Keys for one of them)
/v01/usages/overview/cost_summary?api_key=V93xAJGz3QywAbnJucaZ&from=2012-09-01&to=2012-09-27
and the response looks the same as for statement cost
{
"cue": {
"previous": 5.0:1,
"current": "4.9:1"
},
"total_cost": {
"previous": 1326.16,
"current": 1281.9399999999998
},
"avg_daily_cost": {
"previous": 47.362857142857145,
"current": 45.78357142857142
},
"end_of_month_estimated_cost": {
"previous": 1475.69,
"current": 1373.5071428571428
},
"reservations_amortised": {
"previous": 0,
"current": 2.5292124337899367
}
}
the difference is that you can filter the data by tags by passing parameter with_tags if you want to narrow down result to resources tagged by tags or without_tags when you want to exclude resources tagged by certain tag
and the request would look like this
/v01/usages/overview/cost_summary?api_key=V93xAJGz3QywAbnJucaZ&from=2012-09-01&to=2012-09-27&with_tags[]=cloudvertical&with_tags[]=db&without_tags[]=replication
EC2 cost for certain time frame and tags
If you want to just get the EC2 cost for certain time frame and tags here is the request which would give you that and a bit more:
/v01/computes/overview/ec2?api_key=V93xAJGz3QywAbnJucaZ&from=2012-09-01&to=2012-09-27&
and the response looks like this
{
"summary": {
"avg_instances": {
"previous": 5.03,
"current": 5.74
},
"avg_ecus": {
"previous": 17.92,
"current": 20.95
},
"avg_ram": {
"previous": 37.9,
"current": 43.05
}
},
"details": {
"total_cost": {
"previous": 897.5,
"current": 994.27
},
"ebs_total_cost": {
"previous": 114.67,
"current": 88.23
},
"avg_utilisation": {
"previous": 23.19,
"current": 19.04
},
"ram_hours_used": {
"previous": 22738.14,
"current": 25828.81
},
"ecu_hours_used": {
"previous": 10751.31,
"current": 12568.2
}
}
}
Data is returned for the current timeframe and so you can compare for the previous period, we return two section summary and details at the summary section we return attributes
avg_instances: it’s amount of average running instances
avg_ecus: it’s average amount of ECU deployed
avg_ram: it’s average amount of RAM deployed
avg_utilisation: the average CPU utilisation
at the details section:
total_cost: EC2 instances total cost
ebs_total_cost: EBS volumes total cost
ram_hours_used: the amount of 1GB RAM /hour used
ecu_hours_used: the amount of 1ECU / hour used
S3 buckets with cost
If you’ve provided IAM billing credentials or AWS console access we would be able to present you cost for each bucket for certain time range.
request
/v01.1/storage/list/s3_bucket?&from=2012-09-01&to=2012-10-02&forecast=true&per_page=100&page=1
and the response would look like this
{
"current_page": 1,
"per_page": 100,
"total_entries": 69,
"entries": [{
"cloud_connection_id": 13217,
"provider": "Amazon",
"reference_id": "bucket",
"region": "US",
"forecast": {
"standard_cost": 0,
"reduced_cost": 0,
"total_cost": 0.002872,
"standard_previous_cost": 0,
"reduced_previous_cost": 0,
"total_previous_cost": 0.007438
},
"standard_cost": 0,
"standard_last_month_cost": 0,
"reduced_cost": 0,
"reduced_last_month_cost": 0,
"total_cost": 0.002872,
"total_last_month_cost": 0
}]
}
the response is mostly self explanatory, prefixes standard,reduced are corresponding to the S3 storage option.
We’re really excited to see what gets built on top of this. Let us know in the comments! If you have any questions around the CloudVertical API, please feel free to contact us at support@cloudvertical.com.
Related posts: