Skip to content

M5-S2 — Logs, traces, errors and retention

Section titled “M5-S2 — Logs, traces, errors and retention”
ModuleM5 — Observe
After this session you canReconstruct what happened to one request from its trace id, set up error reporting with its blind spots in mind, and plan for the logs and audit records the platform keeps.
TimeFacilitated: 31 min · On your own: 31 min
Before you startM5-S1. From M3-S2: the gateway’s error envelope and its traceId. From ACSA: monitoring and the audit trail.
Go deeperObservability: structured logging & correlation · Logs, audit & retention

◆ Orientation (1 min) — One id, every service

Section titled “◆ Orientation (1 min) — One id, every service”

A user reports that an approval email never arrived, and sends you the trace id from the error message. The request touched the gateway, the data pod, the bus, the workflow application and the notification worker: five places, five logs. This session shows how one id ties them together, what Sentry adds, and what the platform keeps for later questions.

▤ Concept (6 min) — Logs, the correlation id, Sentry and what is kept

Section titled “▤ Concept (6 min) — Logs, the correlation id, Sentry and what is kept”

Every service logs JSON, one object per line, because the chart runs them in production mode. Each line carries service, env, timestamp, level and msg, and, inside a request or a message handler, the correlationId, the userId and the spaceId. The level for the whole release is global.log.level (error, warn, info or debug); changing it rolls every pod that reads the shared configuration, so raise it to debug only for a short investigation. The logger removes fields named like secrets (password, token, authorization, secret, key and similar) before writing.

The correlation id: the only trace you get

Section titled “The correlation id: the only trace you get”

There is no distributed-tracing system with spans and waterfalls. Instead, one id travels everywhere:

flowchart LR
  C["Caller<br/>(may send x-correlation-id)"] --> G["Gateway:<br/>keeps it or creates one"]
  G --> D["data:<br/>logs it"]
  D -->|"message carries it"| B["Bus"]
  B --> W["workflow:<br/>logs it"]
  B --> N["notification worker:<br/>logs it"]

What to notice: the id crosses the bus inside each message, so asynchronous work done minutes later in another service still carries the same id as the original request.

The gateway stamps x-correlation-id on every request, keeping one the caller sent. It is the traceId in every gateway error (M3-S2). Work with no id, such as a request that bypassed the gateway, logs NO-TRACE-ID and cannot be followed: ask integrators to send their own id so that you can find their requests.

In production you search all logs at once in your log platform (Loki, Elasticsearch or similar). In the lab, kubectl logs with the release’s label does the same job.

When you give the release a Sentry project, unhandled errors are reported there with their correlation id:

ValuePurpose
sentry.backendDSN, sentry.webDSNWhere the services and the web portal report; unset means no reporting
sentry.environmentThe environment name Sentry groups by, for example northwind-prod
sentry.traceSampleRateShare of transactions traced; the chart’s default is "0.1" (10 %)

Choose the sample rate deliberately: 10 % of every transaction is a lot of Sentry volume for a busy tenant. And know the blind spots: the audit application and the scheduler log some failures without raising them, on purpose, so those failures never reach Sentry. Watch their logs, the scheduler’s failed-job metric and the dead-letter queues instead.

RecordWho reads itHow long it is kept
The audit trail (who changed what)The administrator, in MonitoringA single-tenant release never purges it
Email, text-message and WhatsApp logsThe administrator, in MonitoringA single-tenant release never purges them
Automation run historyThe administratorA single-tenant release never purges it
System logs and entry historyThe administratorNever purged
Sign-in and second-factor audit recordsThe identity serverRemoved automatically after 180 and 90 days
Pod logsYouAs long as your log platform keeps them; a pod’s own log is lost when it is replaced

Multi-tenant deployments purge the first three daily, per tenant, from each tenant’s plan limits. A single-tenant release grows these collections for ever: plan the MongoDB storage for it, and if Northwind’s policy requires a limit, agree it with the administrator and apply it at the database level. The audit trail is also evidence: never delete it without that agreement.

⛏ Lab (18 min) — Follow one change through the platform

Section titled “⛏ Lab (18 min) — Follow one change through the platform”

Goal. One change you make in the portal, followed by its correlation id through the gateway, the data pod and at least one service that received it over the bus.

Before you start. The release healthy, you signed in as nwoperator in a browser with its developer tools available (F12).

  1. In the portal, open Administration › Organization › Users and open Drill Marker. Open the browser’s developer tools on the Network tab.

  2. Change Drill Marker’s last name to Marker-Traced and save.

  3. In the Network tab, select the request that saved the change (a PATCH or PUT to the API), and copy the x-correlation-id header from its response headers.

  4. Search every pod of the release for it:

    Terminal window
    ID=<paste the id>
    kubectl -n northwind logs -l app.kubernetes.io/instance=nw --all-containers --prefix \
    --since=10m --max-log-requests=20 | grep "$ID"
  5. Sort what you found: which pods logged the id, and which of those lines came from handling a bus message rather than the HTTP request? (The prefix names the pod; the message text says which.)

  6. Pick one JSON line and read its fields: service, level, correlationId, userId, spaceId.

  7. Note in inventory.md the release’s current Sentry settings: helm get values nw -n northwind -a | grep -A5 "^sentry:".

  8. Write two lines for Northwind’s operations handbook: what you need from a user to investigate a failure, and how long sign-in audit records are kept.

