Prometheus: Invest in tests and docs for min interval or min step explanation (#80165)

* add clearer comment for function def

* update test to reflect change in range for 1w step

* clarify docs

* add more clarity

* add explanation to query options min interval and link to min step

* Update docs/sources/panels-visualizations/query-transform-data/_index.md

Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com>

---------

Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com>
This commit is contained in:
Brendan O'Handley
2024-01-22 08:44:46 -06:00
committed by GitHub
co-authored by Isabel
parent 639bf3036d
commit 3409e0ea5a
4 changed files with 33 additions and 3 deletions
+5
View File
@@ -284,6 +284,11 @@ func isVariableInterval(interval string) bool {
return false
}
// This function aligns query range to step and handles the time offset.
// It rounds start and end down to a multiple of step.
// Prometheus caching is dependent on the range being aligned with the step.
// Rounding to the step can significantly change the start and end of the range for larger steps, i.e. a week.
// In rounding the range to a 1w step the range will always start on a Thursday.
func AlignTimeRange(t time.Time, step time.Duration, offset int64) time.Time {
offsetNano := float64(offset * 1e9)
stepNano := float64(step.Nanoseconds())