View a markdown version of this page

job_runs - Amazon EMR

job_runs

The job_runs system table contains one aggregated row for each job attempt that reaches a terminal state, such as succeeded, failed, or cancelled. It covers Amazon EMR on EC2, Amazon EMR on EKS, and Amazon EMR Serverless in your account and Region. The table doesn't include a running job until the job ends. To follow a job through its state changes, see job_lifecycle.

Table location

You query system tables like any other tables in Amazon S3 Tables. The catalog name contains a slash and a hyphen, so you must enclose it in double quotation marks. The following SQL query uses the fully qualified name of the job_runs table.

SELECT * FROM "s3tablescatalog/aws-emr"."metadata"."job_runs" LIMIT 10

Columns

The following table describes the columns in the job_runs system table.

Column Type Description
job_key string Unique identifier for a single job, the same on every event belonging to that job.
attempt_number int Retry attempt number.
account_id string The AWS account that owns the job.
region_name string The AWS Region where the job ran.
platform_enum string Compute platform that ran the job. Valid values are emr_ec2, emr_eks, and emr_serverless.
compute_id string Identifier of the compute resource that ran the job.
compute_name string Name that you gave the compute when you created it. Null if you created the compute resource without a name.
compute_arn string ARN of the compute named in compute_id.
job_id string Identifier the platform assigned to this job.
job_name string Name that you gave the job when you submitted it. Null if you submitted the job without a name.
engine_enum string Processing engine that ran the job. Valid values are spark, hive, trino, custom_jar, and other.
release_label string The Amazon EMR release used by the compute resource. Null for clusters launched with an AMI version rather than a release label.
job_driver_type_enum string Kind of workload the job represents. Valid values are spark, pyspark, spark_submit_job, spark_sql_job, hive, hive_cli, stream, trino_session, and custom_jar.
job_driver_config_json string (JSON) How you launched the job, including its entry point or jar and main class, and the arguments and submit parameters you gave it. The configuration you submitted is in application_conf_json.
application_conf_json string (JSON) The job's submitted application configuration. Null when the job ran with the compute resource's own configuration.
monitoring_conf_json string (JSON) The job's submitted monitoring configuration. Null when monitoring was not configured for the job. Null for Amazon EMR on EC2.
submitter_arn string ARN of the IAM user or role that submitted the job. Null if you submitted the job without a runtime role.
execution_role_arn string ARN of the IAM role the job used while running. Null when the job ran with the compute resource's own permissions.
final_state_enum string The job's state exactly as the platform reports it, matching what you would see in the service console or API.
state_reason_message string Readable explanation of why the job is in its current state. Null when the platform reports no reason for the final state.
error_category string Broad category of a failure. Null when the job has not failed.
s3_log_uri string Location of the job's logs, usually an s3:// URI. Null when no Amazon S3 log location was configured.
creation_time timestamp Time that you created the job.
start_time timestamp When the job began running. Null when the job never started, including a job cancelled while queued.
end_time timestamp When the job finished, whether it succeeded, failed, or was cancelled.
queue_duration long How long the job waited before it started running, in milliseconds. On Amazon EMR Serverless this excludes provisioning time. Null on Amazon EMR on EC2 and Amazon EMR on EKS when the job never started, and on Amazon EMR Serverless when the job was never queued.
execution_duration long How long the job spent running, in milliseconds, excluding time spent waiting. Null when the job never started.
job_duration long Total time from creation to end, in milliseconds.
requested_capacity_json string (JSON) Spark capacity the job requested, projected from its submitted configuration. Null when the job isn't Spark or requested no explicit capacity.
vcpu_seconds double Allocated vCPU-seconds. Null for Amazon EMR on EC2 and Amazon EMR on EKS.
memory_gb_seconds double Allocated memory. Null for Amazon EMR on EC2 and Amazon EMR on EKS.
schema_version string Version identifier for this row's field set.
ingest_time timestamp When this row was written to the table.

Example queries

The following examples show common queries against the job_runs table.

Failed jobs in the past 24 hours, with log location

The following SQL query finds jobs that failed or were cancelled in the past 24 hours and shows where each one wrote its logs.

SELECT platform_enum, compute_id, job_id, job_name, final_state_enum, error_category, state_reason_message, s3_log_uri, end_time FROM "s3tablescatalog/aws-emr"."metadata"."job_runs" WHERE end_time >= current_timestamp - INTERVAL '1' DAY AND final_state_enum IN ('FAILED', 'CANCELLED') ORDER BY end_time DESC

Top 10 jobs by allocated vCPU-hours on Amazon EMR Serverless, past 30 days

The following SQL query lists the 10 Amazon EMR Serverless jobs that used the most allocated vCPU-hours over the past 30 days.

SELECT compute_id, job_name, COUNT(*) AS runs, SUM(vcpu_seconds) / 3600.0 AS vcpu_hours, SUM(memory_gb_seconds) / 3600.0 AS memory_gb_hours FROM "s3tablescatalog/aws-emr"."metadata"."job_runs" WHERE end_time >= current_timestamp - INTERVAL '30' DAY AND platform_enum = 'emr_serverless' GROUP BY compute_id, job_name ORDER BY vcpu_hours DESC LIMIT 10

Queue time compared with run time by cluster or application

The following SQL query compares average queue time against average run time for each cluster or application.

SELECT platform_enum, compute_id, AVG(queue_duration) / 1000.0 AS avg_queue_s, AVG(execution_duration) / 1000.0 AS avg_run_s, COUNT(*) AS runs FROM "s3tablescatalog/aws-emr"."metadata"."job_runs" WHERE end_time >= current_timestamp - INTERVAL '7' DAY GROUP BY platform_enum, compute_id ORDER BY avg_queue_s DESC

Who submitted jobs, and under which role

The following SQL query groups job runs by who submitted them and the role each one used.

SELECT submitter_arn, execution_role_arn, COUNT(*) AS runs FROM "s3tablescatalog/aws-emr"."metadata"."job_runs" WHERE end_time >= current_timestamp - INTERVAL '30' DAY GROUP BY submitter_arn, execution_role_arn ORDER BY runs DESC