当我try 使用AWS Cloud CLI的PowerShell为多个实例创建Cloud Watchalert 时(如下所示)
$instanceNames = "i-000000123456789", "i-000000123456777";
foreach ($instanceName in $instanceNames) {
aws cloudwatch put-metric-alarm --alarm-name 'Major Alert > Memory Usage exceeds 90%' --alarm-description 'Major Alert > Memory Usage exceeds 90%' --actions-enabled --alarm-actions 'arn:aws:sns:us-east-1:123456789:Test_Topic' 'arn:aws:sns:us-east-1:123456777:Test_Topic' --metric-name 'Memory % Committed Bytes In Use' --namespace 'CWAgent' --statistic 'Average' --dimensions '[{"Name":"InstanceId","Value":"'$instanceName'"}]' --period 300 --evaluation-periods 1 --datapoints-to-alarm 1 --threshold 90 --comparison-operator 'GreaterThanThreshold' --treat-missing-data 'missing'
}
我收到以下错误消息:
设置字符串格式时出错:输入字符串的格式不正确. 第行:4字符:1
- AWS CloudWatch PUT-METRY-ALARM--ALARM-NAME‘重大alert &>记忆我们...
- _
设置字符串格式时出错:输入字符串的格式不正确. 第行:4字符:1
- AWS CloudWatch PUT-METRY-ALARM--ALARM-NAME‘重大alert &>记忆我们...
- _
即使在我简单地运行Cloudwatch cli命令来创建alert 时,我在解析json语法时也会遇到同样的错误. "Value":"'+$instanceName+'"个
任何关于这方面的意见都将受到高度赞赏!!