# Web Statistics and Analytics
This package produces web statistics and analytical output based on nginx access log files.
[](https://pypi.org/project/a9x-webstatistics/) [](https://github.com/ava007/a9x-webstatistics/releases) [](https://github.com/ava007/a9x-webstatistics/actions) [](https://github.com/ava007/a9x-webstatistics/blob/main/LICENSE)
[](https://pypistats.org/packages/a9x-webstatistics)
[](https://pypi.org/project/a9x-webstatistics)
## Live Examples
Visit the live examples on [logikfabrik.com](https://www.logikfabrik.com/aboutwebstats.html).
<img src="https://github.com/ava007/a9x-webstatistics/blob/main/a9x_webstats_20250612.png">
## Installation
```bash
pip install a9x-webstatistics
```
## Requirements on Linux / Unix
- access log file from web server
- standard access log file from nginx, freenginx or apache
- access log file in json format
- python3.9 onwards
- optional: maxmind db which need to be download by end user after registration
## Deployment on Linux / Unix
```bash
#!/bin/sh
export LOG=/usr/local/www/webstats.log
export PATH=/usr/local/www/django5/envpy311/bin:$PATH
python3.11 -m a9x_webstatistics.main \
--infile /var/log/nginx-access.log \
--geoip /usr/local/share/GeoIP/GeoLite2-Country.mmdb \
--domain https://www.logikfabrik.com \
--statfile /usr/local/www/lf_static/webstatsLF24.json &> $LOG
python3.11 -m a9x_webstatistics.gencockpit \
--infile /usr/local/www/lf_static/webstatsLF24.json \
--outfile /usr/local/www/lf_static/webstatsLF24.html &>> $LOG
```
Cron-Job Entry for Linux / FreeBSD:
```bash
#minute hour mday month wday who command
13,58 * * * * dj1 /usr/local/www/cronjobs/cron_webstatistics.sh
```
## Installation on Windows
```bash
# install on windows:
## install a virtual env for python
python -m venv c:\temp\webstatsenv
## activate env
c:\temp\webstatsenv\Scripts\activate.bat
## install a9x-webstatistics
pip install a9x-webstatistics
python -m pip install --upgrade pip
python -m pip list
```
## Deployment on Windows
```bash
# run
c:
cd \temp
wget -URI https://www.logikfabrik.com/wlog/access.log -OutFile access.log
## active env
c:\temp\webstatsenv\Scripts\activate.bat
## create calculate statistics
## there are no country statistics created as not geoip defined
python -m a9x_webstatistics.main --infile access.log --statfile webstatsLF.json
## create html file for webstatistics
python -m a9x_webstatistics.gencockpit --infile webstatsLF.json --outfile webstatsLF.html
```
## Extended Example
```bash
#!/bin/sh
export LOG=/usr/local/www/webstats.log
export PATH=/usr/local/www/django5/envpy311/bin:$PATH
_YEARNUM="$(date +'%Y')";
_MONTHNUM="$(date +'%m')";
# make a archive copy for every month:
cp /usr/local/www/lf_static/webstatsLF24.json /usr/local/www/lf_static/webstatsLF24$_YEARNUM$_MONTHNUM.json
cp /usr/local/www/lf_static/webstatsLF24.html /usr/local/www/lf_static/webstatsLF24$_YEARNUM$_MONTHNUM.html
# updates all packages:
pip install -U `pip list --outdated | awk 'NR > 2 {print $1}'` >> $LOG
python3.11 -m a9x_webstatistics.main \
--infile /var/log/nginx-access.log \
--geoip /usr/local/share/GeoIP/GeoLite2-Country.mmdb \
--domain https://www.logikfabrik.com \
--statfile /usr/local/www/lf_static/webstatsLF24.json &> $LOG
python3.11 -m a9x_webstatistics.gencockpit \
--infile /usr/local/www/lf_static/webstatsLF24.json \
--outfile /usr/local/www/lf_static/webstatsLF24.html &>> $LOG
```
# Supported Access Log Formats
## Nginx Combined Format
predefined combined format: access_log /.../logs/nginx-access.log combined;
## Nginx Json Format
```bash
log_format a9x_logs escape=json '{'
'"tl":"$time_local",'
'"ip":"$remote_addr",' # must; client IP
'"rq":"$request_uri",' # must; full original request URI (with arguments)
'"qs":"$query_string",' # optional
'"st":"$status",' # must; response status code
'"ru":"$remote_user",' # optional; client HTTP username
'"bs":"$bytes_sent", ' # must; the number of bytes sent to a client
'"rf":"$http_referer",' # optional;
'"rt":"$upstream_response_time", ' # optional; time spend receiving upstream body
'"sc":"$scheme", ' # optional; http or https
'"ua":"$http_user_agent",' # optional
'"cs":"$upstream_cache_status",' # optional
'"al":"$http_accept_language",' # optional
'}';
access_log /.../log/nginx-access-log.json a9x_logs buffer=1k;
```
## Apache Combined Format
CustomLog /.../log/apache2/apache_access.log combined
Raw data
{
"_id": null,
"home_page": "https://github.com/ava007/a9x-webstatistics",
"name": "a9x-webstatistics",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "webstats, statistics, analytics",
"author": "Andr\u00e9 von Arx",
"author_email": "avonarx@outlook.de",
"download_url": "https://files.pythonhosted.org/packages/b4/db/4a8215ce36a30f65e968b389e4c3a99e69e7cd28e883bbfe94abb29acecc/a9x_webstatistics-1.8.7.tar.gz",
"platform": null,
"description": "# Web Statistics and Analytics\n\nThis package produces web statistics and analytical output based on nginx access log files.\n\n[](https://pypi.org/project/a9x-webstatistics/) [](https://github.com/ava007/a9x-webstatistics/releases) [](https://github.com/ava007/a9x-webstatistics/actions) [](https://github.com/ava007/a9x-webstatistics/blob/main/LICENSE)\n\n[](https://pypistats.org/packages/a9x-webstatistics)\n[](https://pypi.org/project/a9x-webstatistics)\n\n## Live Examples\n\nVisit the live examples on [logikfabrik.com](https://www.logikfabrik.com/aboutwebstats.html).\n\n<img src=\"https://github.com/ava007/a9x-webstatistics/blob/main/a9x_webstats_20250612.png\">\n\n## Installation\n\n```bash\npip install a9x-webstatistics\n```\n\n\n## Requirements on Linux / Unix\n- access log file from web server\n - standard access log file from nginx, freenginx or apache\n - access log file in json format\n- python3.9 onwards\n- optional: maxmind db which need to be download by end user after registration\n\n\n## Deployment on Linux / Unix\n\n```bash\n#!/bin/sh\n\nexport LOG=/usr/local/www/webstats.log\nexport PATH=/usr/local/www/django5/envpy311/bin:$PATH\n\npython3.11 -m a9x_webstatistics.main \\\n --infile /var/log/nginx-access.log \\\n --geoip /usr/local/share/GeoIP/GeoLite2-Country.mmdb \\\n --domain https://www.logikfabrik.com \\\n --statfile /usr/local/www/lf_static/webstatsLF24.json &> $LOG\n\npython3.11 -m a9x_webstatistics.gencockpit \\\n --infile /usr/local/www/lf_static/webstatsLF24.json \\\n --outfile /usr/local/www/lf_static/webstatsLF24.html &>> $LOG\n```\n\nCron-Job Entry for Linux / FreeBSD:\n```bash\n#minute hour mday month wday who command\n13,58 * * * * dj1 /usr/local/www/cronjobs/cron_webstatistics.sh\n\n```\n\n\n## Installation on Windows\n\n```bash\n# install on windows:\n\n## install a virtual env for python\npython -m venv c:\\temp\\webstatsenv\n\n## activate env\nc:\\temp\\webstatsenv\\Scripts\\activate.bat\n\n## install a9x-webstatistics\npip install a9x-webstatistics\npython -m pip install --upgrade pip\npython -m pip list\n```\n\n## Deployment on Windows\n\n```bash\n# run\nc:\ncd \\temp\nwget -URI https://www.logikfabrik.com/wlog/access.log -OutFile access.log\n\n## active env\nc:\\temp\\webstatsenv\\Scripts\\activate.bat\n\n## create calculate statistics\n## there are no country statistics created as not geoip defined\npython -m a9x_webstatistics.main --infile access.log --statfile webstatsLF.json\n\n## create html file for webstatistics\npython -m a9x_webstatistics.gencockpit --infile webstatsLF.json --outfile webstatsLF.html\n```\n\n## Extended Example\n\n```bash\n#!/bin/sh\n\nexport LOG=/usr/local/www/webstats.log\nexport PATH=/usr/local/www/django5/envpy311/bin:$PATH\n\n_YEARNUM=\"$(date +'%Y')\";\n_MONTHNUM=\"$(date +'%m')\";\n\n# make a archive copy for every month:\ncp /usr/local/www/lf_static/webstatsLF24.json /usr/local/www/lf_static/webstatsLF24$_YEARNUM$_MONTHNUM.json\ncp /usr/local/www/lf_static/webstatsLF24.html /usr/local/www/lf_static/webstatsLF24$_YEARNUM$_MONTHNUM.html\n\n# updates all packages:\npip install -U `pip list --outdated | awk 'NR > 2 {print $1}'` >> $LOG\n\n\npython3.11 -m a9x_webstatistics.main \\\n --infile /var/log/nginx-access.log \\\n --geoip /usr/local/share/GeoIP/GeoLite2-Country.mmdb \\\n --domain https://www.logikfabrik.com \\\n --statfile /usr/local/www/lf_static/webstatsLF24.json &> $LOG\n\npython3.11 -m a9x_webstatistics.gencockpit \\\n --infile /usr/local/www/lf_static/webstatsLF24.json \\\n --outfile /usr/local/www/lf_static/webstatsLF24.html &>> $LOG\n```\n# Supported Access Log Formats\n\n\n\n## Nginx Combined Format\n\npredefined combined format: access_log /.../logs/nginx-access.log combined;\n\n\n## Nginx Json Format\n\n```bash\nlog_format a9x_logs escape=json '{'\n '\"tl\":\"$time_local\",'\n '\"ip\":\"$remote_addr\",' # must; client IP\n '\"rq\":\"$request_uri\",' # must; full original request URI (with arguments)\n '\"qs\":\"$query_string\",' # optional\n '\"st\":\"$status\",' # must; response status code\n '\"ru\":\"$remote_user\",' # optional; client HTTP username\n '\"bs\":\"$bytes_sent\", ' # must; the number of bytes sent to a client\n '\"rf\":\"$http_referer\",' # optional;\n '\"rt\":\"$upstream_response_time\", ' # optional; time spend receiving upstream body\n '\"sc\":\"$scheme\", ' # optional; http or https\n '\"ua\":\"$http_user_agent\",' # optional\n '\"cs\":\"$upstream_cache_status\",' # optional\n '\"al\":\"$http_accept_language\",' # optional\n'}';\n\naccess_log /.../log/nginx-access-log.json a9x_logs buffer=1k;\n```\n\n## Apache Combined Format\n\n\nCustomLog /.../log/apache2/apache_access.log combined\n\n\n",
"bugtrack_url": null,
"license": null,
"summary": "Web Statistics and Analytics Package",
"version": "1.8.7",
"project_urls": {
"Bug Reports": "https://github.com/ava007/a9x-webstatistics/issues",
"Documentation": "https://github.com/ava007/a9x-webstatistics",
"Homepage": "https://github.com/ava007/a9x-webstatistics",
"Source Code": "https://github.com/ava007/a9x-webstatistics"
},
"split_keywords": [
"webstats",
" statistics",
" analytics"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "ed6882a20f3c89bd290865ff6f50ac19c76bdc5cf64240aa2f36a8866e7e3d62",
"md5": "e1ba6a5f1c06dda9a3a557943c77046b",
"sha256": "3b302de4a626a553d5969fd4bd358bb012dea1dc9d44c9fb861dafb69a52ed2d"
},
"downloads": -1,
"filename": "a9x_webstatistics-1.8.7-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e1ba6a5f1c06dda9a3a557943c77046b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 79950,
"upload_time": "2025-07-08T17:19:11",
"upload_time_iso_8601": "2025-07-08T17:19:11.081049Z",
"url": "https://files.pythonhosted.org/packages/ed/68/82a20f3c89bd290865ff6f50ac19c76bdc5cf64240aa2f36a8866e7e3d62/a9x_webstatistics-1.8.7-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "b4db4a8215ce36a30f65e968b389e4c3a99e69e7cd28e883bbfe94abb29acecc",
"md5": "bc7f7ac639152d859367a1a82d9515cb",
"sha256": "5265c9dbede4ec7ac089100db3aaf9229110891a6f4f8735cd2b8b628f8517a4"
},
"downloads": -1,
"filename": "a9x_webstatistics-1.8.7.tar.gz",
"has_sig": false,
"md5_digest": "bc7f7ac639152d859367a1a82d9515cb",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 388038,
"upload_time": "2025-07-08T17:19:12",
"upload_time_iso_8601": "2025-07-08T17:19:12.815699Z",
"url": "https://files.pythonhosted.org/packages/b4/db/4a8215ce36a30f65e968b389e4c3a99e69e7cd28e883bbfe94abb29acecc/a9x_webstatistics-1.8.7.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-08 17:19:12",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ava007",
"github_project": "a9x-webstatistics",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "a9x-webstatistics"
}