Skip to content

Commit ab0a528

Browse files
committed
Comprehensive Update
1 parent ff20e02 commit ab0a528

32 files changed

+3286
-1924
lines changed

.github/CHANGELOG.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
- version 1.0.0 - 10/31/2024
2+
- version 1.1.0 - 11/18/2024 - major changes
3+
- version 1.1.1 - 11/20/2024 - keyword replacement
4+
- version 2.0.0 - 11/28/2024 - backward incompatible
5+
- [1.0.1] apache_logs.error_systemCodeID corrected line - INTO logsystemCode to INTO logsystemCodeID
6+
- [1.0.1] remove debugging - SELECT statement from apache_logs.process_access_import, process_error_import & normalize_useragent.
7+
- [1.0.1] remove whitespace and commented out old code on all stored programs
8+
- [1.0.1] set all table AUTO_INCREMENT=1. All future version releases will be the same - AUTO_INCREMENT=1.
9+
- [1.1.0] rename LOAD DATA TABLES, normalized access_log_useragent TABLE into 11 TABLES, added 13 VIEWS.
10+
- [1.1.0] resize LOAD DATA COLUMNS, added req_query COLUMN and seperated query strings from req_uri COLUMN.
11+
- [1.1.0] add access_log_reqquery TABLE, renamed access_log_session TABLE to access_log_cookie.
12+
- [1.1.0] add UPDATE TRIM statements for apachemessage COLUMNS.
13+
- [1.1.1] change word 'extended' to 'csv2mysql'
14+
- [2.0.0] fix the double backslash requirement on Windows platform for file paths.
15+
- [2.0.0] move all stage table parsing from Python to MySQL Stored Procedures - process_access_parse & process_error_parse
16+
- [2.0.0] process_access_parse, process_access_import, process_error_parse, process_error_import have importloadid parameter.
17+
- [2.0.0] revamp parse & import processes and now provide 2 processing methods - by process_status and new importloadid.
18+
- [2.0.0] relate and control each client load, parsing and importing separately. Enable multiple upload clients simultaneously.
19+
- [2.0.0] add or rename of COLUMNS in import_load, import_process, import_file. populate import_load and import_process with meaningful information.
20+
- [2.0.0] add SET importfileid COLUMN to LOAD DATA statement and remove UPDATE importfileid statement in Python.
21+
- [2.0.0] create ErrorLogFormat "[%{u}t] [%-m:%l] [pid %P:tid %T] %7F: %E: [client\ %a] %M% ,\ referer\ %{Referer}i , %v" to add %v-canonical ServerName.
22+
- [2.0.0] add ServerName & ServerPort on import Combined & Error logs stage tables. Option allow adding domains to logs.
23+
- [2.0.0] add ERROR_SERVERNAME,ERROR_SERVERPORT,COMBINED_SERVERNAME & COMBINED_SERVERPORT variables to settings.env.
24+
- [2.0.0] add SET servername & serverport COLUMN values to LOAD DATA statements.
25+
- [2.0.0] create log_referer, log_remotehost, log_servername, log_serverport TABLES to assoicate Access and Error logs.
26+
- [2.0.0] add server_name & server_port COLUMNS to import_file TABLE. Provides second option to update Apache logs without %v.
27+
- [2.0.0] modify process_access_import & process_error_import to populate empty server_name & server_port with ServerName & ServerPort from import_file TABLE.
28+
- [2.0.0] add WATCH_LOG to setting Log Level in watch4logs.py. 0=no messages, 1=message when files found, 2=message when checking for files & files found
29+
- [2.0.0] add class bcolors to place RED BACKGROUND on all ERROR - messsages
30+
- [2.0.0] add file - mysql_user_and_grants.sql - MySQL USER and GRANTS file for CREATE USER apache_upload for Python module
31+
- [2.0.0] add file - call_processes.sql - description and CALL command lines for 5 Stored Procedures
32+
- [2.0.0] add file - CHANGLOG.md - for single place to list all code and database changes

.github/INSTALL.md

Lines changed: 43 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
## Installation Instructions
2-
The steps are very important to make installation painless. Please follow instructions in order.
2+
The steps are important to make installation painless.
33

