From 426a249bdb9b365efb4b12fb5a66a16b285d01b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Borna=20=C5=A0unji=C4=87?= Date: Fri, 17 Apr 2026 10:25:04 +0200 Subject: [PATCH 1/2] refactor: timerange type --- src/components/prometheus/queries.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/prometheus/queries.ts b/src/components/prometheus/queries.ts index 557b2b81..c8659b1a 100644 --- a/src/components/prometheus/queries.ts +++ b/src/components/prometheus/queries.ts @@ -1,4 +1,9 @@ -export type TimeRange = '30s' | '2m' | '5m' | '1h' | '1d'; +type TimeUnit = 'ms' | 's' | 'm' | 'h' | 'd' | 'w' | 'y'; +type UnitDuration = `${bigint}${TimeUnit}`; +export type TimeRange = + | `${number}` + | UnitDuration + | `${UnitDuration}${UnitDuration}`; const metricName = 'http_server_duration_milliseconds'; const countPostfix = 'count'; From 6df26d571ce3030b49506936e65584d630d73f6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Borna=20=C5=A0unji=C4=87?= Date: Fri, 17 Apr 2026 11:27:31 +0200 Subject: [PATCH 2/2] docs: add comment explaining timerange type --- src/components/prometheus/queries.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/components/prometheus/queries.ts b/src/components/prometheus/queries.ts index c8659b1a..108e7adb 100644 --- a/src/components/prometheus/queries.ts +++ b/src/components/prometheus/queries.ts @@ -1,5 +1,9 @@ type TimeUnit = 'ms' | 's' | 'm' | 'h' | 'd' | 'w' | 'y'; type UnitDuration = `${bigint}${TimeUnit}`; +/** + * PromQL time duration format. Supports floats in seconds (e.g. '90', '1.5'), + * unit suffixes (e.g. '30s', '5m', '1h'), and combined durations (e.g. '1h30m'). + */ export type TimeRange = | `${number}` | UnitDuration