AWS Builder Center

Proactive Monitoring for Amazon WorkSpaces Personal

Monitor an entire Amazon WorkSpaces Personal fleet with six directory-level CloudWatch alarms, at a fixed cost for any fleet size, and get an email listing the affected WorkSpaces when an alarm fires.

Amazon WorkSpaces Personal publishes health, connection, disk usage, and network metrics to Amazon CloudWatch. Turning those metrics into timely alerts is where many teams struggle. One alarm per WorkSpace works for a handful of desktops, but the alarm count and cost grow with the fleet, and every new or deleted WorkSpace needs an alarm created or removed. Custom scripts that poll the WorkSpaces API avoid that, but you have to build and run them. A CloudWatch Metrics Insights query alarm removes that bookkeeping, but its cost still scales with fleet size.
In this article, I show you how to monitor an entire WorkSpaces fleet with just six CloudWatch alarms by using the  DirectoryId  dimension. Because the alarms are scoped to the directory, their cost is fixed and low for a fleet of any size. The trade-off is that a directory-level alarm identifies the directory, not the affected WorkSpace, so this solution adds an email that lists the affected WorkSpaces whenever an alarm fires.
Approach
How it works
Trade-off
Per-WorkSpace alarms
One alarm for each WorkSpace, using the  WorkspaceId  dimension
Alarm count and cost grow with the fleet, and every new or deleted WorkSpace needs an alarm created or removed
Custom API polling
A scheduled function calls  DescribeWorkspaces  (and  GetMetricData  for connection, disk, and network metrics) and alerts on what it finds
Identifies the affected WorkSpaces, but you build and maintain the code, detection waits for the next poll, and large fleets need many API calls on every run, even when nothing is wrong
Metrics Insights query alarm
One alarm with a query that tracks every WorkSpace
No per-WorkSpace management, but the cost scales with the number of WorkSpaces
Directory-level alarms (this solution)
One alarm per signal, using the  DirectoryId  dimension
Fixed, low cost for any fleet size. The alarm identifies the directory, so this solution adds an email that lists the affected WorkSpaces
The alarms notify administrators when WorkSpaces are unhealthy, when a significant share of user connections fail, when a WorkSpace is running out of disk space, or when latency or packet loss is high across the directory's sessions. When several WorkSpaces are affected at once, the signals point to a shared cause, such as a directory, network, or image issue, or an operating system problem after patching. Your team can start troubleshooting before users notice or contact the help desk, instead of reacting to a wave of tickets.
The AWS CloudFormation template is available in the  sample-workspaces-proactive-monitoring  GitHub repository.

Solution overview

The CloudFormation stack creates up to six CloudWatch alarms for one WorkSpaces directory. All of them use metrics that WorkSpaces already publishes under the  DirectoryId  dimension, and all of them publish to one Amazon Simple Notification Service (Amazon SNS) topic.
  1. Unhealthy WorkSpaces: Alarms when N or more WorkSpaces in the directory are unhealthy.
  1. Connection failure rate (optional): Alarms when the percentage of failed connection attempts across the directory reaches a threshold.
  1. Root volume disk usage (optional): Alarms when any WorkSpace's root volume is above a disk usage threshold.
  1. User volume disk usage (optional): Alarms when any WorkSpace's user volume is above the same threshold.
  1. In-session latency (optional): Alarms when the average round-trip time across the directory's sessions reaches a threshold.
  1. UDP packet loss (optional): Alarms when the average UDP packet loss across the directory's sessions reaches a threshold.
When any alarm enters the  ALARM  state, an Amazon EventBridge rule invokes an optional AWS Lambda function. The function looks up the affected WorkSpaces and sends a second email to the same topic that lists them. A separate alarm notifies the topic if the function fails.

ProactiveWorkSpacesMonitoring architecture


How the alarms work

Unhealthy WorkSpaces

Each WorkSpace publishes its own  Unhealthy  datapoint ( 0  or  1 ) every five minutes under the  DirectoryId  dimension, so the  Sum  over a 300-second period is the number of unhealthy WorkSpaces in the directory. Stopped AutoStop WorkSpaces report  0 , so they don't trigger the alarm.
 UnhealthyThreshold  sets how many WorkSpaces must be unhealthy. The default of  1  notifies you as soon as any WorkSpace is unhealthy; raise it to alert only on problems that affect several users.  EvaluationPeriods  sets how many consecutive five-minute periods the threshold must be met (1–12, default  1 ).
CloudWatch notifies you only when an alarm changes state. If more WorkSpaces become unhealthy while the alarm is already in the  ALARM  state, no further notification is sent until it returns to  OK  and fires again.

