(self, running_apps, addl_tags)
Get metrics for each Spark job.
Get metrics for each Spark job.
Get metrics for each Spark job .
def _spark_job_metrics(self, running_apps, addl_tags):
        """
        Get metrics for each Spark job.
        """
        for app_id, (app_name, tracking_url) in iteritems(running_apps):

            base_url = self._get_request_url(tracking_url)
            response = self._rest_request_to_json(
                base_url, SPARK_APPS_PATH, SPARK_SERVICE_CHECK, addl_tags, app_id, 'jobs'
            )

            for job in response:

                status = job.get('status')

                tags = ['app_name:%s' % str(app_name)]
                tags.extend(addl_tags)
                tags.append('status:%s' % str(status).lower())

                job_id = job.get('jobId')
                if job_id is not None:
                    tags.append('job_id:{}'.format(job_id))

                for stage_id in job.get('stageIds', []):
                    tags.append('stage_id:{}'.format(stage_id))

                self._set_metrics_from_json(tags, job, SPARK_JOB_METRICS)
                self._set_metric('spark.job.count', COUNT, 1, tags)
def _spark_job_metrics ( self , running_apps , addl_tags ) : for app_id , ( app_name , tracking_url ) in iteritems ( running_apps ) : base_url = self . _get_request_url ( tracking_url ) response = self . _rest_request_to_json ( base_url , SPARK_APPS_PATH , SPARK_SERVICE_CHECK , addl_tags , app_id , 'jobs' ) for job in response : status = job . get ( 'status' ) tags = [ 'app_name:%s' % str ( app_name ) ] tags . extend ( addl_tags ) tags . append ( 'status:%s' % str ( status ) . lower ( ) ) job_id = job . get ( 'jobId' ) if job_id is not None : tags . append ( 'job_id:{}' . format ( job_id ) ) for stage_id in job . get ( 'stageIds' , [ ] ) : tags . append ( 'stage_id:{}' . format ( stage_id ) ) self . _set_metrics_from_json ( tags , job , SPARK_JOB_METRICS ) self . _set_metric ( 'spark.job.count' , COUNT , 1 , tags )