Structured Logging
Cheat sheet · https://pcornel.dk/topic.php?topic=6207
Answer
Structured logging writes logs as key-value data (usually JSON) instead of free text, so fields can be filtered, aggregated and correlated.
Remember
Use consistent field names (timestamp, level, service, message, trace_id). Log the event once with context instead of many lines. Never log passwords, tokens or full card data.
First checks
tail -1 app.log | jq .— first check for this topiccurl -s localhost:9090/-/ready— Prometheus readycurl -s 'localhost:9090/api/v1/query?query=up'— scrape targets up/downpromtool check config prometheus.yml— config valid
Verify in this order
event + context → JSON line → parsed fields → queries
Where it usually breaks
Multi-line stack traces break line-based collectors unless joined.
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=6207