Connection failure rate

This alarm uses a metric math expression over the directory's  ConnectionAttempt  and  ConnectionFailure  sums for each five-minute period:
IF(FILL(attempts, 0) >= ConnectionMinAttempts,
100 * FILL(failures, 0) / FILL(attempts, 0), 0)
 FILL  turns periods with no data into zeros, so a quiet period breaks a run of breaching periods instead of being skipped. The  IF  reports  0  when there are fewer than  ConnectionMinAttempts  attempts (default  5 ), because one failure out of two attempts is a 50% rate but not a meaningful signal. By default, the alarm fires when 20% or more of attempts fail for  EvaluationPeriods  consecutive periods. Periods with no attempts, such as outside working hours, keep the alarm in the  OK  state.

Disk usage

Every running WorkSpace publishes  RootVolumeDiskUsage  and  UserVolumeDiskUsage  under the  DirectoryId  dimension, so the  Maximum  over a 300-second period is the highest usage of any WorkSpace in the directory. Each volume has its own alarm, so the notification shows which volume is filling up.
By default, each alarm fires when any WorkSpace's volume is above 90% ( DiskUsageThreshold , 1–99) for one five-minute period.
These alarms fire on a single WorkSpace, because disk space is usually a per-user problem. Stopped WorkSpaces don't publish disk metrics, so a full volume on an AutoStop WorkSpace triggers the alarm again when the WorkSpace next runs.

Latency and packet loss

These alarms use the  Average  of  InSessionLatency  and  UDPPacketLossRate  under the  DirectoryId  dimension, which averages every session in the directory over each five-minute period. They fire on network problems that affect many users at once, such as a VPN, proxy, or ISP issue, not on one user's home network.
IF(FILL(connected, 0) >= NetworkMinConnected, FILL(latency, 0), 0)
 connected  is the directory's  UserConnected  sum, which is the number of WorkSpaces with a user connected. The  IF  reports  0  until at least  NetworkMinConnected  WorkSpaces (default  10 ) have a user connected, so a few sessions can't set the average. Lower it for small directories. The packet loss alarm uses the same expression.
By default, the latency alarm fires at an average of 250 ms or more ( LatencyThreshold ) and the packet loss alarm at 5% or more ( PacketLossThreshold ), for three consecutive five-minute periods ( NetworkEvaluationPeriods , 1–12). Normal latency depends on how far your users are from the Region, so set  LatencyThreshold  above your fleet's usual average. Only sessions that stream over UDP publish  UDPPacketLossRate . Both metrics are published only during sessions, so periods with no sessions keep the alarms in the  OK  state.

The alarm details email

A single Lambda function handles all six alarms. It reads the alarm name from the EventBridge event, runs the matching check, and publishes the result to the topic.
Alarm
What the email lists
Unhealthy
WorkSpaces in the  UNHEALTHY  or  IMPAIRED  state
Connection failure rate
WorkSpaces with connection failures in the last 30 minutes, or in the alarm's evaluation window (5 minutes ×  EvaluationPeriods ) if that is longer, with their failure and attempt counts
Root or user volume disk usage
Running WorkSpaces whose latest usage (last 15 minutes) is above  DiskUsageThreshold , highest first
In-session latency or UDP packet loss
WorkSpaces whose average in the last 15 minutes, or in the alarm's evaluation window (5 minutes ×  NetworkEvaluationPeriods ) if that is longer, is at or above the threshold, highest first
Each affected WorkSpace is listed on one line with its WorkSpace ID and user name. The following example shows the email for the unhealthy alarm.
Alarm: WorkSpaces-d-xxxxxxxxxx-Unhealthy
Directory: d-xxxxxxxxxx

Unhealthy or impaired WorkSpaces: 3
ws-xxxxxxxx1 user=jdoe state=UNHEALTHY
ws-xxxxxxxx2 user=asmith state=UNHEALTHY
ws-xxxxxxxx3 user=mgarcia state=IMPAIRED
The following example shows the email for the user volume disk usage alarm.
Alarm: WorkSpaces-d-xxxxxxxxxx-UserVolumeDiskUsage
Directory: d-xxxxxxxxxx

WorkSpaces with user volume usage above 90%: 1
ws-xxxxxxxxx user=jdoe user volume=99.2%
The alarm's own notification is sent independently, so operators still receive it if the function fails. A separate alarm,  WorkSpaces-<DirectoryId>-AlarmDetailsErrors , notifies the topic when a run fails, and the log group  /workspaces/<StackName>/alarm-details  shows the cause. The logs contain WorkSpace IDs, but not user names.

How to deploy

The steps below use the AWS Command Line Interface (AWS CLI), but you can also deploy the stack through the AWS CloudFormation console by uploading the template and entering the parameters.
  1. Download   workspaces-personal-monitoring.yaml   from the GitHub repository (choose Download raw file), or download it from the command line.
PowerShell:
Invoke-WebRequest -Uri https://raw.githubusercontent.com/aws-samples/sample-workspaces-proactive-monitoring/main/workspaces-personal-monitoring.yaml -OutFile workspaces-personal-monitoring.yaml
macOS, Linux, or AWS CloudShell:
curl -O https://raw.githubusercontent.com/aws-samples/sample-workspaces-proactive-monitoring/main/workspaces-personal-monitoring.yaml
  1. Deploy the CloudFormation stack. Replace  REGION  with the Region of your WorkSpaces directory, and replace the directory ID and email address with your own values.
PowerShell:
aws cloudformation deploy `
--region REGION `
--stack-name WorkSpacesAlarms-d-xxxxxxxxxx `
--template-file workspaces-personal-monitoring.yaml `
--capabilities CAPABILITY_IAM `
--parameter-overrides `
DirectoryId=d-xxxxxxxxxx `
NotificationEmail=workspaces-alerts@example.com
macOS, Linux, or AWS CloudShell:
aws cloudformation deploy \
--region REGION \
--stack-name WorkSpacesAlarms-d-xxxxxxxxxx \
--template-file workspaces-personal-monitoring.yaml \
--capabilities CAPABILITY_IAM \
--parameter-overrides \
DirectoryId=d-xxxxxxxxxx \
NotificationEmail=workspaces-alerts@example.com
 CAPABILITY_IAM  is required because the alarm details function has an AWS Identity and Access Management (IAM) role.
  1. Confirm the SNS subscription email you receive. Notifications are not delivered until you choose Confirm subscription.
To monitor more directories, deploy one stack per directory.

Stack parameters

Parameter
Required
Default
Description
 DirectoryId 
Yes
None
WorkSpaces directory to monitor
 NotificationEmail 
No
blank
Email address to subscribe to the topic
 AlarmName 
No
 WorkSpaces-<DirectoryId>-Unhealthy 
Name of the unhealthy alarm
 UnhealthyThreshold 
No
 1 
Number of unhealthy WorkSpaces required to alarm
 EvaluationPeriods 
No
 1 
Consecutive five-minute periods for the unhealthy and connection failure alarms (1–12)
 EnableConnectionFailureAlarm 
No
 true 
Create the connection failure rate alarm
 ConnectionFailureRateThreshold 
No
 20 
Failure rate, in percent, required to alarm
 ConnectionMinAttempts 
No
 5 
Minimum connection attempts per period before the rate is evaluated
 EnableDiskUsageAlarms 
No
 true 
Create the root and user volume disk usage alarms
 DiskUsageThreshold 
No
 90 
Volume usage, in percent, above which the disk alarms fire (1–99)
 DiskEvaluationPeriods 
No
 1 
Consecutive five-minute periods for the disk usage alarms (1–12)
 EnableNetworkAlarms 
No
 true 
Create the in-session latency and UDP packet loss alarms
 LatencyThreshold 
No
 250 
Average in-session latency, in milliseconds, required to alarm
 PacketLossThreshold 
No
 5 
Average UDP packet loss, in percent, required to alarm
 NetworkMinConnected 
No
 10 
Minimum WorkSpaces with a user connected before the network alarms are evaluated
 NetworkEvaluationPeriods 
No
 3 
Consecutive five-minute periods for the network alarms (1–12)
 ExistingTopicArn 
No
auto-created
Existing SNS topic to notify; leave blank to create one
 TopicName 
No
generated
Name for a newly created topic
 TopicKmsKeyArn 
No
blank
Customer managed AWS KMS key that encrypts the topic
 NotifyOnOk 
No
 false 
Also notify when an alarm returns to  OK 
 EnableAlarmDetails 
No
 true 
Email the affected WorkSpaces when an alarm fires
To change a value, add it to  --parameter-overrides  and run the deploy command again. For example,  UnhealthyThreshold=3 EvaluationPeriods=2  alarms only when three or more WorkSpaces are unhealthy for two consecutive periods.

Notification options

By default, the stack creates a new SNS topic for the alarms and subscribes the  NotificationEmail  address to it. You don't need to change anything to use this option.
Using an existing topic
If you already have an SNS topic that your team monitors, you can send the notifications there instead:
  1. Make sure that the topic's access policy allows  cloudwatch.amazonaws.com  to publish. The stack doesn't change an existing topic's policy.
  1. Check the topic's subscribers. The alarm details function publishes plain text, not alarm JSON. If the topic has subscribers that parse alarm JSON, such as Lambda functions, Amazon SQS queues, or chat integrations, also set  EnableAlarmDetails=false .
  1. Add  ExistingTopicArn  to  --parameter-overrides  in the deploy command, for example  ExistingTopicArn=arn:aws:sns:REGION:111122223333:MyTopic .  NotificationEmail  is optional; if you set it, the stack adds that email subscription to the existing topic.
Encrypt the topic
To encrypt notifications with a customer managed AWS Key Management Service (AWS KMS) key, whether the stack creates the topic or you use an existing one:
  1. Add the following statement to the key policy before you deploy. The stack can't change the key policy.
{
"Sid": "AllowCloudWatchAlarmsToPublish",
"Effect": "Allow",
"Principal": { "Service": "cloudwatch.amazonaws.com" },
"Action": ["kms:Decrypt", "kms:GenerateDataKey*"],
"Resource": "*"
}
  1. Add  TopicKmsKeyArn  to  --parameter-overrides . For a new topic, the stack encrypts the topic with this key. For an existing topic, use the key that the topic already uses.
The AWS managed key ( alias/aws/sns ) is not supported, because CloudWatch alarms can't publish to topics encrypted with it. The stack grants the alarm details function access to the key through IAM; if your key policy doesn't delegate access to IAM, also allow the function's role in the key policy.
Deploy the alarms only
To deploy only the alarms and the topic, with no Lambda or IAM resources, set  EnableAlarmDetails=false . You won't receive the email that lists the affected WorkSpaces, and you can omit  --capabilities CAPABILITY_IAM  from the deploy command.

Testing the notifications

New alarms start in the  INSUFFICIENT_DATA  state and move to  OK  within about 15 minutes. To test the notifications, force the unhealthy alarm into the  ALARM  state.
PowerShell:
aws cloudwatch set-alarm-state `
--region REGION `
--alarm-name WorkSpaces-d-xxxxxxxxxx-Unhealthy `
--state-value ALARM `
--state-reason "Manual notification test"
macOS, Linux, or AWS CloudShell:
aws cloudwatch set-alarm-state \
--region REGION \
--alarm-name WorkSpaces-d-xxxxxxxxxx-Unhealthy \
--state-value ALARM \
--state-reason "Manual notification test"
You receive two emails, the alarm notification and the alarm details email. The alarm returns to  OK  at its next evaluation, and the test doesn't affect any WorkSpace.

Considerations

  • Notifications are sent on state change only. If more WorkSpaces become affected while an alarm is already in the  ALARM  state, no new notification is sent. Check the CloudWatch console for the current state, or set  NotifyOnOk=true  so you know when an incident ends.
  • One stack per directory, in the directory's Region. Each directory needs its own stack, with its own alarms and costs. Deploy the stack in the Region where the directory is registered; alarms in another Region don't see its metrics.
  •  EvaluationPeriods  is shared. It applies to both the unhealthy and connection failure rate alarms. The disk alarms use  DiskEvaluationPeriods , and the latency and packet loss alarms use  NetworkEvaluationPeriods .
  • Disk usage on stopped WorkSpaces isn't monitored. A stopped AutoStop WorkSpace doesn't publish disk metrics, so a full volume is detected only when the WorkSpace next runs.
  • Only the alarm details function identifies the affected WorkSpaces. If you set  EnableAlarmDetails=false , the alarms identify the directory only.

Pricing

The following estimate uses on-demand prices for Europe (Ireland) in October 2026. Prices vary by Region and change over time.
The alarms are the only fixed cost, and they don't depend on the number of WorkSpaces. CloudWatch bills $0.10 per alarm metric per month, and the connection failure rate, latency, and packet loss alarms each use two metrics.
Alarm
Alarm metrics
Monthly cost
Unhealthy WorkSpaces
1
$0.10
Connection failure rate
2
$0.20
Root volume disk usage
1
$0.10
User volume disk usage
1
$0.10
In-session latency
2
$0.20
UDP packet loss
2
$0.20
Alarm details function errors
1
$0.10
Total per directory
10
$1.00
The alarm details function adds about $0.01–$0.02 per alarm event for every 1,000 WorkSpaces in the directory, from its  GetMetricData  calls. The Lambda, Amazon SNS, and CloudWatch Logs costs are negligible.
The CloudWatch Free Tier includes 10 alarm metrics per account, and the  AWS/WorkSpaces  metrics are published at no charge.


Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article