Pcornel
Observability

Logs

Cheat sheet · https://pcornel.dk/topic.php?topic=6100

Back to the Topic

Answer

Logs are timestamped records of discrete events, ideally structured (JSON) with fields such as level, service, message and trace_id.

Remember

Structure logs, include correlation IDs, never log secrets or personal data unnecessarily, and set retention by value. Logs are expensive at volume — sample or drop noise.

First checks

  • journalctl -u <svc> -p err --since -1h — first check for this topic
  • curl -s localhost:9090/-/ready — Prometheus ready
  • curl -s 'localhost:9090/api/v1/query?query=up' — scrape targets up/down
  • promtool check config prometheus.yml — config valid

Verify in this order

app writes log → agent ships → parsed/enriched → indexed/stored → queried

Where it usually breaks

Failures include parsing rules that drop fields, clock skew reordering events, multiline stack traces split incorrectly, log rotation/retention removing context, duplicate ingestion and severity labels that do not reflect operational impact.

Logs verification boundary matrix

BoundaryInspectHealthy interpretationDo not infer
IntentStructured vs unstructured logsIntended object/scope is explicit and versioned where relevantIntent is already effective
Owning runtime/control planeSeverity / Timestamps/time zonesOwner accepts and reports the expected object stateDownstream dependencies are healthy
Effective stateCorrelation/request IDsIndependent read-back matches the intended stateEvery client sees the same result
Consumer outcomeParsing/enrichmentThe original bounded check succeeds in the same time windowProduction correctness outside this scope

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=6100

Confirmation

Confirm action

Continue?