Detailed Analysis Tab
Relevant source files
The following files were used as context for generating this wiki page:
The Detailed Analysis Tab is a core component of the LogUtil Terminal User Interface (TUI), designed to provide a deep-dive view into specific traffic patterns. While the Overview Tab provides high-level statistics, the Detailed Tab allows users to drill down into individual IP addresses to inspect every specific request associated with that source.
The primary scope of this module is to bridge the gap between aggregate metrics and raw log data. It enables security auditing, troubleshooting, and traffic pattern analysis by providing a split-pane interface: a list of top-contributing IP addresses on the left and a scrollable list of corresponding raw log entries on the right. Sources: README.md:164-167, src/tabs/detailed.rs:1-35
Architecture and Components
The Detailed Tab is implemented as a stateful struct that implements the Tab trait. It maintains local UI states for two distinct panels, allowing for independent navigation within the IP list and the request details. Sources: src/tabs/detailed.rs:26-30, src/tabs/base.rs:1-15
Core Data Structures
| Structure | Description | Key Fields |
|---|---|---|
DetailedTab | The main container for the tab's logic and state. | ip_table_state, request_list_state, top_n |
DrawDetailedRequestsParams | A helper struct used to encapsulate rendering parameters for the request panel. | frame, area, ip_rows, request_items |
GLOBAL_DB | An external memory-resident database used to query IP and request data. | Accessed via db.get_top_ips() and db.find_by_ip() |
Sources: src/tabs/detailed.rs:13-30, src/app.rs:7-15
Visual Layout Flow
The tab utilizes a horizontal split layout, allocating 30% of the screen width to the IP selection table and 70% to the detailed request list.
Functional Logic
Data Retrieval and Formatting
The tab dynamically fetches data from the GLOBAL_DB. It retrieves the "Top N" IP addresses (defaulting to 10) and then performs a secondary query based on the user's current selection to populate the request list. Sources: src/tabs/detailed.rs:35-40, src/tabs/detailed.rs:195-205
- IP Formatting: Each row in the IP table includes the IP address, the total request count, and a human-readable timestamp of the last update, formatted using the local timezone. Sources: src/tabs/detailed.rs:90-115
- Request Formatting: Individual log lines are truncated to 100 characters for the preview list to maintain UI readability, though the full string remains available for operations like clipboard copying. Sources: src/tabs/detailed.rs:120-130
Interaction Model
The tab handles standard keyboard navigation to switch focus between the IP list and the request list.
Sources: src/tabs/detailed.rs:235-285
Feature: Clipboard Integration
A critical feature of the Detailed Analysis Tab is the ability to export data to the system clipboard. The copy_selected_to_clipboard function identifies which element is currently focused and extracts the relevant string. Sources: src/tabs/detailed.rs:46-85, src/app.rs:105-135
- IP Selection: If the IP table is focused, the raw IP address string is copied.
- Request Selection: If a specific request is focused, the entire raw log line (not the truncated version) is copied.
- Feedback: Upon a successful copy, the
Appstate triggers a modal notification usingTuiManager::draw_modalto confirm the action to the user.
Sources: src/tabs/detailed.rs:50-80, src/tui_manager.rs:85-110
Logic Sequence for Copy Operation
Sources: src/tabs/detailed.rs:46-85, src/app.rs:125-135
Component Styling
The UI utilizes specific color constants defined in the tui_manager to ensure visual consistency across tabs.
| Element | Style / Color | Context |
|---|---|---|
| IP Address | Color::Rgb(255, 255, 0) | Yellow/Bold for high visibility. |
| Request Count | Color::Rgb(169, 169, 169) | Dimmed grey for secondary data. |
| Last Update | Color::Rgb(100, 149, 237) | Cornflower blue for timestamps. |
| Borders | Color::Rgb(144, 238, 144) | Light green rounded borders. |
| Selection | SELECTED_ITEM_STYLE | White text on Dark Blue background. |
Sources: src/tabs/detailed.rs:106-114, src/tui_manager.rs:48-58, src/tabs/detailed.rs:160-170
Conclusion
The Detailed Analysis Tab serves as the primary diagnostic tool within LogUtil. By organizing high-volume log data into an IP-centric hierarchy and providing integrated clipboard support, it allows administrators to transition quickly from observing an anomaly to inspecting the specific underlying request data. Its implementation relies on a split-state management system that balances efficient data retrieval with a responsive, interactive terminal experience. Sources: README.md:164-167, src/tabs/detailed.rs:190-230