diff --git a/lemur/notifications/messaging.py b/lemur/notifications/messaging.py index 1fce7636..3dd4fff7 100644 --- a/lemur/notifications/messaging.py +++ b/lemur/notifications/messaging.py @@ -111,7 +111,7 @@ def send_plugin_notification(event_type, data, recipients, notification): notification.plugin.send(event_type, data, recipients, notification.options) status = SUCCESS_METRIC_STATUS except Exception as e: - log_data["message"] = f"Unable to send expiration notification to recipients {recipients}" + log_data["message"] = f"Unable to send {event_type} notification to recipients {recipients}" current_app.logger.error(log_data, exc_info=True) sentry.captureException() diff --git a/lemur/plugins/lemur_aws/plugin.py b/lemur/plugins/lemur_aws/plugin.py index a0b72d94..8a54b035 100644 --- a/lemur/plugins/lemur_aws/plugin.py +++ b/lemur/plugins/lemur_aws/plugin.py @@ -454,7 +454,4 @@ class SNSNotificationPlugin(ExpirationNotificationPlugin): f"{self.get_option('topicName', options)}" current_app.logger.debug(f"Publishing {notification_type} notification to topic {topic_arn}") - try: - sns.publish(topic_arn, message, notification_type, region_name=self.get_option("region", options)) - except Exception: - current_app.logger.exception(f"Error publishing {notification_type} notification to topic {topic_arn}") + sns.publish(topic_arn, message, notification_type, region_name=self.get_option("region", options)) diff --git a/lemur/plugins/lemur_aws/sns.py b/lemur/plugins/lemur_aws/sns.py index 3aeb14da..f9fd4a07 100644 --- a/lemur/plugins/lemur_aws/sns.py +++ b/lemur/plugins/lemur_aws/sns.py @@ -29,7 +29,8 @@ def publish_single(sns_client, topic_arn, certificate, notification_type): response_code = response["ResponseMetadata"]["HTTPStatusCode"] if response_code != 200: - raise Exception(f"Failed to publish notification to SNS, response code was {response_code}") + raise Exception(f"Failed to publish {notification_type} notification to SNS topic {topic_arn}. " + f"SNS response: {response_code} {response}") current_app.logger.debug(f"AWS SNS message published to topic [{topic_arn}]: [{response}]") diff --git a/lemur/plugins/lemur_slack/plugin.py b/lemur/plugins/lemur_slack/plugin.py index ba2baf40..70d97aa5 100644 --- a/lemur/plugins/lemur_slack/plugin.py +++ b/lemur/plugins/lemur_slack/plugin.py @@ -127,7 +127,7 @@ class SlackNotificationPlugin(ExpirationNotificationPlugin): raise Exception("Unable to create message attachments") body = { - "text": "Lemur {0} Notification".format(notification_type.capitalize()), + "text": f"Lemur {notification_type.capitalize()} Notification", "attachments": attachments, "channel": self.get_option("recipients", options), "username": self.get_option("username", options), @@ -136,8 +136,8 @@ class SlackNotificationPlugin(ExpirationNotificationPlugin): r = requests.post(self.get_option("webhook", options), json.dumps(body)) if r.status_code not in [200]: - raise Exception("Failed to send message") + raise Exception(f"Failed to send message. Slack response: {r.status_code} {body}") current_app.logger.info( - "Slack response: {0} Message Body: {1}".format(r.status_code, body) + f"Slack response: {r.status_code} Message Body: {body}" )