Refactor reports to share definitions across intervals
This commit is contained in:
parent
99a6b45d4c
commit
657c30b260
4 changed files with 38 additions and 18 deletions
13
README.md
13
README.md
|
@ -27,18 +27,21 @@ Reports are written under the `output/` directory. Each command updates the corr
|
|||
### 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.
|
||||
optional `label` and `chart` type, and a SQL `query` that must return `bucket`
|
||||
and `value` columns. The special token `{bucket}` is replaced with the
|
||||
appropriate SQLite `strftime` expression for each interval (hourly, daily,
|
||||
weekly or monthly) so that a single definition works across all durations.
|
||||
When `generate_reports.py` runs, every definition is executed for the requested
|
||||
interval and creates `output/<interval>/<name>.json` along with an HTML
|
||||
dashboard.
|
||||
|
||||
Example snippet:
|
||||
|
||||
```yaml
|
||||
- name: hits
|
||||
interval: hourly
|
||||
chart: bar
|
||||
query: |
|
||||
SELECT strftime('%Y-%m-%d %H:00:00', datetime(time)) AS bucket,
|
||||
SELECT {bucket} AS bucket,
|
||||
COUNT(*) AS value
|
||||
FROM logs
|
||||
GROUP BY bucket
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue