如果有条件,boto3将无法执行

时间:2018-09-14 19:11:50

标签: python-3.x amazon-web-services boto3 amazon-cloudwatch

我正在尝试通过boto3 sdk对我的AWS帐户使用describe_alarms。

当我尝试根据条件做出反应但不起作用时,

代码:-

for i in alarm['MetricAlarms']:
  if i['MetricName] == 'Myalarm':
     print(i[AlarmName])
     print("done")

o / p:-完成,而不是关联的警报的名称

上面的代码将在响应下方进行解析

{
'MetricAlarms': [
    {
        'AlarmName': 'string',
        'AlarmArn': 'string',
        'AlarmDescription': 'string',
        'AlarmConfigurationUpdatedTimestamp': datetime(2015, 1, 1),
        'ActionsEnabled': True|False,
        'OKActions': [
            'string',
        ],
        'AlarmActions': [
            'string',
        ],
        'InsufficientDataActions': [
            'string',
        ],
        'StateValue': 'OK'|'ALARM'|'INSUFFICIENT_DATA',
        'StateReason': 'string',
        'StateReasonData': 'string',
        'StateUpdatedTimestamp': datetime(2015, 1, 1),
        'MetricName': 'string',
        'Namespace': 'string',
        'Statistic': 'SampleCount'|'Average'|'Sum'|'Minimum'|'Maximum',
        'ExtendedStatistic': 'string',
        'Dimensions': [
            {
                'Name': 'string',
                'Value': 'string'
            },
        ],
        'Period': 123,
        'Unit': 'Seconds'|'Microseconds'|'Milliseconds'|'Bytes'|'Kilobytes'|'Megabytes'|'Gigabytes'|'Terabytes'|'Bits'|'Kilobits'|'Megabits'|'Gigabits'|'Terabits'|'Percent'|'Count'|'Bytes/Second'|'Kilobytes/Second'|'Megabytes/Second'|'Gigabytes/Second'|'Terabytes/Second'|'Bits/Second'|'Kilobits/Second'|'Megabits/Second'|'Gigabits/Second'|'Terabits/Second'|'Count/Second'|'None',
        'EvaluationPeriods': 123,
        'DatapointsToAlarm': 123,
        'Threshold': 123.0,
        'ComparisonOperator': 'GreaterThanOrEqualToThreshold'|'GreaterThanThreshold'|'LessThanThreshold'|'LessThanOrEqualToThreshold',
        'TreatMissingData': 'string',
        'EvaluateLowSampleCountPercentile': 'string'
    },
],
'NextToken': 'string'

}

0 个答案:

没有答案