Skip to content

Cloudwatchagent resulting in high CPU when using wildcard #807

@Errosion

Description

@Errosion

Describe the bug
On a Windows Server 2016 Datacenter Bastion EC2 host, we have Cloudwatch agent and Sophos installed. Upon implementing some additional log monitoring for the Sophos FIM export logs, we saw a huge spike the CWagent CPU usage. From around <5% up to a consistent 15-20% CPU time.

The CWAgent config has the below defined:

"metrics_collection_interval": 300,

, {
	"file_path": "C:\\ProgramData\\Sophos\\File Integrity Monitoring\\Export\\*.xml",
	"log_group_name": "/Sophos/FIM",
	"log_stream_name": "{instance_id}"
},

With that configured, the cloudwatch agent sits consistently at 15-20% CPU time on a t3.small instance and will go up higher when in use.
With the above set of logs removed from the config, the agent sits at <5% CPU time.

At any given time there are 670 or less files within that directory, no other subdirectories. The total size of all of the files is less than 2MB.

Steps to reproduce
Add the above config line into the config, restart the cloudwatchagent service. CPU will spike and continue to run at 15-20% when system is idle and upwards of 40-50% when other things are running.

What did you expect to see?
A much smaller increase to the overall CPU % being used by the agent.

What did you see instead?
See steps to reproduce

What version did you use?
Issue started being seen on CWAgent 1.247359.1.
Has carried over to 1.247360.0b252689.

What config did you use?
{ "agent": { "metrics_collection_interval": 300, "logfile": "c:\\ProgramData\\Amazon\\AmazonCloudWatchAgent\\Logs\\amazon-cloudwatch-agent.log" }, "metrics": { "metrics_collected": { "Memory": { "measurement": ["% Committed Bytes In Use"] }, "LogicalDisk": { "measurement": ["% Free Space"], "resources": ["*"] }, "System": { "measurement": ["*"] } }, "append_dimensions": { "ImageId": "{aws:ImageId}", "InstanceId": "{aws:InstanceId}", "InstanceType": "{aws:InstanceType}" } }, "logs": { "logs_collected": { "windows_events": { "collect_list": [{ "event_format": "xml", "event_levels": ["VERBOSE", "INFORMATION", "WARNING", "ERROR", "CRITICAL"], "event_name": "Security", "log_group_name": "Windows-Security", "log_stream_name": "{instance_id}" }, { "event_format": "xml", "event_levels": ["VERBOSE", "INFORMATION", "WARNING", "ERROR", "CRITICAL"], "event_name": "Microsoft-Windows-Windows Firewall With Advanced Security/Firewall", "log_group_name": "Windows-Firewall", "log_stream_name": "{instance_id}" }] }, "files": { "collect_list": [{ "file_path": "C:\\ProgramData\\Sophos\\Sophos Anti-Virus\\logs\\SAV.txt", "log_group_name": "/Sophos/SAV", "log_stream_name": "{instance_id}" }, { "file_path": "C:\\ProgramData\\Sophos\\Sophos Anti-Virus\\logs\\SAV-Trace.txt", "log_group_name": "/Sophos/SAV-Trace", "log_stream_name": "{instance_id}" }, { "file_path": "C:\\ProgramData\\Sophos\\Sophos Anti-Virus\\logs\\Sophos Cloud Scheduled Scan.txt", "log_group_name": "/Sophos/Sophos-Cloud-Scheduled-Scan", "log_stream_name": "{instance_id}" }, { "file_path": "C:\\ProgramData\\Sophos\\File Integrity Monitoring\\Export\\*.xml", "log_group_name": "/Sophos/FIM", "log_stream_name": "{instance_id}" }, { "file_path": "C:\\ProgramData\\Sophos\\Sophos Anti-Virus\\logs\\oaScannerWatchdog.txt", "log_group_name": "/Sophos/oaScannerWatchdog", "log_stream_name": "{instance_id}" }] } } } }

Environment
MS Windows Server 2016 Datacenter
Sophos Endpoint management
(File Integrity Monitoring 1.0.3.449)

Additional context
While I understand that there are some limitations to wildcard searches and these should be as specific as possible, the "*.xml" is the closest we can get. The filename format is:
YYYY-MM-DD_HH-MM_????_??_??_databatch.xml
Actual filenames:

2023-08-08_10-56_5021_2_2_databatch.xml
2023-07-14_13-15_4801_68_79_databatch.xml

I am not entirely certain as to what the "?" fields are but they are all digits.
Since the first five fields change at inconsistent patterns, I cannot really be more specific in the wildcard searches.

Sophos handles the rotation of these files and there is a 90 day retention policy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    os/windowsWindowsquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions