From fed62b6c451dc80c72262216d80268c276cc68c9 Mon Sep 17 00:00:00 2001 From: Aditya Ujeniya Date: Fri, 12 Dec 2025 14:51:01 +0100 Subject: [PATCH] Functionality to configure resampling --- cmd/cc-backend/init.go | 7 +++---- configs/config-demo.json | 15 ++++++++++----- internal/config/config.go | 7 +++++++ internal/config/schema.go | 4 ++++ web/frontend/package-lock.json | 5 ----- 5 files changed, 24 insertions(+), 14 deletions(-) diff --git a/cmd/cc-backend/init.go b/cmd/cc-backend/init.go index dd044ba..a1d1e23 100644 --- a/cmd/cc-backend/init.go +++ b/cmd/cc-backend/init.go @@ -32,11 +32,10 @@ const configString = ` "addr": "127.0.0.1:8080", "short-running-jobs-duration": 300, "resampling": { - "trigger": 30, + "minimumPoints": 600, + "trigger": 180, "resolutions": [ - 600, - 300, - 120, + 240, 60 ] }, diff --git a/configs/config-demo.json b/configs/config-demo.json index 6f4c053..70ca2a0 100644 --- a/configs/config-demo.json +++ b/configs/config-demo.json @@ -3,10 +3,16 @@ "addr": "127.0.0.1:8080", "short-running-jobs-duration": 300, "resampling": { - "trigger": 30, - "resolutions": [600, 300, 120, 60] + "minimumPoints": 600, + "trigger": 180, + "resolutions": [ + 240, + 60 + ] }, - "apiAllowedIPs": ["*"], + "apiAllowedIPs": [ + "*" + ], "emission-constant": 317 }, "cron": { @@ -82,5 +88,4 @@ }, "retention-in-memory": "48h" } -} - +} \ No newline at end of file diff --git a/internal/config/config.go b/internal/config/config.go index 8872b15..dca6fc3 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -12,6 +12,7 @@ import ( "time" cclog "github.com/ClusterCockpit/cc-lib/ccLogger" + "github.com/ClusterCockpit/cc-lib/resampler" ) type ProgramConfig struct { @@ -78,6 +79,8 @@ type ProgramConfig struct { } type ResampleConfig struct { + // Minimum number of points to trigger resampling of data + MinimumPoints int `json:"minimumPoints"` // Array of resampling target resolutions, in seconds; Example: [600,300,60] Resolutions []int `json:"resolutions"` // Trigger next zoom level at less than this many visible datapoints @@ -140,4 +143,8 @@ func Init(mainConfig json.RawMessage, clusterConfig json.RawMessage) { if len(Clusters) < 1 { cclog.Abort("Config Init: At least one cluster required in config. Exited with error.") } + + if Keys.EnableResampling.MinimumPoints > 0 { + resampler.SetMinimumRequiredPoints(Keys.EnableResampling.MinimumPoints) + } } diff --git a/internal/config/schema.go b/internal/config/schema.go index 06b3b3d..ed1f42d 100644 --- a/internal/config/schema.go +++ b/internal/config/schema.go @@ -102,6 +102,10 @@ var configSchema = ` "description": "Enable dynamic zoom in frontend metric plots.", "type": "object", "properties": { + "minimumPoints": { + "description": "Minimum points to trigger resampling of time-series data.", + "type": "integer" + }, "trigger": { "description": "Trigger next zoom level at less than this many visible datapoints.", "type": "integer" diff --git a/web/frontend/package-lock.json b/web/frontend/package-lock.json index 86f8e69..4c7e4bf 100644 --- a/web/frontend/package-lock.json +++ b/web/frontend/package-lock.json @@ -621,7 +621,6 @@ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz", "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "license": "MIT", - "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -822,7 +821,6 @@ "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.12.0.tgz", "integrity": "sha512-DKKrynuQRne0PNpEbzuEdHlYOMksHSUI8Zc9Unei5gTsMNA2/vMpoMz/yKba50pejK56qj98qM0SjYxAKi13gQ==", "license": "MIT", - "peer": true, "engines": { "node": "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0" } @@ -929,7 +927,6 @@ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "license": "MIT", - "peer": true, "engines": { "node": ">=12" }, @@ -984,7 +981,6 @@ "integrity": "sha512-w8GmOxZfBmKknvdXU1sdM9NHcoQejwF/4mNgj2JuEEdRaHwwF12K7e9eXn1nLZ07ad+du76mkVsyeb2rKGllsA==", "devOptional": true, "license": "MIT", - "peer": true, "dependencies": { "@types/estree": "1.0.8" }, @@ -1165,7 +1161,6 @@ "resolved": "https://registry.npmjs.org/svelte/-/svelte-5.44.0.tgz", "integrity": "sha512-R7387No2zEGw4CtYtI2rgsui6BqjFARzoZFGLiLN5OPla0Pq4Ra2WwcP/zBomP3MYalhSNvF1fzDMuU0P0zPJw==", "license": "MIT", - "peer": true, "dependencies": { "@jridgewell/remapping": "^2.3.4", "@jridgewell/sourcemap-codec": "^1.5.0",