You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A Python script (log_monitor.py) will read the ws_main.log file, search for log levels (INFO, WARNING, ERROR, TRACEBACK), and count the occurrences of each. The results will be stored in an output log file (log_summary.log).
FROM python:3.9
# Set working directory
WORKDIR /app
# Copy the Python script and logs directory
COPY log_monitor.py /app/
COPY logs /logs # Assuming logs are stored in a 'logs' directory in the project# Install any necessary Python packages
RUN pip install --no-cache-dir -r requirements.txt
# Run the script to monitor logs
CMD ["python", "log_monitor.py"]
Docker-cmpose
version: '3.8'
services:
log-monitor:
build: .
volumes:
- ./logs:/logs # Bind the logs directory for persistent access
restart: on-failure
Build and Run the Container
Build the image:
docker build -t log-monitor .# Run the container:
docker run --rm -v $(pwd)/logs:/logs log-monitor
Automating the Daily Execution
Using Docker Compose with Restart Policies: Configure Docker Compose with a restart: daily policy.
Using Cron with Docker: Alternatively, you can set up a host-based cron job to restart the container daily:
0 0 *** docker restart log-monitor
The text was updated successfully, but these errors were encountered:
A Python script (log_monitor.py) will read the ws_main.log file, search for log levels (INFO, WARNING, ERROR, TRACEBACK), and count the occurrences of each. The results will be stored in an output log file (log_summary.log).
Dockerfile
Docker-cmpose
Build and Run the Container
Build the image:
Automating the Daily Execution
Using Docker Compose with Restart Policies: Configure Docker Compose with a restart: daily policy.
Using Cron with Docker: Alternatively, you can set up a host-based cron job to restart the container daily:
The text was updated successfully, but these errors were encountered: