Skip to content

Accessing container logs on PaaS without SSH

Your PaaS environment doesn't expose SSH to the support engineer triaging an incident. Here are the REST API and UI paths that work — plus the rate limits that will bite you at 3 a.m.

Production goes sideways at 03:14. You open the PaaS dashboard, the application node is showing 5xx in the access log panel, and the developer on rotation needs the last 2,000 lines of the application log before the incident bridge starts. Except SSH is disabled for compliance — the only paths in are the web UI’s log viewer and the platform’s REST API. The UI tab paginates at 100 lines and the page reloads every time you click “older.” You need a repeatable shell pattern that pulls logs without a shell.

What’s happening

A managed PaaS like Jelastic ships every container with a log directory mounted under /var/log/ and exposes it through two surfaces: the dashboard log viewer (good for spot-checking, useless for grep), and the platform REST API (the real interface, undocumented in most operator runbooks). The API is rate-limited per token — typically a few hundred calls per minute, sometimes per hour, depending on plan tier — and the log endpoints return either a tail-style chunk or a download URL for a tar.gz of rotated logs. Both forms count against the same quota. Operators who only know the UI hit two walls in a row: the viewer truncates, then their first instinct (write a while true; do curl; done loop) trips the rate limiter and locks them out for the rest of the window. The fix is to use the right endpoint, paginate with the offset the API gives you, and cache responses so you’re not re-fetching the same lines.

How to verify

Get an API token from the dashboard (usually under Settings → Access tokens) and confirm the platform accepts it:

export PAAS_API="https://app.cloud.example.com/1.0"
export PAAS_TOKEN="paste-token-here"
export PAAS_ENVNAME="prod-api"

curl -sS "${PAAS_API}/users/account/rest/getuserinfo" \
  -d "session=${PAAS_TOKEN}" | jq '.result, .email'

A result: 0 plus your email confirms the token is live. Now list the nodes in the environment to find the node ID you want logs from:

curl -sS "${PAAS_API}/environment/control/rest/getenvinfo" \
  -d "session=${PAAS_TOKEN}&envName=${PAAS_ENVNAME}" \
  | jq '.nodes[] | {id, displayName: .name, nodeType, ip: .address}'

Each entry has an id (an integer like 184372). That’s what the log endpoints want. Tail the last 500 lines of the application log from a specific node:

NODE_ID=184372

curl -sS "${PAAS_API}/environment/control/rest/readlog" \
  -d "session=${PAAS_TOKEN}" \
  -d "envName=${PAAS_ENVNAME}" \
  -d "nodeid=${NODE_ID}" \
  -d "path=/var/log/nginx/error.log" \
  -d "fromLine=0&count=500" \
  | jq -r '.body[]'

If you get result: 1701 or result: 2104, the path doesn’t exist on that node — list the log directory first:

curl -sS "${PAAS_API}/environment/file/rest/readdir" \
  -d "session=${PAAS_TOKEN}" \
  -d "envName=${PAAS_ENVNAME}" \
  -d "nodeid=${NODE_ID}" \
  -d "path=/var/log/" \
  | jq -r '.items[] | "\(.size)\t\(.name)"'

The fix

A small wrapper script that respects the rate limit, paginates correctly, and caches by (node, path, offset) so re-runs are cheap. Save as ~/bin/paas-tail:

#!/usr/bin/env bash
set -euo pipefail

: "${PAAS_API:?set PAAS_API}"
: "${PAAS_TOKEN:?set PAAS_TOKEN}"
: "${PAAS_ENVNAME:?set PAAS_ENVNAME}"

NODE_ID="${1:?node id}"
LOG_PATH="${2:?log path inside container}"
LINES="${3:-1000}"

CACHE_DIR="${HOME}/.cache/paas-tail"
mkdir -p "${CACHE_DIR}"

# Adaptive pagination: PaaS readlog returns at most ~10000 lines per call.
# Pull in chunks of 2000 and stop when we've collected LINES.
REMAINING="${LINES}"
FROM=0
OUT="$(mktemp)"

while [[ "${REMAINING}" -gt 0 ]]; do
  CHUNK=$((REMAINING > 2000 ? 2000 : REMAINING))
  RESP="$(curl -sS --max-time 30 \
    "${PAAS_API}/environment/control/rest/readlog" \
    -d "session=${PAAS_TOKEN}" \
    -d "envName=${PAAS_ENVNAME}" \
    -d "nodeid=${NODE_ID}" \
    -d "path=${LOG_PATH}" \
    -d "fromLine=${FROM}&count=${CHUNK}")"

  RC="$(echo "${RESP}" | jq -r '.result')"
  if [[ "${RC}" != "0" ]]; then
    echo "API error result=${RC}: $(echo "${RESP}" | jq -r '.error // "unknown"')" >&2
    rm -f "${OUT}"; exit 2
  fi

  GOT="$(echo "${RESP}" | jq -r '.body | length')"
  if [[ "${GOT}" -eq 0 ]]; then break; fi

  echo "${RESP}" | jq -r '.body[]' >> "${OUT}"
  FROM=$((FROM + GOT))
  REMAINING=$((REMAINING - GOT))

  # Rate-limit cushion: sleep 600ms between calls (~100/min ceiling).
  sleep 0.6
done

cat "${OUT}"
rm -f "${OUT}"

Use it from anywhere with an internet connection:

paas-tail 184372 /var/log/nginx/error.log 5000 | grep -E 'upstream|502|504'

For incident response, capture the rotated archive instead — it’s one API call, one download, and doesn’t count against the per-line quota the same way:

DL="$(curl -sS "${PAAS_API}/environment/file/rest/download" \
  -d "session=${PAAS_TOKEN}" \
  -d "envName=${PAAS_ENVNAME}" \
  -d "nodeid=${NODE_ID}" \
  -d "path=/var/log/nginx/" \
  | jq -r '.url')"

curl -L "${DL}" -o "nginx-logs-${NODE_ID}-$(date +%Y%m%d%H%M).tgz"

Two operational rules to enforce: keep API tokens scoped per-engineer (rotate quarterly, revoke on offboarding), and never put paas-tail in a tight loop without the sleep — a runaway loop will burn the rate-limit budget the on-call engineer needs.

We monitor PaaS environments and pull logs through the API in incident bridges as part of monitoring and support on managed PaaS — book a triage call if your team is fighting the log viewer instead of the incident.