示例#1
0
def process(metric, datapoint):
    increment('datapointsReceived')

    for rule in RewriteRuleManager.preRules:
        metric = rule.apply(metric)

    aggregate_metrics = []

    for rule in RuleManager.rules:
        aggregate_metric = rule.get_aggregate_metric(metric)

        if aggregate_metric is None:
            continue
        else:
            aggregate_metrics.append(aggregate_metric)

        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)

    if metric not in aggregate_metrics:
        events.metricGenerated(metric, datapoint)
示例#2
0
def process(metric, datapoint):
    increment('datapointsReceived')

    for rule in RewriteRuleManager.preRules:
        metric = rule.apply(metric)

    aggregate_metrics = []

    for rule in RuleManager.rules:
        aggregate_metric = rule.get_aggregate_metric(metric)

        if aggregate_metric is None:
            continue
        else:
            aggregate_metrics.append(aggregate_metric)

        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)

    if metric not in aggregate_metrics:
        events.metricGenerated(metric, datapoint)

    if settings.LOG_AGGREGATOR_MISSES and len(aggregate_metrics) == 0:
        log.msg(
            "Couldn't match metric %s with any aggregation rule. Passing on un-aggregated."
            % metric)
示例#3
0
def process(metric, datapoint):
  increment('datapointsReceived')

  for rule in RewriteRuleManager.preRules:
    metric = rule.apply(metric)

  aggregate_metrics = []

  for rule in RuleManager.rules:
    aggregate_metric = rule.get_aggregate_metric(metric)

    if aggregate_metric is None:
      continue
    else:
      aggregate_metrics.append(aggregate_metric)

    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)

  if metric not in aggregate_metrics:
    events.metricGenerated(metric, datapoint)
示例#4
0
def process(metric, datapoint):
  increment('datapointsReceived')

  for rule in RewriteRuleManager.preRules:
    metric = rule.apply(metric)

  aggregate_metrics = []

  for rule in RuleManager.rules:
    aggregate_metric = rule.get_aggregate_metric(metric)

    if aggregate_metric is None:
      continue
    else:
      aggregate_metrics.append(aggregate_metric)

    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)

  if metric not in aggregate_metrics:
    events.metricGenerated(metric, datapoint)

  if len(aggregate_metrics) == 0:
    log.msg("Couldn't match metric %s with any aggregation rule. Passing on un-aggregated." % metric)
示例#5
0
文件: receiver.py 项目: zhpn/carbon
def process(metric, datapoint):
  increment('datapointsReceived')

  for rule in RewriteRuleManager.preRules:
    metric = rule.apply(metric)

  aggregate_metrics = []

  if settings.AGGREGATOR_RULE_METHOD == "rules":
    for rule in RuleManager.rules:
      aggregate_metric = rule.get_aggregate_metric(metric)

      if aggregate_metric is None:
        continue
      else:
        aggregate_metrics.append(aggregate_metric)

      buffer = BufferManager.get_buffer(aggregate_metric)

      if not buffer.configured:
        buffer.configure_aggregation(rule.frequency, rule.aggregation_func)

      buffer.input(datapoint)
  # Custom rule to sum metrics
  elif settings.AGGREGATOR_RULE_METHOD == "sumall":
    sum_index = metric.find(".sum.")
    metric_namespace = metric[:metric.find(".")]
    nsDict = settings["aggregation-sumall-rules"]
    if sum_index != -1:
      aggregate_metric = metric[:sum_index] + ".sum_all.hosts"
      aggregate_metrics.append(aggregate_metric)
      buffer = BufferManager.get_buffer(aggregate_metric)
      aggregate_time_interval = 60

      if metric_namespace in nsDict:
          aggregate_time_interval = int(nsDict[metric_namespace])

      if not buffer.configured:
        buffer.configure_aggregation(aggregate_time_interval, sum)

      buffer.input(datapoint)

  for rule in RewriteRuleManager.postRules:
    metric = rule.apply(metric)

  if settings['FORWARD_ALL'] and metric not in aggregate_metrics:
    #log.msg("Couldn't match metric %s with any aggregation rule. Passing on un-aggregated." % metric)
    events.metricGenerated(metric, datapoint)