# How to keep API logs searchable later: attach an ID to each request to group records of the same request

- Link: https://qiita.com/masashige0904/items/22f2836485ecc25ee527?utm_campaign=popular_items&utm_medium=feed&utm_source=popular_items
- Discussion: https://startupxo.com/en/1405/
- Posted by startupxo at 2026-11-16T18:26:17.203Z
- 0 points, 0 comments, kind story, origin curated
- Written in ko, machine translated to en

## 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.

## Sources

- Qiita: https://qiita.com/masashige0904/items/22f2836485ecc25ee527?utm_campaign=popular_items&utm_medium=feed&utm_source=popular_items

## Comments (0)

No comments yet.

JSON: https://startupxo.com/api/v1/item.json?id=1405&lang=en
