eldy / AWStats

AWStats Log Analyzer project (official sources)
https://www.awstats.org
361 stars 119 forks source link

+ allow processing logs in json #245

Closed bayaro closed 1 month ago

bayaro commented 6 months ago

Nowadays in many cases it is more convenient to have logs in json. These changes allow process such logs without losing any previous functionality.

The new option is introduced - LogFormatJsonMap. This option should contain a json for mapping keys in log file into awstats's predefined keys. This configuration will be used only if the LogFormat will have the value json. Example:

LogFormat=json
LogFormatJsonMap={"host":"remote_addr","logname":"remote_user","time1":"time","method":"request_method","url":"request_uri","code":"status","size":"bytes_sent","referer":"http_referer","agent":"http_user_agent"}

NB. The are no direct correspondence of predefined keys and $pos_* variables. So LogFormatJsonMap should use suffixes from $pos_* variables. As example: instead of bytesd the key size should be used; instead of ua - agent.