44
### 1. MySQL Steps
5-
Before running `apachLogs2MySQL.sql` open file in your favorite editor and do a ***Find and Replace*** of the following User Account with a User Account with DBA Role on server you are installing on. This will make everything much easier. Copy below:
5+
Before running `apachLogs2MySQL.sql` if `root`@`localhost` does not exist open file and do a ***Find and Replace*** of User Account with a User Account with DBA Role on installation server. Copy below:
66
```
7-
`root`@`%`
7+
`root`@`localhost`
88
```
9-
Rename above <sup>user</sup> to a <sup>user</sup> on your server. For example - `root`@`%` to `dbadmin`@`localhost`
9+
Rename above <sup>user</sup> to a <sup>user</sup> on your server. For example - `root`@`localhost` to `dbadmin`@`localhost`
1010

11-
The easiest way to install is use MySQL Command Line Client. Login as User with DBA Role and execute the following:
11+
The easiest way to install is MySQL Command Line Client. Login as User with DBA Role and execute the following:
1212
```
1313
source yourpath/apacheLogs2MySQL.sql
1414
```
@@ -20,7 +20,7 @@ local-infile=1
2020
After these 3 steps MySQL server should be good to go.
2121

2222
### 2. Python Steps
23-
Install all modules:
23+
Install all modules (`requirements.txt` in repository):
2424
```
2525
pip install -r requirements.txt
2626
```
@@ -32,7 +32,7 @@ python3 -m ensurepip --upgrade
3232
If any issues with ***pip install*** occur use individual install commands below:
3333

3434
### 3. Required Python Modules
35-
Python module links & install command lines for each platform. Single quotes around module name are required on macOS. The simplest option is run the command line under '5. Python Steps'. If that works you are all set. The `requirements.txt` file is included in repository.
35+
Python module links & install command lines for each platform. Single quotes around module name are required on macOS.
3636
|Python Package|Windows 10 & 11|Ubuntu 24.04|macOS 15.0.1 Darwin 24.0.0|GitHub Repository|
3737
|--------------|---------------|------------|--------------------------|-----------------|
3838
|[PyMySQL](https://pypi.org/project/PyMySQL/)|python -m pip install PyMySQL[rsa]|sudo apt-get install python3-pymysql|python3 -m pip install 'PyMySQL[rsa]'|[PyMySQL/PyMySQL](https://github.com/PyMySQL/PyMySQL)|
@@ -47,48 +47,45 @@ By default the load_dotenv() is looking for a file name .env which is standard n
4747
```
4848
load_dotenv() # Loads variables from .env into the environment
4949
```
50-
Windows requires double backslash:
51-
```
52-
C:\\Users\\farmf\\Documents\\apacheLogs\\
53-
```
54-
Lunix & macOS require single frontslash:
55-
```
56-
/home/will/apacheLogs/
57-
```
5850
Below is settings.env with default settings for running on Windows 11 Pro workstation. Make sure the correct logFormats are in correct logFormat folders. The application does not currently detect logFormats. Data will not be imported properly if folder settings are not correct.
5951
### 5. Settings.env Variables
6052
```
61-
MYSQL_HOST=localhost # MySQL server
62-
MYSQL_PORT=3306 # MySQL server port
63-
MYSQL_USER=root # MySQL server User
64-
MYSQL_PASSWORD=password # MySQL server User Password
65-
MYSQL_SCHEMA=apache_logs # MySQL database schema ApacheLogs2MySQL will create
66-
WATCH_PATH=C:\\Users\\farmf\\Documents\\apacheLogs\\ # watch folder for new files
67-
WATCH_RECURSIVE=1 # watch all subfolders - 0=no 1=yes
68-
WATCH_INTERVAL=15 # seconds between watching for new files
69-
ERROR=1 # process error logs - 0=no 1=yes
70-
ERROR_LOG=2 # display process error processing to console in python - 0=none 1=summary 2=summary & each file being processed
71-
ERROR_PATH=C:\\Users\\farmf\\Documents\\apacheLogs\\**/*error*.* # process folder & file patterns for Error Log files - MUST BE Watch folder and can be Subfolders
72-
ERROR_RECURSIVE=1 # watch all subfolders - 0=no 1=yes
73-
ERROR_PROCESS=1 # execute MySQL Stored Procedure to import Error log staging table - 0=no 1=yes
74-
COMBINED=1 # process Common and Combined Access logs - 0=no 1=yes
75-
COMBINED_LOG=2 # display Common and Combined Access log processing to console in python - 0=none 1=summary 2=summary & each file being processed
76-
COMBINED_PATH=C:\\Users\\farmf\\Documents\\apacheLogs\\combined\\**/*access*.* # process folder & file patterns for Common and Combined Access files - MUST BE Watch subfolder
77-
COMBINED_RECURSIVE=1 # watch all subfolders - 0=no 1=yes
78-
COMBINED_PROCESS=1 # execute MySQL Stored Procedure to import Common and Combined Access staging table - 0=no 1=yes
79-
VHOST=1 # process Vhost Access logs - 0=no 1=yes
80-
VHOST_LOG=2 # display Vhost Access log processing to console in python - 0=none 1=summary 2=summary & each file being processed
81-
VHOST_PATH=C:\\Users\\farmf\\Documents\\apacheLogs\\vhost\\**/*access*.* # process folder & file patterns for Vhost Access files - MUST BE Watch subfolder
82-
VHOST_RECURSIVE=1 # watch all subfolders - 0=no 1=yes
83-
VHOST_PROCESS=1 # execute MySQL Stored Procedure to import Vhost Access log staging table - 0=no 1=yes
84-
CSV2MYSQL=1 # process error logs - 0=no 1=yes
85-
CSV2MYSQL_LOG=2 # display Csv2mysql Access log processing to console in python - 0=none 1=summary 2=summary & each file being processed
86-
CSV2MYSQL_PATH=C:\\Users\\farmf\\Documents\\apacheLogs\\csv2mysql\\**/*access*.* # process folder & file patterns for Csv2mysql Access files - MUST BE Watch subfolder
87-
CSV2MYSQL_RECURSIVE=1 # watch all subfolders - 0=no 1=yes
88-
CSV2MYSQL_PROCESS=1 # execute MySQL Stored Procedure to import Csv2mysql Access log staging table - 0=no 1=yes
89-
USERAGENT=1 # process csv2mysql Access logs - 0=no 1=yes
90-
USERAGENT_LOG=2 # display userAgent processing to console in python - 0=none 1=summary 2=summary & each file being processed
91-
USERAGENT_PROCESS=1 # execute MySQL Stored Procedure process userAgent parsed table into 14 normalized userAgent tables - 0=no 1=yes
53+
MYSQL_HOST=localhost
54+
MYSQL_PORT=3306
55+
MYSQL_USER=apache_upload
56+
MYSQL_PASSWORD=password
57+
MYSQL_SCHEMA=apache_logs
58+
WATCH_PATH=C:\Users\farmf\Documents\apacheLogs\
59+
WATCH_RECURSIVE=1
60+
WATCH_INTERVAL=15
61+
WATCH_LOG=2
62+
ERROR=1
63+
ERROR_LOG=2
64+
ERROR_PATH=C:\Users\farmf\Documents\apacheLogs\**/*error*.*
65+
ERROR_RECURSIVE=1
66+
ERROR_PROCESS=2
67+
ERROR_SERVERNAME=yourdomain.com
68+
ERROR_SERVERPORT=443
69+
COMBINED=1
70+
COMBINED_LOG=2
71+
COMBINED_PATH=C:\Users\farmf\Documents\apacheLogs\combined\**/*access*.*
72+
COMBINED_RECURSIVE=1
73+
COMBINED_PROCESS=2
74+
COMBINED_SERVERNAME=yourdomain.com
75+
COMBINED_SERVERPORT=443
76+
VHOST=1
77+
VHOST_LOG=2
78+
VHOST_PATH=C:\Users\farmf\Documents\apacheLogs\vhost\**/*access*.*
79+
VHOST_RECURSIVE=1
80+
VHOST_PROCESS=2
81+
CSV2MYSQL=1
82+
CSV2MYSQL_LOG=2
83+
CSV2MYSQL_PATH=C:\Users\farmf\Documents\apacheLogs\csv2mysql\**/*access*.*
84+
CSV2MYSQL_RECURSIVE=1
85+
CSV2MYSQL_PROCESS=2
86+
USERAGENT=1
87+
USERAGENT_LOG=2
88+
USERAGENT_PROCESS=1
9289
```
9390
### 6. Run Application
9491
If MySQL steps completed successfully, successfully installed Python modules, renamed file `settings.env` to `.env`, and updated MySQL server connection and log folder variables it is time to run application.

0 commit comments

Comments
 (0)