(self, metric_name, metric, scraper_config, labels=None)
Takes a simple metric about a pod, reports it as a rate.
        If several series are found for a given pod, values are summed before submission.
Takes a simple metric about a pod, reports it as a rate.
        If several series are found for a given pod, values are summed before submission.
Takes a simple metric about a pod reports it as a rate . If several series are found for a given pod values are summed before submission .
def _process_pod_rate(self, metric_name, metric, scraper_config, labels=None):
        """
        Takes a simple metric about a pod, reports it as a rate.
        If several series are found for a given pod, values are summed before submission.
        """
        if labels is None:
            labels = []

        if metric.type not in METRIC_TYPES:
            self.log.error("Metric type %s unsupported for metric %s", metric.type, metric.name)
            return

        samples = self._sum_values_by_context(metric, self._get_pod_uid_if_pod_metric)
        for pod_uid, sample in iteritems(samples):
            pod = get_pod_by_uid(pod_uid, self.pod_list)
            namespace = pod.get('metadata', {}).get('namespace', None)
            if self.pod_list_utils.is_namespace_excluded(namespace):
                continue

            if '.network.' in metric_name and self._is_pod_host_networked(pod_uid):
                continue
            tags = tagger.tag('kubernetes_pod_uid://%s' % pod_uid, tagger.HIGH)
            if not tags:
                continue
            tags += scraper_config['custom_tags']
            for label in labels:
                value = sample[self.SAMPLE_LABELS].get(label)
                if value:
                    tags.append('%s:%s' % (label, value))
            val = sample[self.SAMPLE_VALUE]
            self.rate(metric_name, val, tags)
def _process_pod_rate ( self , metric_name , metric , scraper_config , labels = None ) : if labels is None : labels = [ ] if metric . type not in METRIC_TYPES : self . log . error ( "Metric type %s unsupported for metric %s" , metric . type , metric . name ) return samples = self . _sum_values_by_context ( metric , self . _get_pod_uid_if_pod_metric ) for pod_uid , sample in iteritems ( samples ) : pod = get_pod_by_uid ( pod_uid , self . pod_list ) namespace = pod . get ( 'metadata' , { } ) . get ( 'namespace' , None ) if self . pod_list_utils . is_namespace_excluded ( namespace ) : continue if '.network.' in metric_name and self . _is_pod_host_networked ( pod_uid ) : continue tags = tagger . tag ( 'kubernetes_pod_uid://%s' % pod_uid , tagger . HIGH ) if not tags : continue tags += scraper_config [ 'custom_tags' ] for label in labels : value = sample [ self . SAMPLE_LABELS ] . get ( label ) if value : tags . append ( '%s:%s' % ( label , value ) ) val = sample [ self . SAMPLE_VALUE ] self . rate ( metric_name , val , tags )