# logsearch **Repository Path**: bug_search/logsearch ## Basic Information - **Project Name**: logsearch - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-04-20 - **Last Updated**: 2026-04-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Log Search System A Spring Boot application for centralized log search across multiple servers with SSH remote access, database query capabilities, and MD report generation. ## Features - **Multi-Server Management**: Manage SSH server configurations for different environments (SIT, UAT, DEV) - **SSH Remote Log Search**: Connect to remote servers via SSH and search log files using grep - **Database Query**: Query business tables (fm_analysis_sql_info, fw_query_info, fw_tran_info, fw_tran_info_msg) with sequence number lookup - **Message Extraction**: Extract request/response messages from log content - **MD Report Generation**: Generate Markdown reports with search results - **File Download**: Download search results as compressed files - **RESTful API**: Complete Web API for all operations - **Command Line Support**: Run searches from command line ## Technology Stack - Java 1.8 - Spring Boot 2.7.x - MySQL Database - JSch (SSH connectivity) - Spring Data JPA - Spring Validation ## Project Structure ``` logsearch/ ├── pom.xml ├── src/main/java/com/walker/logsearch/ │ ├── LogsearchApplication.java │ ├── config/ # Configuration classes │ ├── controller/ # REST API controllers │ ├── service/ # Business services │ ├── repository/ # Data access layer │ ├── entity/ # JPA entities │ ├── dto/ # Data transfer objects │ ├── util/ # Utility classes │ └── exception/ # Exception handling ├── src/main/resources/ │ ├── application.yml # Application configuration │ └── schema.sql # Database initialization └── README.md ``` ## Quick Start ### Prerequisites - JDK 1.8 or higher - Maven 3.x - MySQL 5.7+ or MySQL 8.x ### Build ```bash cd logsearch mvn clean package ``` ### Run ```bash # Using Maven mvn spring-boot:run # Using JAR java -jar target/logsearch-1.0.0.jar ``` ### Command Line Usage ```bash # Basic search java -jar logsearch-1.0.0.jar # Search with environment java -jar logsearch-1.0.0.jar --env=sit # Search with specific server java -jar logsearch-1.0.0.jar --server-id=1 # Search with multiple sequence fields java -jar logsearch-1.0.0.jar --sub-seq-no=001 --service-no=SVC001 # Help java -jar logsearch-1.0.0.jar --help ``` ## API Documentation ### Server Configuration APIs #### Create Server ``` POST /api/servers Content-Type: application/json { "env": "sit", "host": "server.example.com", "port": 22, "username": "admin", "password": "password123", "logPath": "/var/log/application", "dbUrl": "jdbc:mysql://db.example.com:3306/app_db", "dbUsername": "app_user", "dbPassword": "db_password" } ``` #### Update Server ``` PUT /api/servers/{id} Content-Type: application/json { "env": "sit", "host": "server.example.com", "port": 22, "username": "admin", "password": "newpassword123", "logPath": "/var/log/application" } ``` #### Delete Server ``` DELETE /api/servers/{id} ``` #### Get All Servers ``` GET /api/servers GET /api/servers?env=sit ``` #### Test Connection ``` POST /api/servers/{id}/test ``` ### Keyword APIs #### Create Keyword ``` POST /api/keywords Content-Type: application/json { "keyword": "ERROR", "description": "Error level logs" } ``` #### Get All Keywords ``` GET /api/keywords GET /api/keywords?search=ERR ``` #### Delete Keyword ``` DELETE /api/keywords/{id} ``` ### Search APIs #### Execute Log Search ``` POST /api/search Content-Type: application/json { "seqNo": "SEQ2024000001", "subSeqNo": "001", "serviceNo": "SVC001", "busSeqNo": "BUS2024000001", "reference": "REF001", "serverId": 1, "env": "sit" } ``` Response: ```json { "code": 0, "message": "Success", "data": { "taskId": "TASK_1234567890_abc123", "status": "COMPLETED", "databaseResults": { "fmAnalysisSqlInfo": [...], "fwQueryInfo": [...], "fwTranInfo": [...], "fwTranInfoMsg": [...], "hasResults": true, "totalRecords": 4 }, "logFiles": [...], "logLines": [...], "requestMessage": "...", "responseMessage": "...", "reportContent": "...", "downloadUrl": "/api/download/TASK_1234567890_abc123" } } ``` #### Get Task Status ``` GET /api/search/{taskId}/status ``` ### Report APIs #### Get MD Report ``` GET /api/reports/{taskId} ``` ### Download APIs #### Download Results ``` GET /api/download/{taskId} ``` #### Check Download Ready ``` GET /api/download/{taskId}/ready ``` ## Configuration ### Database Configuration (application.yml) ```yaml spring: datasource: url: jdbc:mysql://localhost:3306/logsearch username: root password: root jpa: hibernate: ddl-auto: update ``` ### Server Configuration Servers can be configured via: 1. Application startup (sample data auto-created) 2. REST API 3. Database directly ## Database Schema ### Tables 1. **server_config**: SSH server configurations 2. **keyword**: Search keywords 3. **search_task**: Search task tracking 4. **fm_analysis_sql_info**: SQL analysis information 5. **fw_query_info**: Query information 6. **fw_tran_info**: Transaction information 7. **fw_tran_info_msg**: Transaction message details ## Log Search Flow 1. **Connect**: Establish SSH connection to target server 2. **Query Database**: Search business tables by sequence numbers 3. **Search Files**: Use `grep -rl` to find files containing the sequence 4. **Get Lines**: Use `grep -n` to get detailed line information 5. **Extract Messages**: Parse request/response from log content 6. **Generate Report**: Create Markdown report 7. **Save Files**: Save all results to download directory ## Security Notes - Passwords are stored in plain text (use encryption in production) - SSH connections use password authentication - Consider using key-based authentication for production ## Troubleshooting ### SSH Connection Failed - Verify server hostname/IP and port - Check username and password - Ensure SSH service is running - Check firewall settings ### Database Query No Results - Verify sequence number exists in business tables - Check database connection settings - Ensure correct sequence fields are populated ### Log Files Not Found - Verify log path on remote server - Check file permissions - Ensure grep is available on remote server ## License This project is for internal use only.