Visualize Amazon WorkSpaces Utilization With Amazon QuickSight
Visualize Amazon WorkSpaces Utilization With Amazon QuickSight
Author: Brian Sheppard
Published on: 2024-12-20 21:04:17
Source: Desktop and Application Streaming
Disclaimer:All rights are owned by the respective creators. No copyright infringement is intended.
Customers often ask how they can visually gain granular insights into their Amazon WorkSpaces Personal utilization (billable hours used, running mode, bundle type, AWS Regions). Capturing and visualizing this data can provide several key benefits:
- Understand monthly billable hours for each WorkSpace to identify underutilized instances you can terminate to optimize costs.
- Determine the appropriate running mode (AlwaysOn or AutoStop) to more effectively manage costs.
- Assess the suitability of selected WorkSpace bundle types in relation to allocated resources.
- Identify usage trends and forecast future utilization to better plan and manage your WorkSpaces environment.
In this post, you will learn how to create a comprehensive utilization dashboard for your Amazon WorkSpaces environment.
Overview
The solution uses data from Cost Optimizer for Amazon WorkSpaces, which provides usage insights into your Amazon WorkSpaces environment. AWS Lambda automatically refreshes and copies this data to an Amazon Simple Storage Service (Amazon S3) bucket. You then use Amazon QuickSight to create visualizations that provide more granular visibility into key utilization metrics of your WorkSpaces environment.
Walkthrough
In this post, you complete the following tasks:
- Ensure the latest Cost Optimizer for Amazon WorkSpaces is deployed.
- Deploy the visualization solution.
- Deploy the foundational infrastructure CloudFormation template.
- Configure Amazon S3 bucket permissions in QuickSight.
- Deploy the QuickSight data components CloudFormation template.
- Configure Region mapping (optional).
- Visualize WorkSpaces utilization with QuickSight.
Prerequisites
This solution uses AWS CloudFormation to help automate most of the foundational infrastructure and QuickSight data components so you can focus on building visualizations in QuickSight.
- An AWS account with QuickSight enabled.
- SPICE capacity available in the region where this will be deployed
- Permissions needed for a user (not covered by CloudFormation roles):
- S3
s3:GetBucketLocation
: This allows the user to view the location of the S3 bucket where WorkSpaces utilization data is stored.s3:ListBucket
(if accessing the S3 bucket list or files manually).s3:GetObject
: For reading data from the bucket where the WorkSpaces data is stored.
- Lambda
lambda:InvokeFunction
: To invoke the Lambda functions manually (for example, for re-running or testing without relying on scheduled rules).
- QuickSight
quicksight:ListDataSources
: To list QuickSight data sources.quicksight:ListDataSets
: To list datasets in QuickSight.quicksight:CreateAnalysis
: To create analyses and visualizations in QuickSight.quicksight:DescribeAnalysis
: To describe and view the created analyses.
- CloudFormation
cloudformation:DescribeStacks
: To view details of the deployed CloudFormation stacks.cloudformation:ListStackResources
: To list the resources created by the CloudFormation stack.
- WorkSpaces configured in one or more AWS Regions.
- Cost Optimizer for Amazon WorkSpaces deployed.
- S3
Deployment
Step 1: Ensure the latest Cost Optimizer for Amazon WorkSpaces is deployed
The Cost Optimizer for Amazon WorkSpaces analyzes your Amazon WorkSpaces usage data. By default, it deploys in “Dry Run Mode,” which captures WorkSpaces utilization data without making any changes to your environment. For this post, you only need Dry Run Mode. If desired, you can disable Dry Run Mode to have Cost Optimizer automatically convert your WorkSpaces to the most cost-effective billing option (hourly or monthly) based on defined usage thresholds.
If you have previously deployed the Cost Optimizer for Amazon WorkSpaces solution, you should update the solution to the latest version.
The Cost Optimizer deployment takes 5-15 minutes and uses CloudFormation to automatically provision and configure the necessary AWS services. For full deployment details, see the Cost Optimizer for Amazon WorkSpaces implementation guide.
Cost Optimizer for Amazon WorkSpaces automatically runs each night at 23:00:00 UTC. An initial run is required to create the necessary WorkSpaces utilization data used by this solution. If you haven’t yet deployed Cost Optimizer or updated Cost Optimizer, wait at least one day after the initial deployment before continuing with the next steps. This ensures the first utilization data collection has completed and is available for the rest of the solution. If you would like to manually trigger a collection, you can manually trigger the workspaces-cost-optimizer-ProcessWorkspaces Lambda function.
The Cost Optimizer solution creates an S3 bucket with the format <stack name>-costoptimizerbucket-<uuid>
, where <stack-name>
is the name of your Cost Optimizer for Amazon WorkSpaces CloudFormation stack, and <uuid>
is a unique identifier. The maximum length for an S3 bucket name is 63 characters. Depending on the length of your Cost Optimizer stack name, you may see a truncated version of it.
Make note of this bucket’s name by looking for it in the S3 console or by viewing the Outputs tab for the stack in the CloudFormation console.
Step 2: Deploy the solution
This solution uses CloudFormation templates and stacks to help automate deployment. The CloudFormation template describes the AWS resources included in this solution, and the stack provisions them to the properties described in the template.
Deploy the foundational infrastructure CloudFormation template
Follow the steps in this section to configure and deploy the foundational infrastructure into your account.
- Download two templates from GitHub: 1_foundational_infrastructure.yaml and 2_quicksight_data_components.yaml.
- Sign in to the AWS Management Console and ensure you are in your desired AWS Region.
- Navigate to the CloudFormation console and create a stack using the
1_foundational_infrastructure.yaml
template. - On the Specify stack details page, enter a Stack name.
- Under Parameters, review the parameters and modify as necessary.
Parameter | Default Value | Description |
CostOptimizerBucketName | The name of the Cost Optimizer bucket created by the Cost Optimizer for Amazon WorkSpaces solution. |
-
- Choose Next.
- On the Configure stack options page, choose Next.
- On the Review and create page, review the settings and select I acknowledge that AWS CloudFormation might create IAM resources.
- Choose Submit to deploy the stack.You can view the status of the stack in the CloudFormation console in the Status column. When it finishes deploying, the stack will have a CREATE_COMPLETE status.
- Choose the Outputs Make note of the Value column for the WorkSpacesDataBucketName output. You use this as a parameter for the QuickSight Data Component CloudFormation template. The name will have the format
<stack-name>workspacesdatabucket-<uuid>
, where<stack-name>
is the name of your stack and<uuid>
is a random character sequence. As with the Cost Optimizer bucket name, you may see a truncated version of the stack name.
Configure Amazon S3 bucket permissions in QuickSight
In this step, you configure access to the WorkSpaces data bucket for QuickSight.
- Open the QuickSight console and change to the desired Region.
- Choose the profile icon in the upper right and choose Manage QuickSight.
- Make note of your Username. You will provide this as an input to the QuickSight Data Components CloudFormation template.
- On the left menu, choose Security & permissions, then choose Manage.
- Under Allow access and autodiscovery for these resources, choose Amazon S3. Select the WorkSpacesDataBucketName bucket created by the Foundational Infrastructure CloudFormation Template, then choose Finish and Save.
Deploy the QuickSight data components CloudFormation template
Follow the steps in this section to configure and deploy the QuickSight data components into your account.
- Create another CloudFormation stack using the
2_quicksight_data_components.yaml
template you downloaded previously. - On the Specify stack details page, enter a Stack name.
- Under Parameters, review the parameters and modify them as necessary:
Parameter | Default Value | Description |
QuickSightDatasetName | WorkSpaces-CostOptimizer-Dataset | The name to use for the QuickSight data set. |
QuickSightDataSourceName | WorkSpaces-CostOptimizer-DataSource | The name to use for the QuickSight data source. |
QuickSightUserName | The username of the Amazon QuickSight user who will create QuickSight content. | |
WorkSpacesDataBucketName | The name of the S3 bucket containing the WorkSpaces utilization data. |
For QuickSightUserName, enter the QuickSight username from Step 3 of “Configure Amazon S3 bucket permissions in Amazon QuickSight.”
For WorkSpacesDataBucketName, enter the name of the bucket from Step 9 of “Deploy the foundational infrastructure CloudFormation template.”
- Choose Next.
- On the Configure stack options page, choose Next.
- On the Review and create page, review the settings and select I acknowledge that AWS CloudFormation might create IAM resources.
- Choose Submit to deploy the stack. You can view the status of the stack in the AWS CloudFormation console in the Status When it finishes deploying, the stack will have a CREATE_COMPLETE status. When the stack successfully finishes, you will have a dataset with WorkSpaces utilization data, from which you can create an analysis.
- Open the QuickSight console.
- Choose Datasets from the left navigation menu and choose the dataset created by the QuickSight Data Components CloudFormation template.
- To the right of the dataset, choose the menu with three vertical dots, then choose Create analysis.
- Select the desired layout options for the Sheet and choose Create. For this example, we selected 1920px.
You now have a QuickSight analysis built from a dataset containing the Cost Optimization utilization data for your WorkSpaces environment.
Step 3: Configure AWS Region mapping (optional)
The Cost Optimizer utilization data includes the Region for each WorkSpaces directory. This appears as the ID of the directory. If you would like a more human-friendly version of this field, like “US East (Virginia),” you can create a Region mapping.
- Open the S3 console.
- Navigate to the Cost Optimizer bucket. The prefixes are organized by year, then month, then date.
- Navigate to the most recent prefix. There is a separate CSV file for each directory, in the format
<region-code>_<aws-account-id>_<directory-id>_dry-run_daily
. The Region for that directory prefixes the filename. For example, the directory starting withd-9067
(DirectoryId) is inus-east-1
(Region Code). Refer to Regions and Zones to find the Region Name for a given Region Code. For example, US East (Virginia) is the Name ofus-east-1
. - On your local computer, create a text file named
workspaces-mapping.csv
. Include the headers on the first line and create a separate line for each directory that appears in the Cost Optimizer bucket. Separate each field with a comma, as shown in the following example: - In the QuickSight console, choose Datasets from the left navigation menu, then choose the dataset created by the QuickSight Data Components CloudFormation template.
- Choose EDIT DATASET.
- Choose Add data and select Upload a file from the dropdown. Browse to the CSV file on your local computer and choose Next.
- Choose the double-red-circle Join type.
- Use the pull-down menus to select DirectoryId from the WorkSpaces table and
workspaces-mapping.csv
file. - Choose Apply.
- The Join type will now be blue and gray, indicating the join has been configured.
- Choose SAVE & PUBLISH.
Your dataset now includes a Region Mapping to map DirectoryIds to Region Names.
Step 4: Visualize WorkSpaces utilization with QuickSight
In the previous steps, you deployed a foundational infrastructure to copy utilization data from the Cost Optimizer for Amazon WorkSpaces solution. You then gave access to QuickSight to reference that infrastructure. Next, you deployed QuickSight data components and created a blank analysis.
You can now add visuals to your analysis to gain insights into your WorkSpaces utilization. Here are a few ideas to get you started:
- In the QuickSight console, choose Analyses from the left navigation menu and choose your analysis.
- Add your own visuals using the Cost Optimizer fields, or use the following examples as a guide. You can use Visualizing data in Amazon QuickSight for reference.
WorkSpaces utilization table
The following figure shows two tables displaying information about WorkSpaces in different regions. We added Conditional Formatting to automatically color Billable Hours based on threshold criteria.
The left table has a Name filter of “US West (Oregon),” while the right table has a Name filter of “US East (Virginia)”. The Visuals field list on the left shows the included fields.
WorkSpaces utilization pie charts
The following figure shows three pie charts displaying WorkSpaces counts using various fields. The left chart displays WorkSpaces count by Region Name. The center chart shows WorkSpaces count by Bundle Type. The right chart shows WorkSpaces count by Running Mode Change (this indicates how many WorkSpaces could optimize costs by changing their Running Mode).
The Visuals field list to the left of the tables shows the included fields.
WorkSpaces utilization vertical bar chart
The following figure shows a vertical bar chart. This chart displays Billable Hours by WorkSpace. We also added a reference line to display the monthly/hourly breakeven point of 83 hours to show how each WorkSpace’s utilization compares.
Publish your dashboard
- When ready, publish your analysis as a dashboard by choosing PUBLISH in the upper right.
- If publishing for the first time, choose Publish new dashboard as and provide a name. If you are updating an existing dashboard, choose Replace an existing dashboard and select your dashboard.
- Choose Publish dashboard.
You now have a published dashboard visualizing WorkSpaces utilization data. The following figure shows a sample dashboard using the previous visual examples.
Cleanup
To remove the resources discussed in this post, follow these steps:
- Open the S3 console and empty the WorkSpacesDataBucket created by the Foundational Infrastructure CloudFormation template.
- Open the CloudFormation console.
- To remove the QuickSight Data Components, select the stack and choose Delete.
- To remove the Foundational Infrastructure, select the stack and choose Delete.
- To remove Cost Optimizer for Amazon WorkSpaces, select the stack and choose Delete. If using hub and spoke accounts, also remove those stacks.
- To delete your QuickSight subscription, refer to Deleting your Amazon QuickSight subscription and closing the account.
Conclusion
In this post, you learned how to create a comprehensive dashboard to visualize utilization data for your Amazon WorkSpaces environment. Using data from Cost Optimizer for Amazon WorkSpaces and building custom visualizations with Amazon QuickSight, you now have powerful insights to help you better understand and optimize your WorkSpaces deployment.
About the authors
Brian Sheppard is a Principal Technical Account Manager based out of North Carolina. With over fifteen years of experience in enterprise infrastructure and over five years dedicated to AWS cloud computing services, Brian is committed to fostering collaborative partnerships with customers to help build optimal EUC solutions within the AWS Cloud. | |
John Tyndall was an AWS Solutions Architect based in State College, Pennsylvania. With over two decades of enterprise IT experience, he develops cloud architecture strategies to empower higher education institutions. John is passionate about enabling teaching, learning, and research through effective AWS End User Computing (EUC) solutions. |
Disclaimer: All rights are owned by the respective creators. No copyright infringement is intended.