def compute_value(self): value = self.aggregation_func(self.values) timestamp = time.time() - self.aggregation_frequency datapoint = (timestamp, value) self.values = [] send_metric(self.metric_path, datapoint) increment('aggregateDatapointsSent')
def compute_value(self): now = int(time.time()) current_interval = now - (now % self.aggregation_frequency) age_threshold = current_interval - (settings["MAX_AGGREGATION_INTERVALS"] * self.aggregation_frequency) for buffer in self.interval_buffers.values(): if buffer.active: value = self.aggregation_func(buffer.values) datapoint = (buffer.interval, value) send_metric(self.metric_path, datapoint) increment("aggregateDatapointsSent") buffer.mark_inactive() if buffer.interval < age_threshold: del self.interval_buffers[buffer.interval]
def process(metric, datapoint): increment('datapointsReceived') for rule in RewriteRuleManager.preRules: metric = rule.apply(metric) for rule in RuleManager.rules: aggregate_metric = rule.get_aggregate_metric(metric) if aggregate_metric is None: continue buffer = BufferManager.get_buffer(aggregate_metric) if not buffer.configured: buffer.configure_aggregation(rule.frequency, rule.aggregation_func) buffer.input(datapoint) for rule in RewriteRuleManager.postRules: metric = rule.apply(metric) send_metric(metric, datapoint)
def aggregator_record(metric, value): fullMetric = 'carbon.aggregator.%s.%s' % (HOSTNAME, metric) datapoint = (time.time(), value) send_metric(fullMetric, datapoint)