In this video, you’ll see how to visualize your AWS cost and usage
with Amazon Managed Grafana.
With this solution, you can create a cost and usage report,
query Amazon Simple Storage Service (Amazon S3) data using
Amazon Athena, and visualize the data on a Grafana dashboard.
To get started, let’s navigate to the Billing Management Console
to create a cost and usage report.
First, we’ll give the report a name.
In addition to the identifiers and attributes already included in the report,
we can include individual resource IDs.
Let’s select that option.
Next, we need to configure an Amazon S3 bucket to receive the reports.
We can select an existing S3 bucket or create a new one.
We’ll use an existing one.
Next, we’ll verify use of the default policy.
We could make the policy more restrictive, but for this example, we’ll use the default.
For the report path prefix, we’ll specify “Grafana.”
Under Report versioning, we’ll opt to overwrite an existing report
rather than creating a new version.
Next, we’ll enable report data integration for Amazon Athena, which we’ll use to
query the data in our S3 bucket.
Let’s quickly review our choices and complete the setup.
The report will take at least 24 hours to generate.
Let’s skip ahead to when it’s finished.
Now that the report is available,
let’s take a look at the S3 bucket where it was delivered.
Here’s the grafana path prefix we chose.
Let’s drill down.
This YAML file is an AWS CloudFormation template we can use to streamline the
integration between Athena and AWS Cost and Usage Reports.
Let’s download the file.
Next, we’ll navigate to CloudFormation and create a new stack.
Let’s upload the template file that we just downloaded.
Now we’ll name the stack and finish creating it.
It can take a few minutes for the stack to generate.
Now that the stack has been created, let’s take a look at its resources.
The resources created successfully.
Next, let’s navigate to Athena.
Amazon Athena is an interactive query service that makes it easy to analyze
data in Amazon S3 using standard SQL.
Here we can see the table from the report that we created earlier.
Let’s navigate to S3 and create a new bucket to store Athena’s queried results.
This bucket must be in the same AWS Region as our Cost and Usage Report.
Now that the bucket has been created, let’s return to Athena.
Next, we’ll create a new workgroup and configure it to write query results
to the bucket we just created.
We’ll choose the bucket we just made.
We’ll assign the bucket owner full control and use server-side encryption
with an S3-managed encryption key.
Let’s add a tag so that Grafana will know which workgroup is being used for the data source.
Let’s create the workgroup.
The workgroup has been created.
Let’s return to the query editor and see if we can query the report.
The query executed successfully,
which indicates that the workgroup was created successfully.
You can learn about running Athena queries from this page in the online documentation.
Now let’s go to Grafana, where we can run queries from Athena and visualize them.
Let’s create a new Grafana workspace for working with Cost and Usage Reports.
In this case, we’ll use AWS IAM Identity Center as our authentication method.
We’ll select Amazon Athena as the data source and finish creating the workspace.
Now that the workspace is created, let’s assign a user to it.
Since we’re creating a new dashboard, we need to make the user an admin.
Now we can log into this workspace.
Next, we’ll configure our Athena data source within Grafana.
We’ll select the region that our workgroup is in.
Here’s our workgroup. Let’s add it.
Let’s go to the settings to save and test this data source.
The data source is linked and working.
Back in the AWS console, let’s go to AWS Identity and Access Management
(IAM) to update the permissions of our S3 bucket so that Grafana can access it.
Let’s find our Grafana Service role.
We’ll add S3 read-only access permissions to this role.
Grafana now has permission to access our S3 bucket.
Let’s navigate back to our data source.
We’ll import the Athena Cost and Usage Report dashboard.
Let’s view the dashboard that has been generated.
We can customize this dashboard or create a new one.
Let’s create a new dashboard.
We’ll add our Athena data source.
Let’s paste in a SQL query that captures year-to-date costs for each region.
Let’s add our Cost and Usage Report as a table.
Finally, we’ll give the panel a custom name and apply the changes.
Here’s the titled panel.
To find additional Cost and Usage Analysis queries, visit the AWS Well-Architected Lab pages.
You’ve just seen how to visualize your AWS cost and usage with Amazon Managed Grafana.
You can learn more about this topic in the description and links for this video.
Thanks for watching. Now it’s your turn to try.