Skip to content

Commit

Permalink
Sentry integration
Browse files Browse the repository at this point in the history
  • Loading branch information
deric committed May 26, 2018
1 parent 7c0a8d4 commit 0a3d62f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions elastalert/elastalert.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import logging
import os
import signal
import socket
import sys
import time
import timeit
Expand Down Expand Up @@ -48,6 +49,9 @@
from util import ts_now
from util import ts_to_dt
from util import unix_to_dt
from raven import Client
from raven.conf import setup_logging
from raven.handlers.logging import SentryHandler


class ElastAlerter():
Expand Down Expand Up @@ -127,6 +131,16 @@ def __init__(self, args):
tracer.setLevel(logging.INFO)
tracer.addHandler(logging.FileHandler(self.args.es_debug_trace))

if os.environ.get('SENTRY_DSN') is not None:
sentry = Client(
dsn=os.getenv('SENTRY_DSN'),
name=os.environ.get('HOST', socket.getfqdn())
)
handler = SentryHandler(sentry)
handler.setLevel(logging.WARNING)
setup_logging(handler)
elastalert_logger.info("Configured errors reporting to Sentry: %s" % os.getenv('SENTRY_DSN'))

self.conf = load_rules(self.args)
self.max_query_size = self.conf['max_query_size']
self.scroll_keepalive = self.conf['scroll_keepalive']
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ pytest<3.3.0
setuptools
sphinx_rtd_theme
tox<2.0
raven>=6.4.0
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ PyStaticConfiguration>=0.10.3
python-dateutil>=2.6.0,<2.7.0
PyYAML>=3.12
requests>=2.0.0
raven>=6.4.0
stomp.py>=4.1.17
texttable>=0.8.8
twilio==6.0.0

0 comments on commit 0a3d62f

Please sign in to comment.