Last active
July 20, 2018 18:52
-
-
Save gswallow/057fe5ad240f875051c34ac38e42a1a2 to your computer and use it in GitHub Desktop.
Install the AWS Cloudwatch agent on Windows.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
aws ssm put-parameter --name AmazonCloudWatch-windows --type String --overwrite --value "$(cat cw-windows.json)" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"logs": { | |
"logs_collected": { | |
"windows_events": { | |
"collect_list": [ | |
{ | |
"event_format": "text", | |
"event_levels": [ | |
"WARNING", | |
"ERROR", | |
"CRITICAL" | |
], | |
"event_name": "System", | |
"log_group_name": "/aws/ec2/windows/System" | |
}, | |
{ | |
"event_format": "text", | |
"event_levels": [ | |
"WARNING", | |
"ERROR", | |
"CRITICAL" | |
], | |
"event_name": "Application", | |
"log_group_name": "/aws/ec2/windows/Application" | |
} | |
] | |
} | |
} | |
}, | |
"metrics": { | |
"append_dimensions": { | |
"AutoScalingGroupName": "${aws:AutoScalingGroupName}", | |
"ImageId": "${aws:ImageId}", | |
"InstanceId": "${aws:InstanceId}", | |
"InstanceType": "${aws:InstanceType}" | |
}, | |
"metrics_collected": { | |
"LogicalDisk": { | |
"measurement": [ | |
"% Free Space" | |
], | |
"metrics_collection_interval": 10, | |
"resources": [ | |
"*" | |
] | |
}, | |
"Memory": { | |
"measurement": [ | |
"% Committed Bytes In Use" | |
], | |
"metrics_collection_interval": 10 | |
}, | |
"Paging File": { | |
"measurement": [ | |
"% Usage" | |
], | |
"metrics_collection_interval": 10, | |
"resources": [ | |
"*" | |
] | |
}, | |
"PhysicalDisk": { | |
"measurement": [ | |
"% Disk Time", | |
"Disk Write Bytes/sec", | |
"Disk Read Bytes/sec", | |
"Disk Writes/sec", | |
"Disk Reads/sec" | |
], | |
"metrics_collection_interval": 10, | |
"resources": [ | |
"*" | |
] | |
}, | |
"Processor": { | |
"measurement": [ | |
"% User Time", | |
"% Idle Time", | |
"% Interrupt Time" | |
], | |
"metrics_collection_interval": 10, | |
"resources": [ | |
"*" | |
] | |
}, | |
"TCPv4": { | |
"measurement": [ | |
"Connections Established" | |
], | |
"metrics_collection_interval": 10 | |
}, | |
"TCPv6": { | |
"measurement": [ | |
"Connections Established" | |
], | |
"metrics_collection_interval": 10 | |
} | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<powershell> | |
$url = "https://s3.amazonaws.com/amazoncloudwatch-agent/windows/amd64/latest/AmazonCloudWatchAgent.zip" | |
$output = $env:TEMP + "\AmazonCloudWatchAgent.zip" | |
$wc = New-Object System.Net.WebClient | |
$wc.DownloadFile($url, $output) | |
Expand-Archive -path $output -destinationpath $env:TEMP | |
cd $env:TEMP | |
./install.ps1 | |
./amazon-cloudwatch-agent-ctl.ps1 -a fetch-config -m ec2 -c ssm:AmazonCloudWatch-windows -s | |
</powershell> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You also need an IAM role with some managed AWS policies attached to it:
https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/create-iam-roles-for-cloudwatch-agent.html