You Found the ERROR. The Cause Is in the Lines Before It
A real incident investigation starts the moment you find the ERROR line. The ERROR is the result — the cause is usually upstream. The WARN just above it, a timeout a few seconds earlier, a config load hundreds of lines back. If you can't see those, your report says "an error occurred" and nothing more. Where grep's context flags stop helping grep -B 20 -A 5 is a fine first step. Then: The context…
When you discover an ERROR in a log, the investigation begins. The ERROR is the outcome, but the cause is typically found further up. A WARN line preceding it might indicate a timeout or a configuration load. To delve deeper into the log, expand the context by using grep flags like -B 20 -A 5. Remember, the context width is an estimate; increase it if needed. When dealing with vast amounts of data, focus on hit lists and the original file to maintain synchronization.
For example, during an investigation, a search for 'coffee_shop' in a 258 GB file of US OpenStreetMap data returned 4.5 billion lines. By drilling down, you can isolate specific hits. Here, a single Starbucks location in Central Park was identified from a search result containing 100,492 hits. The traceability is evident - from ERROR to payment service to the specific request ID. This process can be replicated for any log, tracing the chain of events leading to the error.
UwView, a free tool, facilitates this process. Search results are presented in separate pop-up windows, allowing you to switch between the list of hits and the specific scene in the log. The context automatically adjusts based on the scale of the log, never getting cut off even when scrolling through millions of lines. If you notice a common WARN preceding each ERROR, you can quickly identify the pattern.
Once a potential suspect is found, you can search for the corresponding request or thread ID to trace the issue through the entire log.
The free version of UwView provides all the necessary tools for most investigations. It allows you to jump to hits, save them to a file, and apply color rules for better visibility. For repetitive work, Pro version offers more advanced features like increased context width, independent popups for different files, and faster reopening from saved indexes. However, even the free version provides comprehensive capabilities for investigating large logs.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.