aws-samples / amazon-cloudwatch-auto-alarms

Automatically create and configure Amazon CloudWatch alarms for EC2 instances, RDS, and AWS Lambda using tags for standard and custom CloudWatch Metrics.
MIT No Attribution
90 stars 84 forks source link

[ERROR] CloudWatchAutoAlarms Lambda #28

Closed czantoine closed 1 year ago

czantoine commented 1 year ago

Hi ! I have this error when I test the lambda. There is the tag on the instance in the Value section that is added but it is impossible to get the CloudWatch alerts.

{ "errorMessage": "list index out of range", "errorType": "IndexError", "stackTrace": [ " File \"/var/task/cw_auto_alarms.py\", line 165, in lambda_handler\n scan_and_process_alarm_tags(create_alarm_tag, default_alarms, metric_dimensions_map, sns_topic_arn,\n", " File \"/var/task/actions.py\", line 379, in scan_and_process_alarm_tags\n process_alarm_tags(instance[\"InstanceId\"], instance, default_alarms, metric_dimensions_map,\n", " File \"/var/task/actions.py\", line 222, in process_alarm_tags\n create_alarm_from_tag(instance_id, alarm_tag, instance_info, metric_dimensions_map, sns_topic_arn, alarm_separator, alarm_identifier)\n", " File \"/var/task/actions.py\", line 167, in create_alarm_from_tag\n val = additional_dimensions[num * 2 + 1]\n" ] }

Log output :

START RequestId: 0813ee3d-98c2-48b6-97e5-838d1806a908 Version: $LATEST [INFO] 2023-01-24T16:42:36.104Z 0813ee3d-98c2-48b6-97e5-838d1806a908 event received: {'action': 'scan'} [INFO] 2023-01-24T16:42:37.100Z 0813ee3d-98c2-48b6-97e5-838d1806a908 ImageId is: ami-0cc814d99c59f3789 [INFO] 2023-01-24T16:42:37.483Z 0813ee3d-98c2-48b6-97e5-838d1806a908 Platform is: Amazon Linux [ERROR] 2023-01-24T16:42:37.484Z 0813ee3d-98c2-48b6-97e5-838d1806a908 Getting dimensions: list index out of range [ERROR] 2023-01-24T16:42:37.484Z 0813ee3d-98c2-48b6-97e5-838d1806a908 Failure describing reservations : list index out of range [ERROR] 2023-01-24T16:42:37.484Z 0813ee3d-98c2-48b6-97e5-838d1806a908 Failure creating alarm: list index out of range [ERROR] IndexError: list index out of range Traceback (most recent call last):   File "/var/task/cw_auto_alarms.py", line 165, in lambda_handler     scan_and_process_alarm_tags(create_alarm_tag, default_alarms, metric_dimensions_map, sns_topic_arn,   File "/var/task/actions.py", line 379, in scan_and_process_alarm_tags     process_alarm_tags(instance["InstanceId"], instance, default_alarms, metric_dimensions_map,   File "/var/task/actions.py", line 222, in process_alarm_tags     create_alarm_from_tag(instance_id, alarm_tag, instance_info, metric_dimensions_map, sns_topic_arn, alarm_separator, alarm_identifier)   File "/var/task/actions.py", line 167, in create_alarm_from_tag     val = additional_dimensions[num * 2 + 1]END RequestId: 0813ee3d-98c2-48b6-97e5-838d1806a908 REPORT RequestId: 0813ee3d-98c2-48b6-97e5-838d1806a908 Duration: 1420.32 ms Billed Duration: 1421 ms Memory Size: 128 MB Max Memory Used: 80 MB

Thank for you help !