View a markdown version of this page

session_lifecycle - Amazon EMR

session_lifecycle

The session_lifecycle system table contains one row for each session state change across Amazon EMR on EC2, Amazon EMR on EKS, and Amazon EMR Serverless in your account and Region. Each row records a single transition, so you can follow an interactive session through its states from creation to a terminal state. States appear exactly as the service reports them. For one aggregated row for each ended session, see sessions.

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 session_lifecycle table.

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

Columns

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

Column Type Description
session_key string Unique identifier for a single session, the same on every event belonging to that session.
session_name string Name that you gave the session when you submitted it. Null if you created the session without a name.
session_id string Identifier the platform assigned to this session.
account_id string The AWS account that owns the session.
region_name string The AWS Region where the session ran.
event_time timestamp When this lifecycle event occurred.
session_type_enum string Kind of session the row describes. Valid values are spark, spark_connect, livy, jupyter_enterprise_gateway, trino, and hive.
state_enum string The session's state exactly as the platform reports it, matching what you would see in the service console or API.
platform_enum string Compute platform that ran the session. Valid values are emr_ec2, emr_eks, and emr_serverless.
compute_id string Identifier of the compute resource that ran the session.
submitter_arn string ARN of the IAM user or role that submitted the session. Null if you created the session without a runtime role.
creation_time timestamp Time that you created the session.
start_time timestamp When the session first became available to accept work. Null when the session failed while starting.
idle_timeout_minutes long How long the session may stay idle before the platform terminates it.
is_terminal boolean True when the session has finished and no further events will be recorded for it.
state_reason_message string Readable explanation of why the session is in its current state. Null for platforms that don't report this message.
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 session_lifecycle table.

Timeline of one session's state changes

The following SQL query traces one session through its recorded state changes. Replace the following value.

  • session-key is the key of the session you want to trace.

SELECT event_time, state_enum, is_terminal, state_reason_message FROM "s3tablescatalog/aws-emr"."metadata"."session_lifecycle" WHERE event_time >= current_timestamp - INTERVAL '7' DAY AND session_key = 'session-key' ORDER BY event_time

Sessions whose latest recorded state is not terminal

The following SQL query returns sessions whose most recent recorded state isn't terminal.

WITH latest AS ( SELECT *, ROW_NUMBER() OVER ( PARTITION BY session_key ORDER BY event_time DESC, ingest_time DESC) AS rn FROM "s3tablescatalog/aws-emr"."metadata"."session_lifecycle" WHERE event_time >= current_timestamp - INTERVAL '2' DAY) SELECT platform_enum, compute_id, session_id, state_enum, event_time FROM latest WHERE rn = 1 AND NOT is_terminal

This query reflects the latest delivered transition, which can lag by the delivery delay. For live status, use the platform console or API.