为什么在AWS boto3中使用put_metric_alarm时会收到ValidationError?

时间:2018-10-22 17:12:53

标签: boto3

我正在尝试使用此代码创建警报

import boto3 as b3
session = b3.Session(profile_name = 'MyAccount')
cw = session.client('cloudwatch', region_name = 'us-east-1')
response = cw.put_metric_alarm(AlarmName = 'corefactoring-dev-bnvhf-apps_i-0840f49234febb756_disk_used_percent_rootfs',
                            ActionsEnabled= True,
                            AlarmActions= ['arn:aws:sns:us-east-1:354701104343:TopicCloudWatch-TopicForAlarms-WSVUK43NQYMP'],
                            OKActions= ['arn:aws:sns:us-east-1:354701104343:TopicCloudWatch-TopicForAlarms-WSVUK43NQYMP'],
                            InsufficientDataActions= ['notBreaching'],
                            MetricName= 'disk_used_percent',
                            Namespace= 'CWAgent',
                            Statistic='Average',
                            Dimensions=[{'Name': 'path', 'Value': '/'}, {'Name': 'InstanceId', 'Value': 'i-0840f49234febb756'}, {'Name': 'device', 'Value': 'rootfs'}, {'Name': 'fstype', 'Value': 'rootfs'}],
                            Period= 60,
                            EvaluationPeriods= 3,
                            ComparisonOperator = 'GreaterThanThreshold',
                            Threshold= 80.0
                            )
print(response)

我收到此错误

回溯(最近通话最近):   文件“ disk_alarms.py”,第49行,在     阈值= 80.0   _api_call中的文件“ /opt/venvs/awscli/lib/python3.5/site-packages/botocore/client.py”,第320行     返回self._make_api_call(operation_name,kwargs)   _make_api_call中的文件“ /opt/venvs/awscli/lib/python3.5/site-packages/botocore/client.py”,第623行     引发error_class(parsed_response,operation_name) botocore.exceptions.ClientError:调用PutMetricAlarm操作时发生错误(ValidationError):未知

有人可以告诉我怎么了吗?

0 个答案:

没有答案