// advent-of-postgres/day-8
The JSON Logs
The logs are JSON, and the field you need is three levels deep. Find where the gold-tier users hit errors.
Gold-tier users are the elves who pay for priority gift tracking, and support has a pile of complaints from them. Pepper wants to know which region to look at first.
All service logs for 8 December are in logs:
| Column | Type | Notes |
|---|---|---|
id |
bigint |
Primary key |
ts |
timestamptz |
When the line was written |
body |
jsonb |
The structured log line |
A typical body:
{
"level": "error",
"service": "gift-router",
"msg": "request handled",
"ctx": { "region": "eu-north", "user": { "id": "u42", "tier": "gold" } }
}
Anonymous requests have no user block at all.
Your task
Which region had the most error-level log lines from gold-tier users?
Submit the region.
Stuck? Show a hint
->> returns text, and #>> takes a path like '{ctx,user,tier}'. Lines without a user block return NULL there.
Download today's data as SQL to solve it on your own Postgres (14 or later).
Solved this puzzle? Share it.
Tag @thedevopsdaily and share it with the community.
We earn commissions when you shop through the links below.
Bitrise
Managed runners for GitHub Actions
Bitrise Build Hub runs your GitHub Actions jobs on M4 Macs and AMD Linux machines. Change runs-on and keep your workflows, secrets and logs on GitHub.
Atomsized
AWS platform engineering and GitOps
Design and automation for reliable AWS and Kubernetes platforms, safer delivery workflows, and preview and UAT environments your engineers can understand and own.
DigitalOcean
Cloud infrastructure for developers
Simple, reliable cloud computing designed for developers
DevDojo
Developer community & tools
Join a community of developers sharing knowledge and tools
SMTPfast
Developer-first email API
Send transactional and marketing email through a clean REST API. Detailed logs, webhooks, and embeddable signup forms in one dashboard.
QuizAPI
Developer-first quiz platform
Build, generate, and embed quizzes with a powerful REST API. AI-powered question generation and live multiplayer.
Want to support DevOps Daily and reach thousands of developers?
Become a Sponsor