[APP-450] feat: guard time series queries with minimum and maximum granularity#8493
Merged
briangregoryholmes merged 52 commits intomainfrom Feb 3, 2026
Merged
Conversation
…/determine-max-interval-precision
AdityaHegde
requested changes
Jan 23, 2026
Collaborator
AdityaHegde
left a comment
There was a problem hiding this comment.
The chart in explores disappears if you switch between large and small time ranges.
- Select 15mins, grain will be minute
- Select 12months, grain will be day.
- Select 15mins again, chart disappears. Comes back when you select a grain.
web-common/src/features/dashboards/time-series/MetricsTimeSeriesCharts.svelte
Show resolved
Hide resolved
web-common/src/features/dashboards/state-managers/loaders/DashboardStateSync.ts
Outdated
Show resolved
Hide resolved
AdityaHegde
approved these changes
Jan 26, 2026
Collaborator
AdityaHegde
left a comment
There was a problem hiding this comment.
Just a nit. Otherwise LGTM.
Have done some basic testing, the previous issue I raised doesnt exist anymore. @mindspank @nishantmonu51 Could one of you do some UXQA?
web-common/src/features/dashboards/time-controls/time-control-store.ts
Outdated
Show resolved
Hide resolved
AdityaHegde
approved these changes
Jan 27, 2026
mindspank
approved these changes
Feb 1, 2026
briangregoryholmes
added a commit
that referenced
this pull request
Feb 3, 2026
…anularity (#8493) * wip * remove logs * cleanup * test fixes * remove logs * quality check * test fix * remove logs * test fixes * tooltip adjustment * test fixes * rilltime cleanup * test updates * test fix * test fix * test fix * feedback * comment * ux feedback * wip * initial pass at explore support * cleanup * rework allowed grains * cleanup * increase limit * simplify boolean * remove code duplication * quality checks * test fixes * test fixes * move function * reorg * remove comments * tests and adjustments * more tests * quality checks * cleanup * quality check * cleanup * reorg function, remove dead code * import fix * test fix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a guard around the min/max precision allowed for time series data. It also limits the options provided in the time series aggregation selector on Explore to only those we deem "valid".
The intention of this PR is to adhere to the following heuristic:
Determine the allowed grains for a given interval based on the duration of the interval and the
smallest_time_grainproperty of the metrics viewAllowed grains should result in no more than 1500 buckets and no fewer than 1 bucket (though this bucket may be partial (as in the case of
24h as of latest/hbyday). However, if all grains are above the max, allowyeargranularity. If all grains produce fewer than 1 complete bucket, allow the smallest_time_grain.If the user has explicitly asked for a certain granularity (i.e., there is a
grainparameter in the url) and it is within the allowed grains for the range, render it. If the requested grain is not in the allowable grains, fall back to the range grain (if allowed) or the smallest of the allowed grains.If there is no explicit granularity requested, we should follow the grain derived from the time string (e.g
dayfor P7D andhourfor7d as of latest/h+1h) if allowed. If not, fall back to the smallest of the allowed grains.Examples
Time Range:
12M as of latest/d+1dURL Grain:
daySmallest Time Grain:
dayRendered in days.
Time Range:
36M as of latest/d+1dURL Grain:
daySmallest Time Grain:
dayRendered in weeks
Time Range:
12h as of latest/h+1hURL Grain:
hourSmallest Time Grain:
dayIn this case, while
houris the range granularity anddayis normally not allowed, the time series will be aggregated by day despite displaying only a single partial bucket. Because of limitations on Explore, the URL grain will be updated today.This logic can be verified on Canvas via the derived
grainStoreintime-state.tsOn Explore, a number of changes were necessary.
selectedTimeRangefrom theShallowMergeOneLevelDeepKeysso that URL grain is reflected directly and not merged from other fallback statehandleExploreInitandhandleURLChangeto derive this grain state once the time range has been resolvedonSelectRangefunctionFilters.svelteto also properly derive this before triggering a state changeHowever, much of this could be simplified if the
/time-rangesAPI returned these allowed grains directly.Open questions:
Is total number of buckets the correct barometer? Both 30 days in hours and 12 hours in minutes would render 720 buckets. Are these equivalently "taxing" on the database?What is the appropriate number of buckets to cap at? The API limit is quite high and the practical rendering limit is around 1000 (though can be increased with a rework of the time series component). 731 was somewhat arbitrary, but this was chosen to allow looking at two years worth of days.Checklist: