From 93eac532c4d16fb26822142a55adecc92ff59ed2 Mon Sep 17 00:00:00 2001 From: Jan Eitzinger Date: Thu, 27 Aug 2026 12:17:57 +0200 Subject: [PATCH] feat: default to average downsampling Average consolidation makes every plotted point the true arithmetic mean of its interval, which is what the Ganglia-style plot appearance depends on. LTTB deliberately keeps extremes instead, so a plot downsampled with it cannot be read as interval means. resolveResampleAlgo used to return an empty string when neither the user nor the config had chosen an algorithm, and cc-lib's GetResampler maps that to LTTB. Route every fallback through config.ResampleAlgo() and ship "average" as the generated and example default. Co-Authored-By: Claude Opus 5 (1M context) --- cmd/cc-backend/init.go | 2 +- configs/config.json | 2 +- internal/config/schema.go | 2 +- internal/graph/resample.go | 12 ++++-------- .../src/config/user/PlotRenderOptions.svelte | 5 ++++- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/cmd/cc-backend/init.go b/cmd/cc-backend/init.go index d7bcaf32..e11576b1 100644 --- a/cmd/cc-backend/init.go +++ b/cmd/cc-backend/init.go @@ -25,7 +25,7 @@ const configString = ` "short-running-jobs-duration": 300, "resampling": { "default-policy": "medium", - "default-algo": "lttb" + "default-algo": "average" }, "api-allowed-ips": [ "*" diff --git a/configs/config.json b/configs/config.json index df85cb3c..89995746 100644 --- a/configs/config.json +++ b/configs/config.json @@ -15,7 +15,7 @@ }, "resampling": { "default-policy": "medium", - "default-algo": "lttb" + "default-algo": "average" }, "footer-links": { "imprint": "/imprint", diff --git a/internal/config/schema.go b/internal/config/schema.go index 7a1ecb2a..483ca90e 100644 --- a/internal/config/schema.go +++ b/internal/config/schema.go @@ -98,7 +98,7 @@ var configSchema = ` "enum": ["low", "medium", "high"] }, "default-algo": { - "description": "Default resample algorithm when no user preference is set.", + "description": "Default resample algorithm when no user preference is set. Default and recommended: 'average' (RRDTool-style interval averaging).", "type": "string", "enum": ["lttb", "average", "simple"] } diff --git a/internal/graph/resample.go b/internal/graph/resample.go index a1b0406f..c33aa6db 100644 --- a/internal/graph/resample.go +++ b/internal/graph/resample.go @@ -63,12 +63,12 @@ func resolveResampleAlgo(ctx context.Context, resampleAlgo *model.ResampleAlgo) user := repository.GetUserFromContext(ctx) if user == nil { - return "" + return config.ResampleAlgo() } conf, err := repository.GetUserCfgRepo().GetUIConfig(user) if err != nil { - return "" + return config.ResampleAlgo() } algoVal, ok := conf["plotConfiguration_resampleAlgo"] @@ -78,12 +78,8 @@ func resolveResampleAlgo(ctx context.Context, resampleAlgo *model.ResampleAlgo) } } - // Fall back to global default algo - if config.Keys.EnableResampling != nil && config.Keys.EnableResampling.DefaultAlgo != "" { - return config.Keys.EnableResampling.DefaultAlgo - } - - return "" + // Fall back to the global default algo + return config.ResampleAlgo() } // resolveResolutionFromDefaultPolicy computes a resolution using the global diff --git a/web/frontend/src/config/user/PlotRenderOptions.svelte b/web/frontend/src/config/user/PlotRenderOptions.svelte index c26c93f3..b8b96ae9 100644 --- a/web/frontend/src/config/user/PlotRenderOptions.svelte +++ b/web/frontend/src/config/user/PlotRenderOptions.svelte @@ -301,7 +301,10 @@ {/each}
- Algorithm used when downsampling time-series data. LTTB preserves visual shape, Average smooths data, Simple picks every Nth point. + Algorithm used when downsampling time-series data. Average (the + default) makes every plotted point the true mean of its interval, + LTTB preserves visual shape by keeping extremes, Simple picks every + Nth point.