(self, pods, instance_tags)
Reports the number of running pods on this node and the running
        containers in pods, tagged by service and creator.

        :param pods: pod list object
        :param instance_tags: list of tags
Reports the number of running pods on this node and the running
        containers in pods, tagged by service and creator.
Reports the number of running pods on this node and the running containers in pods tagged by service and creator .
def _report_pods_running(self, pods, instance_tags):
        """
        Reports the number of running pods on this node and the running
        containers in pods, tagged by service and creator.

        :param pods: pod list object
        :param instance_tags: list of tags
        """
        pods_tag_counter = defaultdict(int)
        containers_tag_counter = defaultdict(int)
        for pod in pods.get('items', []):
            # Containers reporting
            containers = pod.get('status', {}).get('containerStatuses', [])
            has_container_running = False
            for container in containers:
                container_id = container.get('containerID')
                if not container_id:
                    self.log.debug('skipping container with no id')
                    continue
                if "running" not in container.get('state', {}):
                    continue
                has_container_running = True
                tags = tagger.tag(replace_container_rt_prefix(container_id), tagger.LOW) or None
                if not tags:
                    continue
                tags += instance_tags
                hash_tags = tuple(sorted(tags))
                containers_tag_counter[hash_tags] += 1
            # Pod reporting
            if not has_container_running:
                continue
            pod_id = pod.get('metadata', {}).get('uid')
            if not pod_id:
                self.log.debug('skipping pod with no uid')
                continue
            tags = tagger.tag('kubernetes_pod_uid://%s' % pod_id, tagger.LOW) or None
            if not tags:
                continue
            tags += instance_tags
            hash_tags = tuple(sorted(tags))
            pods_tag_counter[hash_tags] += 1
        for tags, count in iteritems(pods_tag_counter):
            self.gauge(self.NAMESPACE + '.pods.running', count, list(tags))
        for tags, count in iteritems(containers_tag_counter):
            self.gauge(self.NAMESPACE + '.containers.running', count, list(tags))
def _report_pods_running ( self , pods , instance_tags ) : pods_tag_counter = defaultdict ( int ) containers_tag_counter = defaultdict ( int ) for pod in pods . get ( 'items' , [ ] ) : # Containers reporting containers = pod . get ( 'status' , { } ) . get ( 'containerStatuses' , [ ] ) has_container_running = False for container in containers : container_id = container . get ( 'containerID' ) if not container_id : self . log . debug ( 'skipping container with no id' ) continue if "running" not in container . get ( 'state' , { } ) : continue has_container_running = True tags = tagger . tag ( replace_container_rt_prefix ( container_id ) , tagger . LOW ) or None if not tags : continue tags += instance_tags hash_tags = tuple ( sorted ( tags ) ) containers_tag_counter [ hash_tags ] += 1 # Pod reporting if not has_container_running : continue pod_id = pod . get ( 'metadata' , { } ) . get ( 'uid' ) if not pod_id : self . log . debug ( 'skipping pod with no uid' ) continue tags = tagger . tag ( 'kubernetes_pod_uid://%s' % pod_id , tagger . LOW ) or None if not tags : continue tags += instance_tags hash_tags = tuple ( sorted ( tags ) ) pods_tag_counter [ hash_tags ] += 1 for tags , count in iteritems ( pods_tag_counter ) : self . gauge ( self . NAMESPACE + '.pods.running' , count , list ( tags ) ) for tags , count in iteritems ( containers_tag_counter ) : self . gauge ( self . NAMESPACE + '.containers.running' , count , list ( tags ) )