def _buildMetric(self, context, dp, cf, extraRpn="", format=""): datasource = dp.datasource() dsId = datasource.id info = IInfo(dp) # find out our aggregation function agg = AGGREGATION_MAPPING.get(cf.lower(), cf.lower()) rateOptions = info.getRateOptions() tags = self._buildTagsFromContextAndMetric(context, dsId) metricname = dp.name() key = self._get_key_from_tags(tags) search = _devname_pattern.match(key) if search: metricname = metrics.ensure_prefix(context.getMetricMetadata(), metricname) name = context.getResourceKey() + "|" + dp.name() metric = dict(metric=metricname, aggregator=agg, tags=tags, rate=info.rate, name=name) combined_metric = [metric] if rateOptions: metric['rateOptions'] = rateOptions if extraRpn: metric['emit'] = 'false' metric['name'] = "{}-raw".format(dp.name()) new_metric = dict(expression="rpn:{}-raw,{}".format( dp.name(), extraRpn), format=format, name=name) combined_metric.append(new_metric) else: metric['format'] = format return combined_metric
def _buildMetric(self, context, dp, cf, extraRpn="", format=""): datasource = dp.datasource() dsId = datasource.id info = IInfo(dp) # find out our aggregation function agg = AGGREGATION_MAPPING.get(cf.lower(), cf.lower()) rateOptions = info.getRateOptions() tags = self._buildTagsFromContextAndMetric(context, dsId) metricname = dp.name() key = self._get_key_from_tags(tags) search = _devname_pattern.match(key) if search: prefix = search.groups()[0] metricname = metrics.ensure_prefix(prefix, metricname) metric = dict( metric=metricname, aggregator=agg, rpn=extraRpn, format=format, tags=tags, rate=info.rate, name=context.getResourceKey() + "|" + dp.name() ) if rateOptions: metric['rateOptions'] = rateOptions return metric
def _buildMetric(self, context, dp, cf, extraRpn="", format=""): datasource = dp.datasource() dsId = datasource.id info = IInfo(dp) # find out our aggregation function agg = AGGREGATION_MAPPING.get(cf.lower(), cf.lower()) rateOptions = info.getRateOptions() tags = self._buildTagsFromContextAndMetric(context, dsId) metricname = dp.name() key = self._get_key_from_tags(tags) search = _devname_pattern.match(key) if search: prefix = search.groups()[0] metricname = metrics.ensure_prefix(prefix, metricname) metric = dict(metric=metricname, aggregator=agg, rpn=extraRpn, format=format, tags=tags, rate=info.rate, name=context.getResourceKey() + "|" + dp.name()) if rateOptions: metric['rateOptions'] = rateOptions return metric
def _buildMetric(self, context, dp, cf, extraRpn="", format=""): datasource = dp.datasource() dsId = datasource.id info = IInfo(dp) # find out our aggregation function agg = AGGREGATION_MAPPING.get(cf.lower(), cf.lower()) rateOptions = info.getRateOptions() tags = self._buildTagsFromContextAndMetric(context, dsId) metric = dict( metric=dp.id, aggregator=agg, rpn=extraRpn, format=format, tags=tags, rate=info.rate, name=context.getUUID() + "_" + dp.id ) if rateOptions: metric['rateOptions'] = rateOptions return metric
def _buildMetric(self, context, dp, cf, extraRpn="", format=""): datasource = dp.datasource() dsId = datasource.id info = IInfo(dp) # find out our aggregation function agg = AGGREGATION_MAPPING.get(cf.lower(), cf.lower()) rateOptions = info.getRateOptions() tags = self._buildTagsFromContextAndMetric(context, dsId) metricname = dp.name() key = self._get_key_from_tags(tags) search = _devname_pattern.match(key) if search: metricname = metrics.ensure_prefix(context.getMetricMetadata(), metricname) name = context.getResourceKey() + "|" + dp.name() metric = dict( metric=metricname, aggregator=agg, tags=tags, rate=info.rate, name=name ) combined_metric = [metric] if rateOptions: metric['rateOptions'] = rateOptions if extraRpn: metric['emit'] = 'false' metric['name'] = "{}-raw".format(dp.name()) new_metric = dict( expression="rpn:{}-raw,{}".format(dp.name(), extraRpn), format=format, name=name ) combined_metric.append(new_metric) else: metric['format'] = format return combined_metric