This is a command-line application that parses a log (.txt) file with each line containing a log entry of various categories. It then classifies these logs to their respective categories, performs aggregations based on the log category and saves the aggregations in JSON files.
The current logs are of one of these types:
| APM Logs (Application Performance Metrics) | Application Logs | Request Logs | |
|---|---|---|---|
| eg | timestamp=2024-02-24T16:22:15Z metric=cpu_usage_percent host=webserver1 value=72 |
timestamp=2024-02-24T16:22:20Z level=INFO message="Scheduled maintenance starting" host=webserver1 |
timestamp=2024-02-24T16:22:25Z request_method=POST request_url="/api/update" response_status=202 response_time_ms=200 host=webserver1 |
| keys | - metric = cpu_usage_percent, memory_usage_percent, disk_usage_percent etc - value will have the respective value |
- level can be INFO, ERROR, DEBUG, WARNING |
- request_url can be /api/update, /api/status, /api/retry etc - response_time_ms has the response time for the API route - response_status has the response status for the API route |
| find | for each metric:- minimum- median- average- max |
for each level:- count |
for each route: - min of response_time- 50_percentile of response_time- 90_percentile of response_time- 95_percentile of response_time- 99_percentile of response_time- max of response_time- count of response_status |
| file | apm.json |
application.json |
request.json |
Notes
- To run the program, use the command
./LogParser.sh --file <filename.txt>from the LogParser root directory (might have to runchmod +x LogParser.shonce to give it permission to run) - The parser ignores a log entry in case it is corrupted or incomplete
- Output files are created even if no entry exists for that type
- Part I.pdf contains the solutions for the first question along with the class diagram
- LogParser is the solution for the second question - Java code and JUnit unit tests