Add CSV export of the logs matching the current filters

- GET /api/export.csv streams every stored log matching the filters
  (newest first, up to EXPORT_MAX rows, 100000 by default) straight from
  VictoriaLogs, with dates in the time zone chosen in Settings.
- Export button with two variants: CSV (comma, UTF-8) and CSV for Excel
  (semicolon + BOM, formula injection neutralized).
- Store.QueryStream streams query results without buffering them.
- Mobile: filter bar keeps two selects per row, count next to Export.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
cedricandClaude Opus 5.5 committed 2026-09-28 16:26:40 +02:00
1 parent 84e71f741c
commit 328384032b
10 files changed
+316 -23

No files matched your search

+3
View File
@@ -18,6 +18,7 @@ type API struct {
tags *TagStore
rdns *ReverseDNS
allowPurge bool
exportMax int
}
func (a *API) Routes(mux *http.ServeMux) {
@@ -34,6 +35,7 @@ func (a *API) Routes(mux *http.ServeMux) {
mux.HandleFunc("DELETE /api/tags/{id}", a.deleteTag)
mux.HandleFunc("GET /api/purge", a.purgeStatus)
mux.HandleFunc("POST /api/purge", a.purge)
mux.HandleFunc("GET /api/export.csv", a.exportCSV)
}
func writeJSON(w http.ResponseWriter, status int, v any) {
@@ -261,6 +263,7 @@ func (a *API) stream(w http.ResponseWriter, r *http.Request) {
func (a *API) stats(w http.ResponseWriter, r *http.Request) {
s := a.store.Stats()
s["clients"] = a.hub.Count()
s["exportMax"] = a.exportMax
writeJSON(w, http.StatusOK, s)
}