def get_pattern(self): """ Returns a compiled regexp pattern that represents the target metrics of this rule. """ series = extract_series_name(self.target) pat = translate_serieslist_to_regex(series) return pat
def get_pattern(self): """ Returns a compiled regexp pattern that represents the target metrics of this rule. """ series = extract_series_name(self.target) pat = translate_serieslist_to_regex(series) return pat
def get_values(self): """ Retrieves actual values from Graphite based on the evaluators target. """ start = "-{0}".format(interval_to_graphite(self.period)) averages = get_metric_average( self.target, start=start, end='now', ignore_unknown=True) _logger.debug("retrieved %d values from graphite for %r, " "period %s: %r", len(averages), self.target, self.period, averages) self.result = dict((extract_series_name(key), dict(value=value)) for key, value in iteritems(averages)) return self.result
def test_extract_series_name(series, expected): assert extract_series_name(series) == expected