From 88fc28b609c949d6f7411c909818d3aefb6f080e Mon Sep 17 00:00:00 2001 From: Peter Salanki Date: Tue, 1 Apr 2014 00:35:32 -0400 Subject: [PATCH 1/2] Added push notification alerter via py-pushnotify. It supports sending push notifications to Android devices running Notify My Android and Pushover, and iOS devices running Pushover and Prowl. --- readme.md | 4 ++-- src/analyzer/alerters.py | 7 +++++++ src/settings.py.example | 6 ++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 8b0ad87a..1234d9a4 100644 --- a/readme.md +++ b/readme.md @@ -84,12 +84,12 @@ 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 +`strategy` is one of `smtp`, `hipchat`, `pagerduty` or `pushnotify`. 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 for any given metric/strategy combination. To enable Hipchat integration, uncomment the python-simple-hipchat -line in the requirements.txt file. +line in the requirements.txt file. To enable Pushnotify integration, uncomment the py-pushnotify line. ### How do you actually detect anomalies? An ensemble of algorithms vote. Majority rules. Batteries __kind of__ included. diff --git a/src/analyzer/alerters.py b/src/analyzer/alerters.py index edf076b0..7171dea5 100644 --- a/src/analyzer/alerters.py +++ b/src/analyzer/alerters.py @@ -47,6 +47,13 @@ def alert_smtp(alert, metric): s.quit() +def alert_pushnotify(alert, metric): + import pushnotify + client = pushnotify.get_client(settings.PUSHNOTIFY_OPTS['protocol'], application='skyline') + for x in settings.PUSHNOTIFY_OPTS['keys']: + client.add_key(x) + client.notify("%s (value: %s)" % (metric[1], metric[0]), "Anomalous metric") + def alert_pagerduty(alert, metric): import pygerduty pager = pygerduty.PagerDuty(settings.PAGERDUTY_OPTS['subdomain'], settings.PAGERDUTY_OPTS['auth_token']) diff --git a/src/settings.py.example b/src/settings.py.example index c128fe88..6511ba56 100644 --- a/src/settings.py.example +++ b/src/settings.py.example @@ -154,6 +154,12 @@ PAGERDUTY_OPTS = { "key": "your_pagerduty_service_api_key", } +# PushNotify alerts require py-pushnotify +PUSHNOTIFY_OPTS = { + # Your pagerduty subdomain and auth token + "protocol": "prowl", + "keys": ["YOUR-KEY-HERE"] +} """ Horizon settings From 5b1a3f03f67397f5574215c1a1048960e3bd4b9c Mon Sep 17 00:00:00 2001 From: Peter Salanki Date: Tue, 1 Apr 2014 00:36:00 -0400 Subject: [PATCH 2/2] Added to requirements.txt --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 82f9822f..8e062580 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,3 +6,4 @@ simplejson==2.0.9 unittest2 mock #python-simple-hipchat +#py-pushnotify