Error Log Monitoring Problem
Description
This repository offers a solution for an Error Log Monitoring platform, capable of processing log entries and performing various operations such as computing statistics based on timestamps and log types. The project, implemented in Python, includes functionality for generating test input files and Dockerizing the solution for easy deployment.
Features
- Submit Log Entry: Store a new log entry with timestamp, log type, and severity.
- Compute Statistics by Log Type: Calculate the min, max, and mean severity for a specified log type.
- Compute Statistics Before/After Timestamp: Determine the min, max, and mean severity for all log entries before or after a specified timestamp.
- Compute Statistics by Log Type and Timestamp: Calculate the min, max, and mean severity for all log entries of a specified log type occurring before or after a specified timestamp.
Assumptions
- Timestamps are provided in ascending order.
- Log types can be any UTF-8 supported string, with a maximum length of 100 characters.
- Severity is a positive, non-zero floating-point number.
- The solution ensures precision to 10^-6 for severity results.
File Structure
- index.py: Main script for processing log entries and generating the output.
- generate_inputs.py: Script for generating test input files.
- input.txt: Input file containing log entries and commands.
- output.txt: Output file for storing the results.
- Dockerfile: Dockerfile for containerizing the application.
Prerequisites
- Python 3.8-slim
- Docker
Running the Solution
- Generate Test Input File: python generate_inputs.py
- Run the Main Script: python index.py
Dockerizing the Solution
- Build the Docker Image: docker build -t errorlogmonitoring .
- Run the Docker Container: docker run --name errorlogmonitoring -v C:/path/to/your/project/input.txt:/app/input.txt -v C:/path/to/your/project/output.txt:/app/output.txt errorlogmonitoring
Example
Sample Input (input.txt):
1 1715744138011;INTERNAL_SERVER_ERROR;23.72
1 1715744138012;INTERNAL_SERVER_ERROR;10.17
2 INTERNAL_SERVER_ERROR
1 1715744138012;BAD_REQUEST;15.22
1 1715744138013;INTERNAL_SERVER_ERROR;23.72
3 BEFORE 1715744138011
3 AFTER 1715744138010
2 BAD_REQUEST
4 BEFORE INTERNAL_SERVER_ERROR 1715744138011
4 AFTER INTERNAL_SERVER_ERROR 1715744138010
Sample Output (output.txt):
No output
No output
Min: 10.170000, Max: 23.720000, Mean: 16.945000
No output
No output
Min: 0.000000, Max: 0.000000, Mean: 0.000000
Min: 10.170000, Max: 23.720000, Mean: 18.207500
Min: 15.220000, Max: 15.220000, Mean: 15.220000
Min: 0.000000, Max: 0.000000, Mean: 0.000000
Min: 10.170000, Max: 23.720000, Mean: 19.203333
Author: Maharnab Ghosh