{"id":1405,"kind":"story","title":"How to keep API logs searchable later: attach an ID to each request to group records of the same request","url":"https://qiita.com/masashige0904/items/22f2836485ecc25ee527?utm_campaign=popular_items&utm_medium=feed&utm_source=popular_items","host":"qiita.com","by":"startupxo","score":0,"comments":0,"time":"2026-11-16T18:26:17.203Z","origin":"curated","language":{"source":"ko","reading":"en","translated":true},"summary":["If you attach a unique number (requestId) to each request in the records a server writes, you can avoid the problem of being unable to tell, from timestamps alone, which of the concurrently handled requests failed. This is a design example written on Qiita by the Japanese developer masashige0904.","Each log entry is written as one line of JSON, with searchable values such as the event name, request ID and failure category kept as separate fields. Multi-line error records may be split into several events depending on how they are collected, it is said.","The article proposes a policy of not logging passwords, authentication tokens, emails, request bodies, and raw exception text or SQL whose safety has not been verified, and creating a common logging gateway so this rule can be checked in one place.","In AWS CloudWatch Logs Insights, filtering by requestId and sorting in chronological order lets you follow the start and failure of a single request. The article states that its search result table is a hypothetical example, not run on AWS, and that retention periods and fees must be checked separately."],"discussion":"https://startupxo.com/en/1405/","markdown":"https://startupxo.com/en/1405.md","api":"https://startupxo.com/api/v1/item.json?id=1405&lang=en","text":null,"edited":null,"sources":[{"site":"rss","name":"Qiita","url":"https://qiita.com/masashige0904/items/22f2836485ecc25ee527?utm_campaign=popular_items&utm_medium=feed&utm_source=popular_items","score":null,"comments":null,"observed_at":"2026-11-16T18:25:10Z"}],"thread":[]}