How do I push custom logs from a text file to Cloudwatch logs?

Hi there,

I am trying to push some puppet logs to cloudwatch logs from a Windows 2016 Ec2 instance. The puppet logs are stored in a text file in c:\logs\ directory. I have made following changes to the cloudwatch agent configuration file (showing only the important bits below) -

{
“IsEnabled”: true,
“EngineConfiguration”: {
“Components”: [
.
.
.
.
{
“Id”: “CustomLogs”,
“FullName”: “AWS.EC2.Windows.CloudWatch.CustomLog.CustomLogInputComponent,AWS.EC2.Windows.CloudWatch”,
“Parameters”: {
“LogDirectoryPath”: “C:\logs”,
“TimestampFormat”: “yyyy-MM-dd HH:mm:ss”,
“Encoding”: “UTF-8”,
“Filter”: “”,
“CultureName”: “en-US”,
“TimeZoneKind”: “Local”,
“LineCount”: “5”
}
},
{
“FullName”: “AWS.EC2.Windows.CloudWatch.CloudWatchLogsOutput,AWS.EC2.Windows.CloudWatch”,
“Id”: “CloudWatchLogs4”,
“Parameters”: {
“AccessKey”: “”,
“LogGroup”: “/my-app/puppet”,
“LogStream”: “{instance_id}”,
“Region”: “eu-west-1”,
“SecretKey”: “”
}
},
.
.
.
.
“Flows”: {
“Flows”: [
“CustomLogs, CloudWatchLogs4”
]
},
“PollInterval”: “00:00:30”
}
}

However it doesnt seem to work. I have tried restarting the SSM agent using the following command:

Restart-Service AmazonSSMAgent

But its not pushing the logs.

The cloudwatch agent is installed and running fine as its able to push the other windows related logs to cloudwatch. Its just this custom log from a text file which its not able to push.

Am I doing something wrong?

Thanks

You’ll want the Cloudwatch Agent and config that points the agent to the file to send: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/install-CloudWatch-Agent-commandline-fleet.html

I have cloudwatch agent installed on the instance. And its able to push the other windows system logs, Its just these custom logs which its not able to push.

I think you need to modify the configuration of the agent to pick up these files? https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Agent-Configuration-File-Details.html#CloudWatch-Agent-Configuration-File-Logssection