Per-domain Nginx log analytics with hybrid static reports and live insights.
Find a file
ngxstat-bot fab91d2e04 Phase 1 UX + JS transforms: tabs, windowing, percent/grouping, smoothing, stacked series, metadata pass-through, top_n
- Replace tabs with Recent/Trends/Distribution/Tables/Analysis and add sticky controls (interval, domain, window [default 7d], percent, group small, exclude '-' -> Uncached, smoothing toggle).

- Client-side transforms: time-window slicing, percent mode, group others (3%), per-report exclusions; stackedBar multi-series; moving average for error_rate.

- Generator: pass through optional UX metadata (windows_supported, window_default, group_others_threshold, exclude_values, top_n, stacked, palette) and enforce top_n LIMIT for table reports.

- Reports: add status_classes_timeseries and cache_status_timeseries; apply top_n=50 to heavy tables.

- Chart manager: add helpers (sliceWindow, excludeValues, toPercent, groupOthers, movingAverage).

- URL state + localStorage for context; per-tab filtering for Trends/Distribution/Tables.
2025-08-18 23:01:00 -05:00
.forgejo/workflows ci: ensure repo root on PYTHONPATH when running pytest 2025-08-16 05:29:20 -05:00
scripts Phase 1 UX + JS transforms: tabs, windowing, percent/grouping, smoothing, stacked series, metadata pass-through, top_n 2025-08-18 23:01:00 -05:00
static Phase 1 UX + JS transforms: tabs, windowing, percent/grouping, smoothing, stacked series, metadata pass-through, top_n 2025-08-18 23:01:00 -05:00
templates Phase 1 UX + JS transforms: tabs, windowing, percent/grouping, smoothing, stacked series, metadata pass-through, top_n 2025-08-18 23:01:00 -05:00
tests lint: remove unused Path import in tests/test_nginx_config.py 2025-08-16 05:27:02 -05:00
.flake8 lint: re-enable E402; remove sys.path hacks; drop unused pytest imports in tests 2025-08-16 05:24:14 -05:00
.gitignore Update requirements and AGENTS instructions 2025-07-17 00:17:46 -05:00
AGENTS.md docs: refresh README and agent guide 2025-07-19 04:31:13 -05:00
LICENSE Initial commit 2025-07-16 22:42:28 -05:00
README.md docs: refresh README and agent guide 2025-07-19 04:31:13 -05:00
reports.yml Phase 1 UX + JS transforms: tabs, windowing, percent/grouping, smoothing, stacked series, metadata pass-through, top_n 2025-08-18 23:01:00 -05:00
requirements.txt Add YAML-driven report generation 2025-07-18 01:24:26 -05:00
run-analysis.sh Add lock files and cron setup 2025-07-19 03:35:18 -05:00
run-import.sh Add lock files and cron setup 2025-07-19 03:35:18 -05:00
run-reports.sh Add lock files and cron setup 2025-07-19 03:35:18 -05:00
setup.sh Add lock files and cron setup 2025-07-19 03:35:18 -05:00

ngxstat

ngxstat is a lightweight log analytics toolkit for Nginx. It imports access logs into an SQLite database and renders static dashboards so you can explore per-domain metrics without running a heavy backend service.

Requirements

  • Python 3.10+
  • Access to the Nginx log files (default: /var/log/nginx)

The helper scripts create a virtual environment on first run, but you can also set one up manually:

python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Importing Logs

Run the importer to ingest new log entries into database/ngxstat.db:

./run-import.sh

Rotated logs are processed in order and only entries newer than the last imported timestamp are added.

Generating Reports

To build the HTML dashboard and JSON data files use run-reports.sh which runs all intervals in one go:

./run-reports.sh

The script calls scripts/generate_reports.py internally to create hourly, daily, weekly and monthly reports. Per-domain reports are written under output/domains/<domain> alongside the aggregate data. Open output/index.html in a browser to view the dashboard.

If you prefer to run individual commands you can invoke the generator directly:

python scripts/generate_reports.py hourly
python scripts/generate_reports.py daily --all-domains

Analysis Helpers

run-analysis.sh executes additional utilities that examine the database for missing domains, caching opportunities and potential threats. The JSON output is saved under output/analysis and appears in the "Analysis" tab of the dashboard.

./run-analysis.sh

Serving the Reports

The generated files are static. You can serve them with a simple Nginx block:

server {
    listen 80;
    server_name example.com;
    root /path/to/ngxstat/output;

    location / {
        try_files $uri $uri/ =404;
    }
}

Restrict access if the reports should not be public.

Running Tests

Install the development dependencies and execute the suite with pytest:

pip install -r requirements.txt
pytest -q

All tests must pass before submitting changes.

Acknowledgements

ngxstat uses the following thirdparty resources:

The project is licensed under the GPLv3. Icon assets remain in the public domain via the CC0 license.