

# 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](emr-system-table-job-lifecycle.md).

## Table location
<a name="emr-system-table-job-runs-location"></a>

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.

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

## Columns
<a name="emr-system-table-job-runs-columns"></a>

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
<a name="emr-system-table-job-runs-examples"></a>

The following examples show common queries against the `job_runs` table.

### Failed jobs in the past 24 hours, with log location
<a name="emr-system-table-job-runs-examples-failed"></a>

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

```sql
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
<a name="emr-system-table-job-runs-examples-vcpu"></a>

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

```sql
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
<a name="emr-system-table-job-runs-examples-queue"></a>

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

```sql
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
<a name="emr-system-table-job-runs-examples-submitters"></a>

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

```sql
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
```