Using a workaround script to mitigate the log download error for long-running Spark jobs
For long-running Spark job runs and sessions, or any that write a large volume of
logs, the logs can be too large for Cloudera Data Engineering to load in the UI or
to download through the API or CLI. In that case, use the awc-cde-logs.py
workaround script to download the logs directly from the S3 logs bucket and turn them into
readable files on your machine. The script works for both job runs and interactive
sessions.
Cloudera Data Engineering stores the driver and executor logs of every job
run and session in S3 as many small files. Each file holds a slice of time, with
stdout and stderr mixed together.
The script:
- Downloads every log file of one job run or one session.
- Separates
stdoutfromstderr. - Merges the files into one time-ordered, plain-text
stdout.logandstderr.logfor each container: the driver and each executor.
The lines come out in the same order as in the Cloudera Data Engineering UI.
- The script. Download
awc-cde-logs.pyfrom https://github.com/cloudera/cde-public/blob/master/cde-2.0.0/scripts/awc-cde-logs.py. It is a single standalone file: save it in any directory. - Python 3.9 or later, with the
boto3package:pip install boto3If you use uv, you can skip this step:
uv run awc-cde-logs.py ...installsboto3automatically. - S3 access. Get the following from your administrator:
- The S3 endpoint URL, which must be reachable from the machine where you run the script
- An access key and secret key that can list and read the Cloudera Data Engineering logs bucket
- The name of the Cloudera Data Engineering logs bucket
- Free disk space of about the total size of the logs, plus about 30% for the
merged output. You can delete the downloaded files after the merge with
--clean-raw. - The ID of the job run or session. Find it in the Cloudera Data Engineering UI, or with the CDE CLI:
- job runs:
cde run list --job <job-name> - sessions:
cde session list
- job runs:
- Wait until the run or session has ended. Its last logs reach S3 a few minutes after it ends. If you run the script earlier, the output is incomplete.
The output goes to ./cde-logs/<id>/, relative to the directory
you run the command from, not the directory the script is saved in. To write it
somewhere else, use --out <directory>.
cde-logs/<id>/
├── logs/
│ ├── driver/<container>/stdout.log
│ ├── driver/<container>/stderr.log
│ ├── executor_1/<container>/stdout.log
│ ├── executor_1/<container>/stderr.log
│ └── ...
├── raw/ the downloaded files, in the same layout as in S3
└── manifest.json the list of downloaded files, used to order and resume
Spark's own log messages go to stderr, so the driver's
stderr.log is usually the file you need.
stdout.log contains what the application prints, for example
with print() in PySpark.
Examples
# Driver logs only, which is much faster for a run with many executors
python3 awc-cde-logs.py <run-id> --driver-only
# A session's driver logs, with a UTC timestamp on each line
python3 awc-cde-logs.py <session-id> --session --driver-only --timestamps
# Only the logs from 09:00 to 11:59 UTC on 11 November 2026
python3 awc-cde-logs.py <run-id> --from-hour 2026111109 --to-hour 2026111111
# Compressed output, and delete the downloaded files afterwards
python3 awc-cde-logs.py <run-id> --gzip --clean-raw
# Merge the already downloaded files again with different options, without downloading
python3 awc-cde-logs.py <run-id> --merge-only --timestamps
Options
| Option | Description |
|---|---|
<id> |
The job run ID. With --session, the
session ID. |
--session |
The ID is a session, not a job run. |
--bucket <name> |
The logs bucket. Overrides
CDE_LOGS_BUCKET. |
--log-location
s3://<bucket>/<prefix> |
Read the logs from this exact S3 location instead of the default one. Use it only if your administrator gives you a location. |
--out <directory> |
Where to write the output. Default:
./cde-logs. |
--driver-only |
Only the driver's logs. |
--from-hour YYYYMMDDHH |
Skip logs uploaded before this hour, in UTC. |
--to-hour YYYYMMDDHH |
Skip logs uploaded after this hour, in UTC. |
--timestamps |
Start each line with its UTC time, for example
2026-11-11T09:14:13.123456789Z. |
--join-partial |
Rejoin very long lines (over 16 KB) that were split into several pieces. Off by default, so that the output matches the Cloudera Data Engineering UI. |
--gzip |
Write .log.gz files instead of
.log. |
--clean-raw |
Delete the downloaded files after the merge succeeds. |
--download-only |
Download the files without merging them. |
--merge-only |
Merge the files already in
<out>/<id>/raw/ without
downloading. |
--parallel <n> |
Number of concurrent downloads. Default: 32. |
--workers <n> |
Number of processes that merge the files. Default: the number of CPUs. |
--addressing-style
path|virtual|auto |
The S3 URL style. Default:
path. |
--no-verify-ssl |
Do not verify the endpoint's TLS certificate. Not
recommended; set AWS_CA_BUNDLE instead. |
--from-hour and --to-hour filter by the hour a log
file was uploaded, which can be slightly later than the time of the lines in it. To
make sure you get every line near the edges of the range, widen it by one hour on
each side.
Environment variables
| Variable | Required | Description |
|---|---|---|
| AWS_ENDPOINT_URL_S3 | Yes | The S3 endpoint URL. AWS_ENDPOINT_URL
is also accepted. |
| AWS_ACCESS_KEY_ID | Yes | The access key. |
| AWS_SECRET_ACCESS_KEY | Yes | The secret key. |
| CDE_LOGS_BUCKET | Yes, unless you use --bucket or
--log-location |
The name of the Cloudera Data Engineering logs bucket. |
| AWS_SESSION_TOKEN | No | Only for temporary credentials. |
| AWS_REGION | No | The signing region. Default:
us-east-1. |
| AWS_CA_BUNDLE | No | The path to a CA certificate bundle, if the endpoint uses a certificate from a private CA. |
| Message | Cause and solution |
|---|---|
error: set AWS_ENDPOINT_URL_S3 ... or error:
set AWS_... |
A required environment variable is not set. See the Environment variables section. |
error: set --bucket, --log-location or
CDE_LOGS_BUCKET |
The logs bucket is not set. |
error: boto3 is not installed |
Run pip install boto3, or run the
script with uv run. |
error: no log objects found under
s3://... |
Check the ID and the bucket. If the ID is a session,
add --session. If the run or session ended in the
last few minutes, wait and try again. The logs may also have been
deleted under your retention policy. |
AccessDenied |
The keys cannot list or read the logs bucket. Contact your administrator. |
| SSL or certificate errors | Set AWS_CA_BUNDLE to the CA bundle of
the endpoint. |
| Errors addressing the bucket | Try --addressing-style
virtual. |
download failed: ... |
Usually a temporary network error. Run the same command again; completed files are skipped. |
warning: ... unreadable after N
record(s) |
A downloaded file is damaged. The lines before the damage are kept, and the rest of the output is not affected. |
