Skip to content
This repository was archived by the owner on Dec 18, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/analyzer/alerters.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
def alert_smtp(alert, metric):

# For backwards compatibility
server = settings.SMTP_OPTS['server']
port = settings.SMTP_OPTS['port']

if '@' in alert[1]:
sender = settings.ALERT_SENDER
recipient = alert[1]
Expand All @@ -42,7 +45,7 @@ def alert_smtp(alert, metric):
link = settings.GRAPH_URL % (metric[1])
body = 'Anomalous value: %s <br> Next alert in: %s seconds <a href="%s"><img src="%s"/></a>' % (metric[0], alert[2], link, link)
msg.attach(MIMEText(body, 'html'))
s = SMTP('127.0.0.1')
s = SMTP(server, port)
s.sendmail(sender, recipient, msg.as_string())
s.quit()

Expand Down
2 changes: 2 additions & 0 deletions src/analyzer/analyzer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import traceback
from Queue import Empty
from redis import StrictRedis
from time import time, sleep
Expand Down Expand Up @@ -201,6 +202,7 @@ def run(self):

except Exception as e:
logger.error("couldn't send alert: %s" % e)
logger.error("stacktrace: %s" % str(traceback.format_exc()))

# Write anomalous_metrics to static webapp directory
filename = path.abspath(path.join(path.dirname(__file__), '..', settings.ANOMALY_DUMP))
Expand Down
4 changes: 4 additions & 0 deletions src/settings.py.example
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ ALERTS = (

# Each alert module requires additional information.
SMTP_OPTS = {
# The SMTP server to use
"server": "localhost",
# The SMTP port to use on the above server
"port": "25",
# This specifies the sender of email alerts.
"sender": "skyline-alerts@etsy.com",
# recipients is a dictionary mapping metric names
Expand Down