- 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. |
||
---|---|---|
.forgejo/workflows | ||
scripts | ||
static | ||
templates | ||
tests | ||
.flake8 | ||
.gitignore | ||
AGENTS.md | ||
LICENSE | ||
README.md | ||
reports.yml | ||
requirements.txt | ||
run-analysis.sh | ||
run-import.sh | ||
run-reports.sh | ||
setup.sh |
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 third‑party resources:
- Chart.js for charts
- DataTables and jQuery for table views
- Bulma CSS for styling
- Icons from Free CC0 Icons by Jon Hicks (CC0 / MIT)
- Typer for the command-line interface
- Jinja2 for templating
The project is licensed under the GPLv3. Icon assets remain in the public domain via the CC0 license.