Articles

Which deployment caused this HTTP 500? Trace it by request ID

Use a failed request ID to find its exact deployment and runtime log on Gregale, even after a newer revision goes live.

Updated

Start with the request ID, not the latest deployment. A 500 may have come from a revision that no longer serves traffic. On Gregale, look up that exact request in HTTP logs, read the deployment and instance it records, and then search that instance's runtime logs for the same request.

1. Capture the failed request

For a failing request you can reproduce safely, save its response headers. Use the public X-Faas-Request-Id from that response. You do not need to capture the payload, cookies, or an Authorization header to identify it.

bash
curl -sS -D headers.txt -o /dev/null "$APP_URL/demo/report"
awk 'tolower($1)=="x-faas-request-id:" {gsub(/\r/,"",$2);print $2}' headers.txt

Record the app, approximate UTC time and route alongside that ID. Don't rerun a request that charges a card or writes production data just to get a new ID. Use the original response or your client's existing logs.

2. Identify the deployment that served it

bash
gregale --json logs "$APP" --source http --request "$REQUEST_ID"

Request events can take about a minute to appear, so retry if the row is missing. Confirm the returned row has the request ID, method, route and status you expect. Use its deployment_id, not the ID of the release currently on the app. If there is no matching row, double-check the app, retained time window and your plan's log access. An empty or unavailable result does not tell you which release served the request.

The HTTP row proves what the platform observed. It doesn't always tell you why the request failed. An error at the edge or during startup may not have run a handler. For an application error, find the structured log line from the exact instance that served it.

The row's instance_id names that instance, and its timestamp gives the UTC day. Once a newer release has replaced the deployment, the old instance has stopped and its lines are in the log archive, readable within about five minutes of it stopping:

bash
gregale --json logs "$APP" --archive --instance "$INSTANCE_ID" --date "$UTC_DAY" | grep "$REQUEST_ID"

Each archived line carries its deployment_id, so check that it matches $DEPLOYMENT_ID. This works when the app logs that ID alongside the error. The starter reads the gateway's forwarded request ID and logs only the ID, revision and a synthetic error marker. Don't log sensitive request content, and don't infer a root cause if an app line is missing.

Run the two-release drill

Download the stateless Python starter. You need Bash, curl, jq, OpenSSL and the Gregale CLI, logged in with gregale login to an isolated workspace on Hobby or above, where HTTP request events are available. Then run:

bash
bash run-demo.sh

The script uses one public, disposable app with synthetic responses. It captures an app-owned 500 from v1, deploys v2 and verifies that v2 serves the stable URL. Only then does it look up the original request ID. The proof is a 500 event tied to v1 and a matching runtime line, not another 500 from the latest deployment. The script removes the verified test app on exit. It doesn't create a database or need an external observability account. The last step can take a few minutes while v1's lines reach the archive.

We ran the starter against a disposable Gregale app with CLI v0.1.18-rc.390 on December 4, 2026. After v2 took all traffic, the old request ID returned v1's deployment, the 500 status and the route, and v1's archived lines held the matching synthetic_report_failure line. The script then deleted the app and confirmed it was gone.

For related workflows, see reading logs, request and trace propagation, and verifying which version is running in production.

Questions

How do I find the logs for one HTTP request?

Capture its X-Faas-Request-Id response header and look it up in Gregale HTTP logs with --request. Confirm the route and status before using the resulting deployment ID.

Can I look up an error after deploying a new version?

Yes, while the old request is retained. The request row points to the deployment that handled it, which may differ from the one currently serving.

Does an HTTP 500 automatically have an application log?

No. The request may have failed before entering the app, or the app may not have logged the request ID. Use the HTTP row as evidence and avoid inventing an application cause.