This technical test requires you to design and implement a Logs Ingestion and Viewing backend using Java Quarkus. The backend will help manage incoming log entries, store them, and provide API endpoints to view and filter the logs.
Fork this repository and invite the provided collaborators: @korutx, @odtorres. Should you have any questions, contact devtest@microboxlabs.com.
- We provide a basic Quarkus project with a basic setup.
- You can use any additional libraries or tools you see fit, but make sure to justify your choices.
- Quarkus documentation is available here.
MicroboxLabs needs a backend system to help their engineering team efficiently manage incoming log entries from various microservices. The new system will provide REST API endpoints for logs ingestion, storage, and viewing by users. The backend will need to handle log parsing, storage, and filtering based on different criteria.
The goal is to create a Java Quarkus backend application that provides REST API endpoints for log ingestion, viewing, and filtering. The key features are as follows:
-
Logs Ingestion Endpoint (Admin Only)
- Create an API endpoint (
/api/logs/upload) that accepts a plain text file containing log entries. - Each log entry in the file must have the following format:
[2024-11-01 10:00:00] [INFO] Service-A: Successfully completed task. [2024-11-01 10:01:00] [ERROR] Service-B: Failed to connect to the database. [2024-11-01 10:02:00] [WARNING] Service-C: Response time is slow. - Parse each log entry and store it in the database with the following fields:
- Timestamp (e.g.,
2024-11-01 10:00:00) - Log Level (e.g.,
INFO,ERROR,WARNING) - Service Name (e.g.,
Service-A) - Message (e.g.,
Successfully completed task)
- Timestamp (e.g.,
- Create an API endpoint (
-
View Logs Endpoint
- Create an API endpoint (
/api/logs) that allows users to view all log entries. - The endpoint should provide pagination to efficiently handle large amounts of logs.
- The response should include fields like timestamp, log level, service name, and message.
- Create an API endpoint (
-
Filtering Logs Endpoint
- Create an API endpoint (
/api/logs/filter) that allows users to filter logs based on the following parameters:- Date Range: Start and end dates.
- Log Level: Filter by
INFO,WARNING,ERROR. - Service Name: Filter by the name of the service (e.g.,
Service-A).
- Create an API endpoint (
- Use a lightweight database (e.g., H2 or PostgreSQL).
- Store each log entry as a separate record in the database with the necessary fields.
- Implement basic authorization to distinguish between Admin users and Regular users:
- Admin User: Allowed to upload log files.
- Regular User: Allowed only to view and filter logs.
- Backend Framework: Quarkus (Java).
- Database: H2 or PostgreSQL for storing log entries.
- RESTful API: Use Quarkus RESTEasy to implement the endpoints.
- Security: Implement basic authentication using Quarkus Security.
-
Admin Uploads Logs:
- An Admin user calls the
/api/logs/uploadendpoint to upload a plain text log file. - The backend parses the file and stores each log entry in the database.
- An Admin user calls the
-
Viewing Logs:
- A Regular User makes a GET request to
/api/logsto view logs. - The backend responds with a paginated list of log entries.
- A Regular User makes a GET request to
-
Filtering Logs:
- A user makes a GET request to
/api/logs/filterwith parameters like date range, log level, or service name. - The backend returns the filtered log entries.
- A user makes a GET request to
- Functionality:
- Does the solution meet all the core requirements?
- Are users able to upload, view, and filter logs effectively?
- Software Design:
- Proper use of Quarkus features and logical organization of code.
- Clean separation between data, business, and presentation layers.
- Code Quality:
- Readable and maintainable code with meaningful comments.
- Effective use of modern Java and Quarkus features.
- Testing:
- Unit Tests for parsing logs and storing entries.
- Integration Tests for the API endpoints.
- Documentation:
- Clear instructions on how to set up and run the project.
- In-line comments for complex parts of the code.
- Deployment: Focus on local execution and testing rather than deployment.
- Advanced Security: Keep authentication simple, as the emphasis is on functionality.
- Swagger Documentation: Use Quarkus OpenAPI to add Swagger documentation for the API.
- Real-Time Streaming: Add support for a real-time streaming endpoint using Server-Sent Events (SSE) to push new log entries to users as they arrive.
- Fork/Clone the repository.
- Set up a Quarkus project and configure your chosen database.
- Implement the required REST API endpoints.
- Use any tools or resources, including AI (e.g., ChatGPT or GitHub Copilot), to assist you.
This challenge aims to evaluate your ability to work on a backend application using Java Quarkus, focusing on REST API creation, database integration, and effective use of the Quarkus framework.