Check.

  • You have the correlation id of your own change.
  • It appears in the gateway’s log and in the core-data pod’s log.
  • It also appears in at least one other pod, from a message handled over the bus.
  • You can name the service and spaceId of one of the lines.
  • Your handbook lines ask for the trace id and give 180 days for sign-in audit records.

Pass condition. All five checks hold.

If something goes wrong

What you seeWhat to do
No x-correlation-id response headerLook for it on the request headers instead, or in an error response’s traceId. If neither, use curl with your own header, for example -H "x-correlation-id: nw-lab-trace-001".
grep finds nothingWiden --since, and check the label: kubectl -n northwind get pods --show-labels shows app.kubernetes.io/instance=nw.
kubectl logs complains about too many log requestsRaise --max-log-requests, or search one Deployment at a time.
The lines are not JSONThe service is not running in production mode; report it, as the chart sets it for every service.
Model answer

A typical result for saving a user:

PodWhat it loggedHow the id got there
nw-osos-apigatewayThe request, with the id it stampedIt created or kept it
nw-osos-core-dataThe update of the user entryThe HTTP request from the gateway
nw-osos-core-restAudit and timeline entries for the changeA bus message published by data
nw-osos-identityThe identity record re-read for the changed userA bus message about the user entry

The exact set of services depends on what the change triggers; what matters is that the id reaches services the request never called directly. Handbook lines: “Ask for the time, the address and the trace id from the error. Sign-in records are kept 180 days, second-factor records 90 days; everything else in Monitoring is kept until we agree a limit.”

✓ Practice (5 min) — Check your understanding

Section titled “✓ Practice (5 min) — Check your understanding”
PracticeChoose one answer.

An integration partner’s failed calls appear in your logs only as NO-TRACE-ID, and you cannot find them. What do you ask the partner to do?

  1. Explanation for A

    ✗ Incorrect

    Not this one: that bypasses the gateway, the very part that stamps the id. See The correlation id.

  2. Explanation for B

    ✓ Correct

    Correct: the gateway keeps an id the caller sends, so both sides can find the same request. See The correlation id.

  3. Explanation for C

    ✗ Incorrect

    Not this one: their logging does not change what your platform logs. See The correlation id.

Check your answer

The correct answer is B. Open the explanation under each option to see why.

PracticeChoose one answer.

Sentry shows no errors, yet scheduled reports have not been generated for two days. Why might Sentry be silent?

  1. Explanation for A

    ✗ Incorrect

    Not this one: the services report to sentry.backendDSN too. See Error reporting with Sentry.

  2. Explanation for B

    ✓ Correct

    Correct: the scheduler and the audit application are Sentry’s blind spots by design. See Error reporting with Sentry.

  3. Explanation for C

    ✗ Incorrect

    Not this one: the sample rate governs transaction tracing, not whether errors are reported. See Error reporting with Sentry.

Check your answer

The correct answer is B. Open the explanation under each option to see why.

PracticeChoose one answer.

Northwind’s single-tenant release has run for three years, and the MongoDB volume keeps growing. The email log and the audit trail are the largest collections. What is the right next step?

  1. Explanation for A

    ✗ Incorrect

    Not this one: the audit trail is evidence; removing it needs the organization’s agreement. See What the platform keeps.

  2. Explanation for B

    ✗ Incorrect

    Not this one: a single-tenant release never purges these collections. See What the platform keeps.

  3. Explanation for C

    ✓ Correct

    Correct: in single-tenant mode, retention is a decision you implement, not a default. See What the platform keeps.

Check your answer

The correct answer is C. Open the explanation under each option to see why.

PracticeChoose one answer.

You raised global.log.level to debug to investigate, and every pod of the release restarted. Why?

  1. Explanation for A

    ✓ Correct

    Correct: raise the level only for a short, planned investigation, and set it back the same way. See Structured logs.

  2. Explanation for B

    ✗ Incorrect

    Not this one: the restart comes from the configuration change itself. See Structured logs.

  3. Explanation for C

    ✗ Incorrect

    Not this one: the migration is a Job; it restarts nothing. See Structured logs.

Check your answer

The correct answer is A. Open the explanation under each option to see why.

↺ Recap (1 min) — After Module 5 you can

Section titled “↺ Recap (1 min) — After Module 5 you can”

After this module you can read the health of every workload, scrape its metrics and alert on what matters, follow one request through every service by its correlation id, report errors to Sentry with its blind spots in mind, and plan for the records the platform keeps.

Next. Module 6 grows the release: scaling the right tier with the chart’s autoscaling, and keeping MongoDB, Redis and RabbitMQ highly available.