Prefer no setup? Use the spend presets
If you only want your AWS bill on your Home Screen, you don't need a dashboard. Turn on billing metrics (step 1), then add CloudPeek's spend presets with Create Widget › Preset. Between them they show everything the dashboard below does:
| Dashboard widget | Preset | Difference |
|---|---|---|
| Top 5 services by spend | Spend by service | Every service, biggest first, with those that don't fit added up as Other. Its total is the sum of the services, rather than your whole bill. |
| Month-to-date spend | Month-to-date spend | The same. |
| Last 7 days' spend | Daily spend by account | The same, with each account stacked in its column in an AWS Organizations management account, and it can also show 2 weeks, 30 days or the month to date. |
| Top 5 services' share of spend | Spend share | Every service, not just five. |
The presets add Month-end forecast, Spend and forecast, Daily spend by service, Daily spend table and Spend trend too: see Presets. Build the dashboard instead if you want a fixed top five, your whole bill as the total, the same widgets in the CloudWatch console, or a dashboard you keep in CloudFormation or Terraform.
What you'll build
You'll create a CloudWatch dashboard named CloudPeek-Spend with four widgets. The first is a bar chart of the five services you've spent most on so far this month, found automatically, with your account's total. The second is that month-to-date total with a sparkline of the past week. The third is what you've spent on each of the last 7 days, a column per day, and the fourth is a pie chart of how your top five services share their spend. In CloudPeek they look like this:
It takes about 15 minutes in the AWS console, or one deploy with CloudFormation or Terraform. Pick your tool on the tabs in each step.
Before you start
- An AWS account, and a sign-in that can change billing preferences and create CloudWatch dashboards and IAM users and policies, such as an administrator. If your accounts are in AWS Organizations, use the management account to see the whole organisation's spend.
- CloudPeek on your iPhone, iPad or Android phone.
What it costs. Billing metrics are free. The CloudWatch free tier includes three dashboards; beyond that, each dashboard is $3 a month. CloudPeek's refreshes call GetMetricData, which AWS bills at $0.01 per 1,000 metrics. AWS updates billing metrics only a few times a day, so these widgets refresh every 3 hours at most: with all four pinned, that's about 15 metrics per refresh, about 4¢ a month. Settings estimates it for your own widgets, under Refresh. See CloudWatch pricing.
1. Turn on billing metrics
AWS only sends your estimated charges to CloudWatch after you opt in. You do this once per account, in the console: CloudFormation, Terraform and the AWS CLI can't change this setting.
- Sign in to the AWS console and open Billing and Cost Management › Billing preferences.
- Under Alert preferences, choose Edit.
- Select Receive CloudWatch billing alerts and save the change.
Estimated charges are published to the US East (N. Virginia) region, us-east-1, several times a day. They count from the start of the month, so they go back to zero each month. The first data can take a few hours to appear. If you're not signed in as the root user, the account must also allow IAM access to billing information (under Account › IAM user and role access to Billing information).
Until the first data arrives, the dashboard you'll create next says No data available, and CloudPeek's spend widgets say “Turn on CloudWatch billing alerts in the Billing console. Spend appears within a day.” (“Turn on CloudWatch billing alerts.” on a small widget). To check whether billing metrics have started, open CloudWatch in us-east-1 and choose Metrics › All metrics: a Billing namespace appears once they have. Metrics Explorer doesn't list billing metrics, so look under All metrics.
In AWS Organizations, billing metrics are only in the management account, which has every account's charges, broken down by account (Spend by account). The other accounts have none, so turn on billing alerts in the management account and add it to CloudPeek for spend widgets. In an account you signed in to with IAM Identity Center that isn't the management account, CloudPeek's spend widgets say “Spend for this account is in your organisation's management account.” (“Spend is in your management account.” on a small widget). CloudPeek tells the management account by whether it can list the organisation's accounts (organizations:ListAccounts, in CloudPeek's policy), so give the management account's sign-in that permission.
2. Create the dashboard
- Open the CloudWatch console in us-east-1 and choose Create dashboard.
- Name it
CloudPeek-Spendand choose Create dashboard. If the Add widget window opens, close it. - Choose Actions › View/edit source, replace the source with the dashboard JSON, and choose Update.
- Choose Save.
Download spend-by-service.json (it's shown in full below), then run:
aws cloudwatch put-dashboard \
--region us-east-1 \
--dashboard-name CloudPeek-Spend \
--dashboard-body file://spend-by-service.json
One template creates the dashboard, and also the CloudPeek policy and IAM user from step 3. Here's the dashboard resource:
Dashboard:
Type: AWS::CloudWatch::Dashboard
Properties:
DashboardName: !Ref DashboardName
DashboardBody: !Sub |
{
"start": "-P7D",
"widgets": [
{
"type": "metric",
"x": 0,
"y": 0,
"width": 12,
"height": 8,
"properties": {
"title": "Top ${TopServices} services by spend",
"view": "bar",
"region": "us-east-1",
"start": "-P1D",
"stat": "Maximum",
"period": 21600,
"metrics": [
[ "AWS/Billing", "EstimatedCharges", "Currency", "${Currency}", { "label": "Total" } ],
[ { "expression": "SORT(SEARCH('{AWS/Billing,Currency,ServiceName} MetricName=\"EstimatedCharges\" Currency=\"${Currency}\"', 'Maximum', 21600), MAX, DESC, ${TopServices})", "label": "${!PROP('Dim.ServiceName')}", "id": "top" } ]
]
}
},
{
"type": "metric",
"x": 12,
"y": 0,
"width": 6,
"height": 8,
"properties": {
"title": "Month-to-date spend",
"view": "singleValue",
"region": "us-east-1",
"stat": "Maximum",
"period": 21600,
"sparkline": true,
"metrics": [
[ "AWS/Billing", "EstimatedCharges", "Currency", "${Currency}", { "label": "Total" } ]
]
}
},
{
"type": "metric",
"x": 18,
"y": 0,
"width": 6,
"height": 8,
"properties": {
"title": "Last 7 days' spend",
"view": "timeSeries",
"region": "us-east-1",
"start": "-P7D",
"stat": "Maximum",
"period": 86400,
"yAxis": { "left": { "min": 0 } },
"metrics": [
[ { "expression": "IF(DIFF(m1) < 0, m1, DIFF(m1))", "label": "Spend", "id": "daily" } ],
[ "AWS/Billing", "EstimatedCharges", "Currency", "${Currency}", { "id": "m1", "visible": false } ]
]
}
},
{
"type": "metric",
"x": 0,
"y": 8,
"width": 12,
"height": 8,
"properties": {
"title": "Top ${TopServices} services' share of spend",
"view": "pie",
"region": "us-east-1",
"start": "-P1D",
"stat": "Maximum",
"period": 21600,
"metrics": [
[ { "expression": "SORT(SEARCH('{AWS/Billing,Currency,ServiceName} MetricName=\"EstimatedCharges\" Currency=\"${Currency}\"', 'Maximum', 21600), MAX, DESC, ${TopServices})", "label": "${!PROP('Dim.ServiceName')}", "id": "share" } ]
]
}
}
]
}
The body is the dashboard JSON below, with ${TopServices} and ${Currency} filled in from the stack's parameters. ${!PROP(…)} stops CloudFormation from treating the dynamic label as one of its own variables.
aws cloudformation deploy \
--region us-east-1 \
--stack-name CloudPeek \
--template-file cloudpeek-setup.yaml \
--capabilities CAPABILITY_NAMED_IAM
Or, in the CloudFormation console in us-east-1, choose Upload a template file, name the stack CloudPeek, check the parameters, and select I acknowledge that AWS CloudFormation might create IAM resources with custom names before you submit. When the stack reaches CREATE_COMPLETE, its Outputs tab links to the dashboard.
| Parameter | Default | What it's for |
|---|---|---|
DashboardName | CloudPeek-Spend | The dashboard's name. |
TopServices | 5 | How many of your biggest services to chart, from 1 to 20. |
Currency | USD | The currency your bill is in. |
PolicyName | CloudPeek | The policy's name. |
CreateUser | true | Set to false if you'll sign in with IAM Identity Center. |
UserName | cloudpeek | The IAM user's name. |
To change them, add --parameter-overrides, such as --parameter-overrides TopServices=10 CreateUser=false.
One configuration creates the dashboard, and also the CloudPeek policy and IAM user from step 3. Here's the dashboard resource:
resource "aws_cloudwatch_dashboard" "spend" {
dashboard_name = var.dashboard_name
dashboard_body = jsonencode({
start = "-P7D"
widgets = [
{
type = "metric"
x = 0
y = 0
width = 12
height = 8
properties = {
title = "Top ${var.top_services} services by spend"
view = "bar"
region = "us-east-1"
start = "-P1D"
stat = "Maximum"
period = 21600
metrics = [
["AWS/Billing", "EstimatedCharges", "Currency", var.currency, { label = "Total" }],
[{
expression = "SORT(SEARCH('{AWS/Billing,Currency,ServiceName} MetricName=\"EstimatedCharges\" Currency=\"${var.currency}\"', 'Maximum', 21600), MAX, DESC, ${var.top_services})"
label = "$${PROP('Dim.ServiceName')}"
id = "top"
}],
]
}
},
{
type = "metric"
x = 12
y = 0
width = 6
height = 8
properties = {
title = "Month-to-date spend"
view = "singleValue"
region = "us-east-1"
stat = "Maximum"
period = 21600
sparkline = true
metrics = [
["AWS/Billing", "EstimatedCharges", "Currency", var.currency, { label = "Total" }],
]
}
},
{
type = "metric"
x = 18
y = 0
width = 6
height = 8
properties = {
title = "Last 7 days' spend"
view = "timeSeries"
region = "us-east-1"
start = "-P7D"
stat = "Maximum"
period = 86400
yAxis = { left = { min = 0 } }
metrics = [
[{ expression = "IF(DIFF(m1) < 0, m1, DIFF(m1))", label = "Spend", id = "daily" }],
["AWS/Billing", "EstimatedCharges", "Currency", var.currency, { id = "m1", visible = false }],
]
}
},
{
type = "metric"
x = 0
y = 8
width = 12
height = 8
properties = {
title = "Top ${var.top_services} services' share of spend"
view = "pie"
region = "us-east-1"
start = "-P1D"
stat = "Maximum"
period = 21600
metrics = [
[{
expression = "SORT(SEARCH('{AWS/Billing,Currency,ServiceName} MetricName=\"EstimatedCharges\" Currency=\"${var.currency}\"', 'Maximum', 21600), MAX, DESC, ${var.top_services})"
label = "$${PROP('Dim.ServiceName')}"
id = "share"
}],
]
}
},
]
})
}
It builds exactly the dashboard JSON below with jsonencode. $${PROP(…)} stops Terraform from treating the dynamic label as an interpolation. Save the file in an empty directory and run:
terraform init
terraform apply
| Variable | Default | What it's for |
|---|---|---|
dashboard_name | CloudPeek-Spend | The dashboard's name. |
top_services | 5 | How many of your biggest services to chart, from 1 to 20. |
currency | USD | The currency your bill is in. |
policy_name | CloudPeek | The policy's name. |
create_user | true | Set to false if you'll sign in with IAM Identity Center. |
user_name | cloudpeek | The IAM user's name. |
To change them, pass -var, such as terraform apply -var top_services=10 -var create_user=false. To add the dashboard to an existing configuration, copy the resources and leave out the terraform and provider blocks.
3. Create a sign-in for CloudPeek
Follow Create a sign-in for CloudPeek in Get started. It creates the CloudPeek policy and either an IAM user with an access key or an IAM Identity Center permission set.
Follow Create a sign-in for CloudPeek in Get started, which has the AWS CLI commands for an IAM user or an IAM Identity Center permission set.
The stack from step 2 already created the CloudPeek policy and, unless you set CreateUser to false, the cloudpeek user. Create the user's access key. The secret is shown only once:
aws iam create-access-key --user-name cloudpeek
For IAM Identity Center, attach CloudPeek to a permission set as a customer managed policy (see Option B).
The configuration from step 2 already created the CloudPeek policy and, unless you set create_user to false, the cloudpeek user. Create the user's access key outside Terraform, so the secret stays out of your state. It's shown only once:
aws iam create-access-key --user-name cloudpeek
For IAM Identity Center, attach CloudPeek to a permission set as a customer managed policy (see Option B).
4. Add the account and pin the widgets
- In CloudPeek, add the account on the Accounts tab with the access key or IAM Identity Center (see Get started, step 2). Any default region works: the spend widgets always read
us-east-1. - On the Accounts tab, open the account, then the CloudPeek-Spend dashboard, and tap Pin on the widgets you want: Top 5 services by spend, Month-to-date spend, Last 7 days' spend and Top 5 services' share of spend.
- Add CloudPeek to your Home Screen once for each widget, and choose which one each shows (see Choose which widget it shows). Medium suits the bar and pie charts; small suits the month-to-date total and the last 7 days.
Result: once billing metrics have arrived, the bar chart lists your biggest services this month, with the total above them. Until then, the widgets say No data for this time range.
On iPhone and iPad, the total also works well on the Lock Screen, where widgets show the latest value.
How the dashboard works
Whichever tool you used, this is the dashboard you end up with:
{
"start": "-P7D",
"widgets": [
{
"type": "metric",
"x": 0,
"y": 0,
"width": 12,
"height": 8,
"properties": {
"title": "Top 5 services by spend",
"view": "bar",
"region": "us-east-1",
"start": "-P1D",
"stat": "Maximum",
"period": 21600,
"metrics": [
[ "AWS/Billing", "EstimatedCharges", "Currency", "USD", { "label": "Total" } ],
[ { "expression": "SORT(SEARCH('{AWS/Billing,Currency,ServiceName} MetricName=\"EstimatedCharges\" Currency=\"USD\"', 'Maximum', 21600), MAX, DESC, 5)", "label": "${PROP('Dim.ServiceName')}", "id": "top" } ]
]
}
},
{
"type": "metric",
"x": 12,
"y": 0,
"width": 6,
"height": 8,
"properties": {
"title": "Month-to-date spend",
"view": "singleValue",
"region": "us-east-1",
"stat": "Maximum",
"period": 21600,
"sparkline": true,
"metrics": [
[ "AWS/Billing", "EstimatedCharges", "Currency", "USD", { "label": "Total" } ]
]
}
},
{
"type": "metric",
"x": 18,
"y": 0,
"width": 6,
"height": 8,
"properties": {
"title": "Last 7 days' spend",
"view": "timeSeries",
"region": "us-east-1",
"start": "-P7D",
"stat": "Maximum",
"period": 86400,
"yAxis": { "left": { "min": 0 } },
"metrics": [
[ { "expression": "IF(DIFF(m1) < 0, m1, DIFF(m1))", "label": "Spend", "id": "daily" } ],
[ "AWS/Billing", "EstimatedCharges", "Currency", "USD", { "id": "m1", "visible": false } ]
]
}
},
{
"type": "metric",
"x": 0,
"y": 8,
"width": 12,
"height": 8,
"properties": {
"title": "Top 5 services' share of spend",
"view": "pie",
"region": "us-east-1",
"start": "-P1D",
"stat": "Maximum",
"period": 21600,
"metrics": [
[ { "expression": "SORT(SEARCH('{AWS/Billing,Currency,ServiceName} MetricName=\"EstimatedCharges\" Currency=\"USD\"', 'Maximum', 21600), MAX, DESC, 5)", "label": "${PROP('Dim.ServiceName')}", "id": "share" } ]
]
}
}
]
}
- The expression row finds your top services for you.
SEARCHfinds every service's estimated charges, andSORT(…, MAX, DESC, 5)keeps the five biggest. Services you start using appear on their own. To show more or fewer, change the5at the end of the bar and pie charts' expressions (or theTopServicesparameter, or thetop_servicesvariable). - The label
${PROP('Dim.ServiceName')}names each bar after its service, such asAmazonEC2orAWSLambda. CloudPeek shows the short name (EC2, Lambda), lists them biggest first, and adds up any that don't fit into Other. - The row with only a
Currencydimension is your whole account's charges so far this month. CloudPeek shows it as the widget's Total rather than as a bar, so services outside the top five still count. In the CloudWatch console it appears as one more bar. - Charges count from the start of the month, so the bar and pie charts look at just the last day (
"start": "-P1D"). That way the ranking follows this month's charges rather than last month's. The month-to-date total uses the dashboard's week for its sparkline. - The last 7 days come from the same month-to-date charge, read once a day (
"period": 86400) from the hiddenm1row.DIFF(m1)is how much it rose each day, and on the day it goes back to zero at the start of a month,IF(… < 0, m1, …)takes the new month's charge instead. - CloudPeek draws each of those days as a column, from midnight in your time zone, with today's so far on the right. The CloudWatch console has no chart like that, so it draws the same days as a line.
- If your bill isn't in US dollars, change every
USDin the rows and expressions to your currency code. - The pie chart uses the same expression as the bar chart, without the Total row, so its slices are your top five services' shares of what they cost together. CloudPeek puts that sum in the middle.
- To include everything else in the pie as an Other slice, with your whole account's charges in the middle, copy the bar chart's Total row into it. The CloudWatch console then draws the Total as one more slice.
To see every service's charges, open CloudWatch in us-east-1 and choose All metrics › Billing › By Service.
To see each service's spend per day, stacked in a column a day, add the Daily spend by service preset (see Spend presets), or describe it in an AI widget, such as “Daily spend by service for the last 7 days, stacked”. Each service's charge counts from the start of the month too, so they work out how much each one rose each day, as DIFF(m1) does for the total.
To list the last 7 days' spend in a table, a row a day, newest first, add the Daily spend table preset, or describe it in an AI widget, such as “A table of the last 7 days' spend, one row per day”. On a dashboard, that's the DIFF(m1) rows above in a widget with "view": "table" and "table": {"layout": "vertical"}.
Spend by account
If your accounts are in AWS Organizations, the management account's billing metrics also break charges down by account, with a LinkedAccount dimension. To chart your five biggest accounts this month rather than your biggest services, use this expression row in the bar or pie chart in place of the services one:
[ { "expression": "SORT(SEARCH('{AWS/Billing,Currency,LinkedAccount} MetricName=\"EstimatedCharges\" Currency=\"USD\"', 'Maximum', 21600), MAX, DESC, 5)", "id": "accounts" } ]
Or describe what you want in an AI widget, such as “Spend by account this month”, or “Stacked bar graph of SQS spend for each account over the last 7 days” for one service. The Daily spend by account preset already stacks each account's spend in a column a day: see Spend presets.
CloudWatch only knows each account by its 12-digit ID. CloudPeek shows the account's name instead, from the first of these that names it:
- AWS Organizations, which names every account in the organisation. It needs
organizations:ListAccounts, which is in CloudPeek's policy, and answers only the management account (or a delegated administrator account). CloudPeek asks it once a day. - IAM Identity Center, if you signed in with it: the names of the accounts it lets you sign in to.
- Your Accounts tab: the name you gave an account you've added.
An account none of them names keeps its ID. If AWS Organizations refuses, CloudPeek asks again after six hours, or as soon as you refresh the widget.
Removing it
In the CloudWatch console in us-east-1, open Dashboards, select CloudPeek-Spend and choose Delete. To remove CloudPeek's access too, delete the cloudpeek user and the CloudPeek policy in the IAM console.
aws cloudwatch delete-dashboards --region us-east-1 --dashboard-names CloudPeek-Spend
CloudFormation can't delete a user that still has an access key, or a policy that something outside the stack still uses. Delete the user's access key and detach the policy from any permission sets first, then delete the stack:
aws iam list-access-keys --user-name cloudpeek
aws iam delete-access-key --user-name cloudpeek --access-key-id <access-key-id>
aws cloudformation delete-stack --region us-east-1 --stack-name CloudPeek
IAM won't delete a user that still has an access key, or a policy that's still attached elsewhere. Delete the user's access key and detach the policy from any permission sets first, then destroy:
aws iam list-access-keys --user-name cloudpeek
aws iam delete-access-key --user-name cloudpeek --access-key-id <access-key-id>
terraform destroy
Troubleshooting
The widgets are empty, or the dashboard says “No data available”
Billing metrics aren't reaching CloudWatch yet, and CloudPeek's widgets say “Turn on CloudWatch billing alerts in the Billing console. Spend appears within a day.” Check that they're turned on (step 1) and give them a few hours. Then look for the Billing namespace under All metrics in us-east-1 (Metrics Explorer doesn't list billing metrics). In AWS Organizations, set this up in the management account, which sees the whole organisation's charges: in another of its accounts, the widgets say “Spend for this account is in your organisation's management account.”
Accounts show as numbers
CloudPeek couldn't find their names. In the management account, add organizations:ListAccounts to CloudPeek's sign-in, or deploy the updated template from Get started, then refresh the widget. See Spend by account.
A service is missing
It isn't one of your five biggest this month. To chart more, raise the number at the end of the SORT expression (see how it works). Its charges are already included in the Total.
The Total is bigger than the bars added up
That's expected. The Total is your whole bill so far this month, including services outside your top five.
Something else
See Troubleshooting, or email support@cloudpeek.app. Never send us your secret access key.