Skip to content

Commit

Permalink
fix alert Redis derivative graphs
Browse files Browse the repository at this point in the history
IssueID #2168: Strange Redis derivative graph
IssueID #2034: analyse_derivatives

- Stop nonNegativeDerivative being applied twice

Modified:
skyline/analyzer/alerters.py
skyline/mirage/mirage_alerters.py
  • Loading branch information
earthgecko committed Sep 20, 2017
1 parent c1dd805 commit f24c52d
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 10 deletions.
28 changes: 23 additions & 5 deletions skyline/analyzer/alerters.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,10 @@ def alert_smtp(alert, metric, context):
# @modified 20161229 - Feature #1830: Ionosphere alerts
# Only write the data to the file if it does not exist and replace
# the timeseries object if a json file exists

# @added 20170920 - Bug #2168: Strange Redis derivative graph
using_original_redis_json = False

if not os.path.isfile(json_file):
timeseries_json = str(timeseries).replace('[', '(').replace(']', ')')
try:
Expand All @@ -347,6 +351,9 @@ def alert_smtp(alert, metric, context):
logger.info('%s Redis timeseries replaced with timeseries from :: %s' % (skyline_app, anomaly_json))
timeseries_x = [float(item[0]) for item in timeseries]
timeseries_y = [item[1] for item in timeseries]
# @added 20170920 - Bug #2168: Strange Redis derivative graph
# This already has nonNegativeDerivative applied to it
using_original_redis_json = True
except:
logger.error(traceback.format_exc())
logger.error(
Expand All @@ -355,11 +362,22 @@ def alert_smtp(alert, metric, context):

# @added 20170603 - Feature #2034: analyse_derivatives
if known_derivative_metric:
try:
derivative_timeseries = nonNegativeDerivative(timeseries)
timeseries = derivative_timeseries
except:
logger.error('error :: alert_smtp - nonNegativeDerivative failed')

# @added 20170920 - Bug #2168: Strange Redis derivative graph
# If this is the Mirage Redis json it already has
# nonNegativeDerivative applied to it
if not using_original_redis_json:
logger.info('alert_smtp - nonNegativeDerivative being applied')

try:
derivative_timeseries = nonNegativeDerivative(timeseries)
timeseries = derivative_timeseries
# @added 20170920 - Bug #2168: Strange Redis derivative graph
logger.info('alert_smtp - nonNegativeDerivative applied')
except:
logger.error('error :: alert_smtp - nonNegativeDerivative failed')
else:
logger.info('alert_smtp - nonNegativeDerivative not being applied, as it will have been applied in the original json')

# @added 21070726 - Bug #2068: Analyzer smtp alert error on Redis plot with derivative metrics
# If the nonNegativeDerivative has been calculated we need to reset the
Expand Down
28 changes: 23 additions & 5 deletions skyline/mirage/mirage_alerters.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,10 @@ def alert_smtp(alert, metric, second_order_resolution_seconds, context):
# @modified 20161229 - Feature #1830: Ionosphere alerts
# Only write the data to the file if it does not exist and replace
# the timeseries object if a json file exists

# @added 20170920 - Bug #2168: Strange Redis derivative graph
using_original_redis_json = False

if not os.path.isfile(json_file):
timeseries_json = str(timeseries).replace('[', '(').replace(']', ')')
try:
Expand All @@ -350,6 +354,9 @@ def alert_smtp(alert, metric, second_order_resolution_seconds, context):
logger.info('%s Redis timeseries replaced with timeseries from :: %s' % (skyline_app, anomaly_json))
timeseries_x = [float(item[0]) for item in timeseries]
timeseries_y = [item[1] for item in timeseries]
# @added 20170920 - Bug #2168: Strange Redis derivative graph
# This already has nonNegativeDerivative applied to it
using_original_redis_json = True
except:
logger.error(traceback.format_exc())
logger.error(
Expand All @@ -359,11 +366,22 @@ def alert_smtp(alert, metric, second_order_resolution_seconds, context):
# @added 20170823 - Feature #2034: analyse_derivatives
# Originally patterned and added to analyzer/alerters.py on 20170603
if known_derivative_metric:
try:
derivative_timeseries = nonNegativeDerivative(timeseries)
timeseries = derivative_timeseries
except:
logger.error('error :: alert_smtp - nonNegativeDerivative failed')

# @added 20170920 - Bug #2168: Strange Redis derivative graph
# If this is the Mirage Redis json it already has
# nonNegativeDerivative applied to it
if not using_original_redis_json:
logger.info('alert_smtp - nonNegativeDerivative being applied')

try:
derivative_timeseries = nonNegativeDerivative(timeseries)
timeseries = derivative_timeseries
# @added 20170920 - Bug #2168: Strange Redis derivative graph
logger.info('alert_smtp - nonNegativeDerivative applied')
except:
logger.error('error :: alert_smtp - nonNegativeDerivative failed')
else:
logger.info('alert_smtp - nonNegativeDerivative not being applied, as it will have been applied in the original json')

# @added 21070823 - Bug #2068: Analyzer smtp alert error on Redis plot with derivative metrics
# Originally patterned and added to analyzer/alerters.py on 20170726
Expand Down

0 comments on commit f24c52d

Please sign in to comment.