반응형
<powershell>
$UserData = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($Script))
# agent install
mkdir "c:\cwagent"
cd "c:\cwagent"
wget "https://s3.amazonaws.com/amazoncloudwatch-agent/windows/amd64/latest/amazon-cloudwatch-agent.msi" -OutFile "C:\cwagent\amazon-cloudwatch-agent.msi"
Start-Process msiexec.exe -Wait -ArgumentList '/I C:\cwagent\amazon-cloudwatch-agent.msi /quiet'
# service start
& $Env:ProgramFiles\Amazon\AmazonCloudWatchAgent\amazon-cloudwatch-agent-ctl.ps1 -m ec2 -a start
# config json file create
New-Item -Path "C:\Program Files\Amazon\AmazonCloudWatchAgent" -Name config.json -ItemType file -Value '{
"metrics": {
"namespace": "CWA_Windows_Custom",
"append_dimensions": {
"InstanceId": "${aws:InstanceId}"
},
"metrics_collected": {
"LogicalDisk": {
"measurement": [
"% Free Space"
],
"metrics_collection_interval": 60,
"resources": [
"*"
]
},
"Memory": {
"measurement": [
"Available MBytes",
"% Committed Bytes In Use"
],
"metrics_collection_interval": 60
},
"Paging File": {
"measurement": [
"% Usage"
],
"metrics_collection_interval": 60,
"resources": [
"*"
]
},
"statsd": {
"metrics_aggregation_interval": 60,
"metrics_collection_interval": 10,
"service_address": ":8125"
}
}
}
}'
# cd root
cd "C:\Program Files\Amazon\AmazonCloudWatchAgent"
# wizard run
& "C:\Program Files\Amazon\AmazonCloudWatchAgent\amazon-cloudwatch-agent-ctl.ps1" -a fetch-config -m ec2 -s -c file:"C:\Program Files\Amazon\AmazonCloudWatchAgent\config.json"
</powershell>
반응형
'[AWS] > ROG' 카테고리의 다른 글
[AWS] [활용] [Userdata 사용법] 시작 시 Windows 인스턴스에서 명령 실행 (0) | 2022.03.28 |
---|---|
[AWS] [Windows] 윈도우10 배치(bat)파일 서비스 등록하기 (0) | 2022.03.28 |
[AWS] [활용] SSM&CloudWatch 이용한 윈도 서버 모니터링 (0) | 2022.03.28 |
[AWS] CloudWatch Agent 로그 위치 (0) | 2022.03.22 |
[AWS] NLB 이해하기 (0) | 2022.03.21 |
댓글