In this article, we will discuss consolidated billing and billing metrics and alarms for CloudWatch.

The purpose of consolidated billing is to allow a company to link multiple AWS accounts under one master account. In this way, the cost associated with the linked account will be charged to the master account. This allows a single cost in the company accounting.

VMware Training – Resources (Intense)

The billing metrics and alarms allow the user to monitor the costs that AWS services induce and to be able to take action in case specific cost thresholds are crossed.

The threshold crossing can be either valid (you need to use more resources because we have a higher number of customers) or can be because the resources are being wasted due to mis-usage (more resources than needed are used) or because some of the services have been compromised (like EC2 instances that have been hacked and sent data through the Internet).

So let’s discuss account consolidation first. To enable this feature, log in to the master account under which all other accounts will be consolidated, click on your name the top right corner, and select “Billing & Cost Management”:

From the left menu, select “Consolidated Billing” and then “Sign up for Consolidated Billing”:

As this is the first time doing this, we don’t have any linked accounts, so click on “Send a Request” to start the process:

Next put the email address under which the other account was registered to AWS:

You can view your linked account requests by using the “Linked Account Requests”. As you can see, this one is still in pending state, as the request wasn’t accepted yet:

Right now, the owner of the account that needs to be linked should have received the request on the email address used with AWS. This is an excerpt of the email received. You have information such as the requesting account number, requesting account email address:

You can either click on the link provided through the email or you can log in to the linked account and on “Consolidated Billing” you can see the consolidated billing request that can be either accepted or declined:

Once the request is accepted, on the linked account you will see the account name and email under which the linked account was consolidated. If, in the future, the consolidated billing must be removed, select “Remove Account”:

Back on the master account, you can see the linked accounts. You have the option to remove the linked account from the master account as well:

Once you remove a linked account, an email address is sent to notify the owner of the linked account that the account is no longer part of the consolidated bill.

Let’s discuss billing alerts and how to set them up. First, they need to be enabled. From the “Billing & Cost Management” select “Preferences.” Make sure that “Receive Billing Alerts” is checked. Click on “Manage Billing Alerts.” This will take you to the CloudWatch console:

On the CloudWatch console you have metrics and alarms for billing:

Select “Billing” from under the “Metrics” section from the left menu. You can see that you have nine billing metrics. You have a metric for the total charge that is a summing up of the costs from all your AWS services:

And you have billing metrics for each AWS service that cost you money in the past:

If you would like an overview of how much money you spent on AWS for all services, you need to select the “Total Estimated Charge” metric. In this case, the metric is showing the results from the current time back for 15 days. As you can see, the maximum charge was 0.4$ in July. Because the July month ended and because there is no charge in the coming month, you can see the charge dropping to 0$:

If you want to see the cost for a specific service, you can select only that service. In this case, it is about how much cost the EC2 instances in the last 15 days:

You can add another service like below to see how much you were charged for each service:

Based on these metrics, you can configure billing alarms so that you can be notified and take actions in case specified charge thresholds are crossed.

Let’s configure an alarm that will send an email when the total cost will cross the 10$ threshold.

From the CloudWatch console, select the alarms section and the click on “Create Alarm”:

Next, you need to define a name for the billing alarm. You can have multiple billing alarms for different metrics, for different thresholds.

As we said that we are going to track the total cost, we need to track the “Estimated Charges” metric. Then we need to specify the threshold after which the metric will be in alarmed state.

Also, we need to specify what will happen when the state for the alarm will be ALARM. In this case, we want to receive an email with some details about what has been crossed. You can add another action that can send you an email again when the state of the alarm will be OK.

As you can see in the alarm preview, we are far below the threshold that will trigger the alarm and this is because we have a cost of 0$.

By default, the alarm will monitor the metric and take an action if in the last 6 hours the threshold was crossed:

Once the alarm is created, the state will be OK:

To see more details about the alarm or to see the events of when the alarm was created or when it went off, select the alarm and check the two tabs below:

Let’s do a test with a billing alarm that will check the last day to see if the charge threshold was crossed. As we saw earlier, the cost for anything up to 15 days behind was 0.4$.

We will create an alarm for 0.1$ and we will monitor a period of one day. Once the alarm goes off, we should receive an email.

As you can see from the alarm preview, we know that the threshold was crossed without even creating the alarm:

Once you create the alarm, it will be in INSUFFICIENT_DATA:

But soon it will change to ALARM state:

This is an excerpt from the email received when the alarm threshold was crossed. As you can see, I’m getting the threshold that I set and the charges for the billing period:

And this is pretty much everything about consolidated billing and billing metrics for CloudWatch.

By reaching this point of the article, you should now know what consolidated billing is and what are its benefits.

Also, an important thing about billing is the ability to monitor your cost of the AWS services that are used. It’s important to be able to get notifications in case some of the AWS services trigger higher than expected costs. Based on the notifications, you can see if the risen costs are due to mis-usage or over-provisioning of the AWS resources