標籤:
建立Web Server執行個體,配置CloudWatch來收集Web Server的系統日誌,當錯誤登入次數達到設定值時觸發警示
1. 建立Web Server
1.1 建立一個IAM策略
1.2 建立一個IAM角色
1.3 建立一個安全性群組
1.4 建立Web Server
2. 定義CloudWatch Logs閾值
2.1 確認CloudWatch Logs agent是否正在運行
2.2 建立CloudWatch Logs指標篩選器
2.3 定義一個CloudWatch警示
用錯誤的密碼嘗試登陸WebServer執行個體多次,觸發警報
3. 給EC2執行個體產生一個CloudWatch自訂指標
3.1 登陸到WebServer
3.2 配置AWS CLI
3.3 產生IIS記憶體使用量量
3.3.1 獲得當前為w3wp.exe進程記憶體使用量情況
在WebServer上的瀏覽器中訪問 http://localhost/
$memUsed = Get-WmiObject Win32_process -ComputerName $env:COMPUTERNAME | where CommandLine -Match "w3wp" | ForEach { "{0}" -f $_.VM } | Measure-Object -Sum | Select -ExpandProperty Sum$memUsed
3.3.2 獲得當前執行個體的InstanceId
$instanceId = (new-object net.webclient).DownloadString(‘http://169.254.169.254/latest/meta-data/instance-id‘)
3.3.3 建立CloudWatch自訂指標
aws cloudwatch put-metric-data --namespace HttpServerMetrics --metric-name HttpServerMemUtilization --dimension InstanceId=$instanceId --value $memUsed --unit "Kilobytes"
3.3.4 檢查CloudWatch的自訂指標
System Operations on AWS - Lab 4W - Monitoring (Windows)