Skip to content
This repository has been archived by the owner on Dec 18, 2019. It is now read-only.

wildcard_alert_patterns #110

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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: 3 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ start analyzing for anomalies!
### Alerts
Skyline can alert you! In your settings.py, add any alerts you want to the ALERTS
list, according to the schema `(metric keyword, strategy, expiration seconds)` where
`strategy` is one of `smtp`, `hipchat`, or `pagerduty`. You can also add your own
alerting strategies. For every anomalous metric, Skyline will search for the given
`strategy` is one of `smtp`, `hipchat`, or `pagerduty`. Wildcards can be used in
the `metric keyword` as well. You can also add your own alerting strategies.
For every anomalous metric, Skyline will search for the given
keyword and trigger the corresponding alert(s). To prevent alert fatigue, Skyline
will only alert once every <expiration seconds> for any given metric/strategy
combination. To enable Hipchat integration, uncomment the python-simple-hipchat
Expand Down
7 changes: 6 additions & 1 deletion src/analyzer/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import operator
import socket
import settings
import re

from alerters import trigger_alert
from algorithms import run_selected_algorithm
Expand Down Expand Up @@ -191,7 +192,11 @@ def run(self):
if settings.ENABLE_ALERTS:
for alert in settings.ALERTS:
for metric in self.anomalous_metrics:
if alert[0] in metric[1]:
ALERT_MATCH_PATTERN = alert[0]
METRIC_PATTERN = metric[1]
alert_match_pattern = re.compile(ALERT_MATCH_PATTERN)
pattern_match = alert_match_pattern.match(METRIC_PATTERN)
if pattern_match:
cache_key = 'last_alert.%s.%s' % (alert[1], metric[1])
try:
last_alert = self.redis_conn.get(cache_key)
Expand Down
2 changes: 2 additions & 0 deletions src/settings.py.example
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ ENABLE_ALERTS = True
# ("metric1", "smtp", EXPIRATION_TIME),
# ("metric2", "pagerduty", EXPIRATION_TIME),
# ("metric3", "hipchat", EXPIRATION_TIME),
# Wildcard namespaces can be used as well
# ("metric4.thing.*.requests", "stmp", EXPIRATION_TIME),
# )
ALERTS = (
("skyline", "smtp", 1800),
Expand Down