(self, running_jobs, addl_tags)
Get custom metrics specified for each counter
Get custom metrics specified for each counter
Get custom metrics specified for each counter
def _mapreduce_job_counters_metrics(self, running_jobs, addl_tags):
        """
        Get custom metrics specified for each counter
        """
        for job_metrics in itervalues(running_jobs):
            job_name = job_metrics['job_name']

            # Check if the job_name exist in the custom metrics
            if self.general_counters or (job_name in self.job_specific_counters):
                job_specific_metrics = self.job_specific_counters.get(job_name)

                metrics_json = self._rest_request_to_json(
                    job_metrics['tracking_url'], 'counters', self.MAPREDUCE_SERVICE_CHECK, tags=addl_tags
                )

                if metrics_json.get('jobCounters'):
                    if metrics_json['jobCounters'].get('counterGroup'):

                        # Cycle through all the counter groups for this job
                        for counter_group in metrics_json['jobCounters']['counterGroup']:
                            group_name = counter_group.get('counterGroupName')

                            if group_name:
                                counter_metrics = set([])

                                # Add any counters in the job specific metrics
                                if job_specific_metrics and group_name in job_specific_metrics:
                                    counter_metrics = counter_metrics.union(job_specific_metrics[group_name])

                                # Add any counters in the general metrics
                                if group_name in self.general_counters:
                                    counter_metrics = counter_metrics.union(self.general_counters[group_name])

                                if counter_metrics:
                                    # Cycle through all the counters in this counter group
                                    if counter_group.get('counter'):
                                        for counter in counter_group['counter']:
                                            counter_name = counter.get('name')

                                            # Check if the counter name is in the custom metrics for this group name
                                            if counter_name and counter_name in counter_metrics:
                                                tags = [
                                                    'app_name:' + job_metrics.get('app_name'),
                                                    'user_name:' + job_metrics.get('user_name'),
                                                    'job_name:' + job_name,
                                                    'counter_name:' + str(counter_name).lower(),
                                                ]

                                                tags.extend(addl_tags)

                                                self._set_metrics_from_json(
                                                    counter, MAPREDUCE_JOB_COUNTER_METRICS, tags
                                                )
def _mapreduce_job_counters_metrics ( self , running_jobs , addl_tags ) : for job_metrics in itervalues ( running_jobs ) : job_name = job_metrics [ 'job_name' ] # Check if the job_name exist in the custom metrics if self . general_counters or ( job_name in self . job_specific_counters ) : job_specific_metrics = self . job_specific_counters . get ( job_name ) metrics_json = self . _rest_request_to_json ( job_metrics [ 'tracking_url' ] , 'counters' , self . MAPREDUCE_SERVICE_CHECK , tags = addl_tags ) if metrics_json . get ( 'jobCounters' ) : if metrics_json [ 'jobCounters' ] . get ( 'counterGroup' ) : # Cycle through all the counter groups for this job for counter_group in metrics_json [ 'jobCounters' ] [ 'counterGroup' ] : group_name = counter_group . get ( 'counterGroupName' ) if group_name : counter_metrics = set ( [ ] ) # Add any counters in the job specific metrics if job_specific_metrics and group_name in job_specific_metrics : counter_metrics = counter_metrics . union ( job_specific_metrics [ group_name ] ) # Add any counters in the general metrics if group_name in self . general_counters : counter_metrics = counter_metrics . union ( self . general_counters [ group_name ] ) if counter_metrics : # Cycle through all the counters in this counter group if counter_group . get ( 'counter' ) : for counter in counter_group [ 'counter' ] : counter_name = counter . get ( 'name' ) # Check if the counter name is in the custom metrics for this group name if counter_name and counter_name in counter_metrics : tags = [ 'app_name:' + job_metrics . get ( 'app_name' ) , 'user_name:' + job_metrics . get ( 'user_name' ) , 'job_name:' + job_name , 'counter_name:' + str ( counter_name ) . lower ( ) , ] tags . extend ( addl_tags ) self . _set_metrics_from_json ( counter , MAPREDUCE_JOB_COUNTER_METRICS , tags )