- Newest
- Most votes
- Most comments
Yes, you can monitor private message queues (MSMQ) on Windows systems using AWS services by leveraging a combination of CloudWatch, CloudWatch Agent, and Custom Scripts. Since AWS does not natively integrate with MSMQ, you'll need to implement a custom solution to extract MSMQ queue metrics and push them to AWS for monitoring.
Solution Overview
- Extract MSMQ queue statistics using PowerShell
- Send the metrics to Amazon CloudWatch
- Set up an alarm in CloudWatch to notify when the queue depth is non-zero
Step 1: Extract MSMQ Queue Depth Using PowerShell
On your Windows server, use PowerShell to retrieve the number of messages in a private queue:
$queues = Get-MSMQQueue -Private
foreach ($queue in $queues) {
$queueName = $queue.QueueName
$messageCount = $queue.MessageCount
# Send data to CloudWatch
Write-Host "Queue: $queueName, Messages: $messageCount"
# Push to CloudWatch (via AWS CLI)
aws cloudwatch put-metric-data --namespace MSMQ --metric-name "$queueName-MessageCount" --value $messageCount -- dimensions QueueName=$queueName --region your-region
}
This script retrieves all private queues, extracts message counts, and sends them to Amazon CloudWatch.
Step 2: Automate the Script Execution
- Save the script as MonitorMSMQ.ps1 on the server.
- Create a scheduled task in Windows Task Scheduler:
Open Task Scheduler
Create a new task
Set the trigger to run the script every minute (or your preferred frequency)
Use powershell.exe -File "C:\Path\To\MonitorMSMQ.ps1"
This will ensure the script runs periodically and updates CloudWatch.
Step 3: Set Up a CloudWatch Alarm
- Go to AWS CloudWatch Console → Metrics → Custom Namespace (MSMQ).
- Find the metric with the name {QueueName}-MessageCount.
- Click on Create Alarm.
- Set the threshold condition:
Threshold type: Static
Condition: Greater than 0
Period: 1 minute (or the frequency of your script)
- Choose an SNS topic to receive notifications.
Step 4: Optional - Send Alerts to AWS SNS
If you don’t already have an SNS topic, create one:
- Go to AWS SNS Console → Create Topic.
- Add an Email or Lambda function as a subscriber.
- Configure the CloudWatch Alarm to send alerts to this SNS topic.
Alternative Approach: Using CloudWatch Agent
If you have the AWS CloudWatch Agent installed on your Windows system, you can configure it to push Performance Counter Data from MSMQ to CloudWatch. You'd need to modify the CloudWatch Agent’s config.json file to include MSMQ counters.
Example:
{
"metrics": {
"append_dimensions": {
"InstanceId": "${instance_id}"
},
"metrics_collected": {
"MSMQ": {
"metrics": [
{ "name": "Messages in Queue", "unit": "Count" }
],
"measurement": [
{ "name": "MSMQ Queue Depth", "rename": "MSMQMessageCount" }
]
}
}
}
}
Run:
Start-Service AmazonCloudWatchAgent
Summary
Best for quick implementation → Use PowerShell + AWS CLI + CloudWatch
More scalable solution → CloudWatch Agent with MSMQ metrics
Alerts & notifications → Set up CloudWatch Alarms with SNS
This solution ensures that if any MSMQ queue has messages pending (i.e., count > 0), an alarm will be triggered in AWS CloudWatch, and you will receive an alert via SNS.
answered a year ago
Relevant content
- AWS OFFICIALUpdated a year ago

Thank you so much, Fabio. We don't have AWS CLI installed in our systems for security reasons but we do have cloudwatch agent installed. I did understand the CLI procedure, but not the example you gave for updating the cloudwatch config file. Kind of hesitant to do just anything, as I have read that it is not possible to delete a custom namespace once it is created.