我正在尝试禁用特定警报的警报操作,但是我无法一次全部禁用。
使用此代码,我可以获得具有特定模式(apache)的所有警报的列表,但是我无法通过[disable_alarm_actions] [1]禁用所有这些警报。.
使用此代码,我得到了所需的输出:
names = [[alarm['AlarmName'] for alarm in response['MetricAlarms']]]
disable_response = client.disable_alarm_actions(names)
['Alarm-HHAADDD-MAJORCPUAlarm-01010101', 'Alarm-HHAADDD-MAJORMemoryAlarm-SFCJ00NF8K5Y', 'Alarm-HHAADDD-server-i-00cd64e2d815a96b5-DiskSpaceUtilization', 'Alarm-HHAADDD-server-i-00cd64e2d815a96b5-DiskSpaceUtilization_volume', 'Alarm-01010101-MAJORCPUAlarmELSMasters-01010101', 'Alarm-01010101-MAJORCPUAlarmELSNodes-HHAADDD', 'Alarm-01010101-MAJORMemoryAlarmELSMasters-KCOAV57MFCI4', 'Alarm-01010101-MAJORMemoryAlarmELSNodes-GUVOV6TSI259', 'Alarm-01010101-data-i-01010101-DiskSpaceUtilization_root', 'Alarm-01010101-data-i-01010101-DiskSpaceUtilization_volume', 'Alarm-01010101-data-i-01010101-DiskSpaceUtilization_root', 'Alarm-01010101-data-i-01010101-DiskSpaceUtilization_volume', 'Alarm-01010101-master-i-01010101-DiskSpaceUtilization_root', 'Alarm-01010101-master-i-01010101-DiskSpaceUtilization_volume']
现在我正在尝试这段代码,但出现错误:
disable_response = client.disable_alarm_actions(names)
"%s() only accepts keyword arguments." % py_operation_name)
TypeError: disable_alarm_actions() only accepts keyword arguments.
答案 0 :(得分:1)
only accepts keyword arguments
错误表明,您需要命名所有输入内容,而不仅仅是依赖位置。
尝试:
disable_response = client.disable_alarm_actions(AlarmNames=names)