Desktop and Application Streaming
Understand end-user access to Amazon WorkSpaces with Amazon CloudWatch
Customers often ask how to gain additional insights into how their users are connecting to WorkSpaces. In addition, customers want to know environments that do not meet the required client supported version. In a previous post, to analyze access patterns in Amazon WorkSpaces, we highlighted how this can be accomplished using Amazon QuickSight. This can also be accomplished without the need to set up additional services by using CloudWatch dashboards in your WorkSpaces Region.
In this post, I show how to create CloudWatch dashboards for insight into the actions of users. Dashboard examples include:
- IP addresses connecting into WorkSpaces
- Platforms connecting into WorkSpaces
- Windows client versions connecting into WorkSpaces
- Connections by WorkSpace directory
- Table of client versions connecting to WorkSpaces
- Table of WorkSpaces launched
- Table of WorkSpaces removed
- Table of WorkSpaces rebuilt
- Table of WorkSpaces modified
Walkthrough
Time to read | 20 minutes |
Time to complete | 30 minutes |
Cost to complete | Detailed cost information on CloudWatch can be found at: Amazon CloudWatch Pricing – Amazon Web Services (AWS) |
Learning level | 300 |
Services used |
Prerequisites:
- AWS CloudTrail enabled, and with CloudWatch logs enabled
Step 1: Log WorkSpaces events
Set up WorkSpace events being stored to a log group, which is used by the dashboards.
- Open the CloudWatch console
- Select the AWS Region your WorkSpaces are hosted in
- In the navigation pane, choose Events->Rules. This will redirect to Amazon EventBridge
- Choose Create rule.
- For Event Source, do the following:
- Choose Event Pattern
- For Build event pattern to match events by service, set
- Service Name: WorkSpaces
- Event Type: WorkSpaces Access
- For Targets, select Add target, and then choose CloudWatch log group
- For the /aws/events value, enter WorkSpacesAccessLogs
- Select Configure details.
- For Rule definition, enter a name and description.
- Select Create rule.
Step 2 Create dashboard to show IP addresses connecting to WorkSpaces
In this step, you create a dashboard showing the IP addresses of clients connecting into WorkSpaces.
- Open the CloudWatch console
- Select Dashboards from the Navigation menu. Select Create dashboard
- For the dashboard name, enter WorkSpacesInformation.
- For the widget type, select Pie.
- Select Logs for the data source.
- For Log Groups, select the log group created in Step 1 (WorkSpacesAccessLogs)
- Enter the following for the query:
stats count() by detail.clientIpAddress | fields @timestamp, @message | filter source = "aws.workspaces" | fields detail.clientIpAddress
- Select Create widget
- Rename the widget to IP Addresses connecting into WorkSpaces
- Select Save
Step 3: Create a widget to show platforms connecting into WorkSpaces
In this step, you create a dashboard to showing the end-user platforms that are connecting into WorkSpaces.
- Open the CloudWatch console for your WorkSpaces Region
- Select Dashboards from the Navigation menu, and select WorkSpacesInformation
- Select Add widget.
- For the widget type, select Pie.
- Select Logs for the data source.
- For Log Groups, select the group that was created in Step 1 (WorkSpacesAccessLogs)
- Enter the following for the query:
stats count() by detail.clientPlatform | fields @timestamp, @message | filter source = "aws.workspaces" | fields detail.clientPlatform
- Select Create widget
- Rename the widget to Platforms Connecting
- Select Save
Step 4: Create a widget for Windows Client Versions connecting into WorkSpaces
In this step, you build a dashboard showing the client versions for a specific client platform (for example Windows) that are connecting into WorkSpaces.
- Open the CloudWatch console for your WorkSpaces Region
- Select Dashboards from the Navigation menu, and select WorkSpacesInformation
- Click Add widget.
- For the Widget Type select Pie, and select Logs for the data source
- For Log Groups, select the group that was created in Step 1 (WorkSpacesAccessLogs)
- Enter the following for the query:
statscount() by detail.clientVersion | fields @timestamp, @message | filter source = "aws.workspaces" | filter detail.clientPlatform = "Windows" | fields detail.clientVersion
- For other platforms, replace the detail.clientPlatform additional options are:
| filterdetail.clientPlatform = "OSX"
| filter detail.clientPlatform = "iOS"
| filter detail.clientPlatform = "Android"
| filter detail.clientPlatform = "Linux"
| filter detail.clientPlatform = "Web"
- Select Create widget
- Rename the widget to Client Versions – Windows. Replace Windows with the client platform that you selected in part 7 of this step.
- Select Save
Step 5: Create a widget for connections by WorkSpace directory
In this step, you create a dashboard to visualize users connecting by directory.
- Open the CloudWatch console for your WorkSpaces Region
- Select Dashboards from the Navigation menu, and select WorkSpacesInformation
- Select Add widget.
- For the widget type, select Bar
- Select Logs for the data source.
- For Log Groups, select the group that was created in Step 1 (WorkSpacesAccessLogs)
- Enter the following for the query:
statscount() by detail.directoryId | fields @timestamp, @message | filter source = "aws.workspaces" | fields detail.directoryId
- Select Create widget
- Rename the widget to Connections by Directory Service.
- Select Save
Step 6: Create a detailed table of client versions connections to WorkSpaces
This step gives a log of client versions connected to WorkSpaces.
- Open the CloudWatch console for your WorkSpaces Region
- Select Dashboards from the Navigation menu, and select WorkSpacesInformation
- Select Add widget.
- For the widget type select Logs table, and select Logs for the data source.
- For Log Groups, select the group that was created in Step 1 (WorkSpacesAccessLogs)
- Enter the following for the query:
fields@timestamp, @message | fields account | fields region, detail.clientPlatform, detail.clientVersion, detail.workspaceId |display region, detail.clientPlatform, detail.clientVersion, detail.workspaceId
- Select Create widget
- Rename the widget to WorkSpaces client version.
- Select Save
Step 7: Create a table of WorkSpaces Launched
This step gives a log of WorkSpaces launched.
- Open the CloudWatch console for your WorkSpaces Region
- Select Dashboards from the Navigation menu, and select WorkSpacesInformation
- Select Add widget.
- For the widget type select Logs table, and select Logs for the data source
- For Log Groups, select the log group for CloudTrail in your WorkSpace Region.
- Enter the following for the query:
fields@timestamp, @message | filter eventName = "CreateWorkspaces" | fields awsRegion, responseElements.pendingRequests.0.userName, responseElements.pendingRequests.0.workspaceId |display awsRegion, responseElements.pendingRequests.0.userName, responseElements.pendingRequests.0.workspaceId
- Select Create widget
- Rename the widget to WorkSpaces Launched.
- Select Save
Step 8: Create a table of WorkSpaces removed
In this step, you create a table with a list of WorkSpaces that have been removed.
- Open the CloudWatch console for your WorkSpaces Region
- Select Dashboards from the Navigation menu, and select WorkSpacesInformation
- Select Add widget.
- For the widget type select Logs table, and select Logs for the data source
- For Log Groups, select the log group for CloudTrail in your WorkSpace Region.
- Enter the following for the query:
fields@timestamp, @message |filter eventName = "TerminateWorkspaces" |fields awsRegion, requestParameters.terminateWorkspaceRequests.0.workspaceId |display awsRegion, requestParameters.terminateWorkspaceRequests.0.workspaceId
- Select Create widget
- Rename the widget to WorkSpaces Removed.
- Select Save
Step 9: Create a widget showing rebuilt WorkSpaces
In this step, you create a dashboard widget to show summary information on rebuilds of WorkSpaces.
- Open the CloudWatch console for your WorkSpaces Region
- Select Dashboards from the Navigation menu, and select WorkSpacesInformation
- Select Add widget.
- For the widget type select Logs table, and select Logs for the data source
- For Log Groups, select the log group for CloudTrail in your WorkSpace Region.
- Enter the following for the query:
fields@timestamp, @message |filter eventName = "RebuildWorkspaces" |fields awsRegion, requestParameters.rebuildWorkspaceRequests.0.workspaceId |display awsRegion, requestParameters.rebuildWorkspaceRequests.0.workspaceId
- Select Create widget
- Rename the widget to WorkSpaces Rebuild.
- Select Save
Step 10: Create a widget showing modified WorkSpaces
In this step, you create a dashboard widget to show detail information on modified WorkSpaces.
- Open the CloudWatch console for your WorkSpaces Region
- Select Dashboards from the Navigation menu, and select WorkSpacesInformation
- Select Add widget.
- For the widget type select Logs table, and select Logs for the data source
- For Log Groups, select the log group for CloudTrail in your WorkSpace Region.
- For Log Groups, select the CloudTrail log group. Enter the following for the query:
fields@timestamp, @message |filter eventName = "ModifyWorkspaceProperties" |fields awsRegion, requestParameters.workspaceId, requestParameters.workspaceProperties.computeTypeName, requestParameters.workspaceProperties.runningMode, requestParameters.workspaceProperties.userVolumeSizeGib |display awsRegion, requestParameters.workspaceId, requestParameters.workspaceProperties.computeTypeName, requestParameters.workspaceProperties.runningMode, requestParameters.workspaceProperties.userVolumeSizeGib
- Select Create widget
- Rename the widget to WorkSpaces modified.
- Select Save
Conclusion
In this post, you created widgets to provide insight into how WorkSpaces are accessed. The widgets also give insight to changes that are made to the WorkSpaces in a Region. This can be further enhanced to get the client versions connecting from an IP address (location), or performing automation tasks on rebuild WorkSpaces. Dashboards can be customized to drill down into additional detail. For example, providing insights on when WorkSpaces are being used, the platform and also the client version. When creating CloudWatch Logs, by default, logs are kept indefinitely and never expire. You can adjust the retention policy for each log group. You can keep the indefinite retention, or choose a retention period between 10 years and one day. For more information on CloudWatch Logs, review the guide on Amazon CloudWatch Logs. For more information on CloudWatch dashboards, review the guide on using Amazon CloudWatch dashboards.