(self, type, metric_name, metric, scraper_config, labels=None)
Takes a simple metric about a container, reports it as a rate or gauge.
        If several series are found for a given container, values are summed before submission.
Takes a simple metric about a container, reports it as a rate or gauge.
        If several series are found for a given container, values are summed before submission.
Takes a simple metric about a container reports it as a rate or gauge . If several series are found for a given container values are summed before submission .
def _process_container_metric(self, type, metric_name, metric, scraper_config, labels=None):
        """
        Takes a simple metric about a container, reports it as a rate or gauge.
        If several series are found for a given container, 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_entity_id_if_container_metric)
        for c_id, sample in iteritems(samples):
            pod_uid = self._get_pod_uid(sample[self.SAMPLE_LABELS])
            if self.pod_list_utils.is_excluded(c_id, pod_uid):
                continue

            # FIXME we are forced to do that because the Kubelet PodList isn't updated
            # for static pods, see https://github.com/kubernetes/kubernetes/pull/59948
            pod = self._get_pod_by_metric_label(sample[self.SAMPLE_LABELS])
            if pod is not None and is_static_pending_pod(pod):
                pod_tags = tagger.tag('kubernetes_pod_uid://%s' % pod["metadata"]["uid"], tagger.HIGH)
                if not pod_tags:
                    continue
                pod_tags += self._get_kube_container_name(sample[self.SAMPLE_LABELS])
                tags = list(set(pod_tags))
            else:
                tags = tagger.tag(replace_container_rt_prefix(c_id), 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]

            if "rate" == type:
                self.rate(metric_name, val, tags)
            elif "gauge" == type:
                self.gauge(metric_name, val, tags)
def _process_container_metric ( self , type , 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_entity_id_if_container_metric ) for c_id , sample in iteritems ( samples ) : pod_uid = self . _get_pod_uid ( sample [ self . SAMPLE_LABELS ] ) if self . pod_list_utils . is_excluded ( c_id , pod_uid ) : continue # FIXME we are forced to do that because the Kubelet PodList isn't updated # for static pods, see https://github.com/kubernetes/kubernetes/pull/59948 pod = self . _get_pod_by_metric_label ( sample [ self . SAMPLE_LABELS ] ) if pod is not None and is_static_pending_pod ( pod ) : pod_tags = tagger . tag ( 'kubernetes_pod_uid://%s' % pod [ "metadata" ] [ "uid" ] , tagger . HIGH ) if not pod_tags : continue pod_tags += self . _get_kube_container_name ( sample [ self . SAMPLE_LABELS ] ) tags = list ( set ( pod_tags ) ) else : tags = tagger . tag ( replace_container_rt_prefix ( c_id ) , 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 ] if "rate" == type : self . rate ( metric_name , val , tags ) elif "gauge" == type : self . gauge ( metric_name , val , tags )