Add YAML-driven report generation
This commit is contained in:
parent
1a6dab950d
commit
6241fd2685
6 changed files with 214 additions and 60 deletions
23
README.md
23
README.md
|
@ -24,6 +24,29 @@ python scripts/generate_reports.py monthly
|
|||
|
||||
Reports are written under the `output/` directory. Each command updates the corresponding `<interval>.json` file and produces an HTML dashboard using Chart.js.
|
||||
|
||||
### Configuring Reports
|
||||
|
||||
Report queries are defined in `reports.yml`. Each entry specifies the `name`,
|
||||
`interval`, optional `label` and `chart` type, and a SQL `query` that must return
|
||||
`bucket` and `value` columns. When `generate_reports.py` runs, every matching
|
||||
definition creates `output/<interval>/<name>.json` and an interval dashboard.
|
||||
|
||||
Example snippet:
|
||||
|
||||
```yaml
|
||||
- name: hits
|
||||
interval: hourly
|
||||
chart: bar
|
||||
query: |
|
||||
SELECT strftime('%Y-%m-%d %H:00:00', datetime(time)) AS bucket,
|
||||
COUNT(*) AS value
|
||||
FROM logs
|
||||
GROUP BY bucket
|
||||
ORDER BY bucket
|
||||
```
|
||||
|
||||
Add or modify entries in `reports.yml` to tailor the generated metrics.
|
||||
|
||||
## Importing Logs
|
||||
|
||||
Use the `run-import.sh` script to set up the Python environment if needed and import the latest Nginx log entries into `database/ngxstat.db`.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue