AWS CloudWatch logs only showing a single STDOUT output

131 views Asked by At

I want to gather some information from my Windows EC2 instances. I pieced together from searches that I could write a powershell script and have the output directed to CloudWatch logs. So I created a script and which I launched via Run command AWS-RunPowerShellScript "Enabled CloudWatch Logs" I targeted multiple instances. However when I review the CloudWatch logs I only see the output of one instance (presumably the last one overwrites the former)

Any ideas?

Script:

$pvInfo = Get-WmiObject -Class Win32_Product | where Name -eq "AWS PV Drivers" | select Name, Version
$pvInfo | Add-Member -MemberType NoteProperty -Name "ComputerName" -Force -Value $env:COMPUTERNAME
$pvInfo

Sample Output:

I want to see a line for each server, eg..

Name           Version ComputerName   
----           ------- ------------   
AWS PV Drivers 8.4.0   SERVERX
AWS PV Drivers 8.2.0   SERVERY
AWS PV Drivers 7.4.0   SMALLSERVER
AWS PV Drivers 8.6.0   ANOTHERSERVER
AWS PV Drivers 6.4.0   EXAMPLESERVER
AWS PV Drivers 8.4.0   BIGSERVER
1

There are 1 answers

2
MisterSmith On

Based on your description, i believe CWL would create a logstream for each instance in the format CommandID/InstanceID/PluginID in the log group you specified when configuring/executing the SSM command.

Check the SSM console and look for the execution history - i suspect the command only executed successfully on 1 instance if you only see 1 stream inside the log group level of CWL.